Skip to content
Snippets Groups Projects
Commit 6c163aad authored by dronus's avatar dronus
Browse files

Test-Bilderzeugung aus Sender ausgelagert

parent 0df138fb
No related branches found
No related tags found
No related merge requests found
test
sender
#include<stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define WIDTH 1000
#define HEIGHT 8
#define WIDTH 60
#define HEIGHT 16
int image[WIDTH*HEIGHT];
char data[(WIDTH*HEIGHT/8)*6*4+1];
int image_new[WIDTH*HEIGHT];
int image_old[WIDTH*HEIGHT];
char data[(WIDTH*HEIGHT/8)*6*4+3];
void image2data(int* image, char* data, int layout) {
int offset = 1;
int offset = 3;
int x, y, xbegin, xend, xinc, mask;
int linesPerPin = HEIGHT / 8;
int pixel[8];
data[0]='*';
data[1]=0; // sync delay, sync immediately.
data[2]=0;
for (y = 0; y < linesPerPin; y++) {
if ((y & 1) == (layout ? 0 : 1)) {
// even numbered rows are left to right
......@@ -62,33 +68,30 @@ int fade(int b, int a, int t)
return (rc<<0)+(gc<<8)+(bc<<16);
}
int main() {
int old=0x000000;
while(1)
{
long int r=rand()>>24;
int new=r+((256-r)<<16);
for(int t=0; t<256; t+=16)
{
for(int i=0; i<WIDTH*HEIGHT; i++)
//image[i]=c+(c<<8)+(c<<16)+(c<<24);
//image[i]=c;
image[i]=fade(old,new,t);
fprintf(stderr,"Data size: %i \n", (int) sizeof(data));
int read=fread(image_new,1,sizeof(image_new),stdin);
fprintf(stderr,"Sender input size: %i \n", (int)read);
// do a fade
for(int t=0; t<256; t+=1)
{
for(int i=0; i<sizeof(image)/4; i++)
image[i]=fade(image_old[i],image_new[i],t);
image2data(image,data,0);
int written=fwrite(data,1,sizeof(data),stdout);
fflush(stdout);
fprintf(stderr,"Data written: %i \n", written);
fprintf(stderr,"Sender output written: %i \n", written);
usleep(2000L);
}
old=new;
memcpy(image_old,image_new,sizeof(image_old));
}
}
test.c 0 → 100644
#include<stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define WIDTH 60
#define HEIGHT 16
char image[WIDTH*HEIGHT*4];
int main() {
while(1)
{
for(int i=0; i<WIDTH*HEIGHT; i++)
{
int c=rand() & 0x1F1F1F;
image[i*4+0]=(c >> 0) & 0xFF;
image[i*4+1]=(c >> 8) & 0xFF;
image[i*4+2]=(c >> 16) & 0xFF;
image[i*4+3]=0;
}
int written=fwrite(image,1,sizeof(image),stdout);
fflush(stdout);
fprintf(stderr,"Test image data written: %i \n", written);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment