#include #include /* this program is used to general random pixel selection pattern */ main(int argc, char *argv[]) { FILE *fp; unsigned short pixel[16][16]; unsigned short i,j,k; for(j=0;j<16;j++) for(i=0;i<16;i++) pixel[j][i]=256; pixel[ 3][ 0]= 0; pixel[ 0][14]= 1; pixel[12][ 6]= 2; pixel[ 7][ 1]= 3; pixel[15][ 3]= 4; pixel[ 4][ 9]= 5; pixel[11][ 2]= 6; pixel[ 9][ 4]= 7; pixel[ 2][ 7]= 8; pixel[ 5][15]= 9; pixel[10][13]=10; pixel[ 1][11]=11; pixel[14][12]=12; pixel[ 6][ 5]=13; pixel[ 8][10]=14; pixel[13][ 8]=15; for(k=16;k<256;k++){ while(pixel[j=rand()%16][i=rand()%16]<256); pixel[j][i]=k; } fp=fopen(argv[1],"w"); fprintf(fp,"#include \"prj.h\"\n\n"); fprintf(fp,"set_rand()\n{\n"); for(k=0;k<256;k++){ for(j=0;j<16;j++) for(i=0;i<16;i++) if(pixel[j][i]==k) fprintf(fp," qq[%3d]=%2d; pp[%3d]=%2d;\n",k,j,k,i); } fprintf(fp,"\n}\n"); fclose(fp); /*show the first 16 pixels */ for(j=0;j<16;j++){ for(i=0;i<16;i++) printf(" %c",pixel[j][i]<16? 'X':'_'); printf("\n"); } printf("\n"); }