/* ppm dizer by kumagai masaaki*/ /* as example of xv algorithm extension */ #include #include #include #include #include "ppmif.c" const int dtab[4][4]={ { 0x00, 0x80, 0x20, 0xb0 }, { 0xc0, 0x40, 0xd0, 0x70 }, { 0x30, 0xa0, 0x10, 0x90 }, { 0xe0, 0x60, 0xf0, 0x50 }, } ; /* the algorithm */ void Diz(imgbyte *data,int w,int h,int sx,int sy,int ex,int ey) { int x,y,ry,y2; int r=0,g=0,b=0; imgbyte *p; RegulatePos(w,h,&sx,&sy,&ex,&ey); for(y=sy;y4) ry=4; for(x=sx;x<=ex;x++) { p=data+(w*y+x)*3; for(y2=0;y2dtab[x%4][(y+y2)%4]) { p[0]=0xff; r-=0xff; } else p[0]=0; /* g */ g+=p[1]; if(g>dtab[x%4][(y+y2)%4]) { p[1]=0xff; g-=0xff; } else p[1]=0; /* r */ b+=p[2]; if(b>dtab[x%4][(y+y2)%4]) { p[2]=0xff; b-=0xff; } else p[2]=0; p+=w*3; } } } } int GetOptionInt(char **argv,int *is,int st,int limit,int max) { int i; int ii; if(st+max