X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=pctb%2Fstructure.h;h=263a26ad86fe1e8ea5e0ee588b88d4c1cba0393a;hp=73f65718354a19e88dcdde11c307010d90f709f5;hb=044272b5016efd89618d3725353cdbea9a98d796;hpb=059fab3ad374847da031d23d7e25ee25e888bce0 diff --git a/pctb/structure.h b/pctb/structure.h index 73f6571..263a26a 100644 --- a/pctb/structure.h +++ b/pctb/structure.h @@ -50,43 +50,41 @@ static inline char canon_lookup_colour(unsigned char r, return blues->blue2[b]; } -#define CANONICALISE_IMAGE(im,w,h,rgb_save, COMPUTE_RGB) do{ \ - /* compute_rgb should be a number of statements, or \ - * a block, which assigns to \ - * Rgb rgb; \ - * given the values of \ - * int x,y; \ - * all of which are anamorphic. Result is stored in im. \ - * The COMPUTE_RGB is executed exactly once for \ - * each pixel in reading order. \ - */ \ - (im)= alloc_canon_image((w), (h)); \ - (rgb_save)= alloc_rgb_image((w), (h)); \ - \ - int x,y; \ - for (y=0; y<(h); y++) { \ - for (x=0; x<(w); x++) { \ - unsigned char r,g,b; \ - COMPUTE_RGB; \ - CANONIMG_ALSO_STORERGB((rgb_save)); \ - (im)->d[y*(w) + x]= canon_lookup_colour(r,g,b); \ - } \ - if (DEBUGP(rect)) { \ - fprintf(debug, "%4d ",y); \ - fwrite(im->d + y*(w), 1,(w), debug); \ - fputc('\n',debug); \ - } \ - } \ - debug_flush(); \ +#define CANONICALISE_IMAGE(im,w,h,rgb_save, COMPUTE_RGB) do{ \ + /* compute_rgb should be a number of statements, or \ + * a block, which assigns to \ + * Rgb rgb; \ + * given the values of \ + * int x,y; \ + * all of which are anamorphic. Result is stored in im. \ + * The COMPUTE_RGB is executed exactly once for \ + * each pixel in reading order. \ + */ \ + (im)= alloc_canon_image((w), (h)); \ + (rgb_save)= alloc_rgb_image((w), (h)); \ + \ + int x,y; \ + for (y=0; y<(h); y++) { \ + for (x=0; x<(w); x++) { \ + Rgb rgb; \ + COMPUTE_RGB; \ + CANONIMG_ALSO_STORERGB((rgb_save)); \ + (im)->d[y*(w) + x]= canon_lookup_colour(rgb, rgb>>8, rgb>>16); \ + } \ + if (DEBUGP(rect)) { \ + fprintf(debug, "%4d ",y); \ + fwrite(im->d + y*(w), 1,(w), debug); \ + fputc('\n',debug); \ + } \ + } \ + debug_flush(); \ }while(0) #define CANONIMG_ALSO_STORERGB(ri) \ do{ \ - unsigned char *rip= RI_PIXEL((ri),x,y); \ - rip[0]= r; \ - rip[1]= g; \ - rip[2]= b; \ + Rgb *rip= RI_PIXEL32((ri),x,y); \ + *rip= rgb; \ }while(0)