chiark / gitweb /
Adjust colours early so that we don't have to keep all RGBs in RAM
[ypp-sc-tools.web-live.git] / pctb / structure.h
index 84fdcae2e2a1fb75c004634301b008e4c859cba4..73f65718354a19e88dcdde11c307010d90f709f5 100644 (file)
@@ -50,7 +50,7 @@ static inline char canon_lookup_colour(unsigned char r,
   return blues->blue2[b];
 }
 
-#define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{            \
+#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;                                              \
@@ -61,15 +61,14 @@ static inline char canon_lookup_colour(unsigned char r,
      * each pixel in reading order.                            \
      */                                                                \
     (im)= alloc_canon_image((w), (h));                         \
-    RgbImage *rgb_save;                                                \
-    (im)->rgb= rgb_save= alloc_rgb_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);                      \
+        CANONIMG_ALSO_STORERGB((rgb_save));                    \
        (im)->d[y*(w) + x]= canon_lookup_colour(r,g,b);         \
       }                                                                \
       if (DEBUGP(rect)) {                                      \