chiark / gitweb /
New inline function ri_rgb; introduce typedef for rgb sample
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Jul 2009 00:23:53 +0000 (01:23 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Jul 2009 00:23:53 +0000 (01:23 +0100)
pctb/convert.h
pctb/structure.h

index 83be1e8bced1ab8fce05d7233588595792f74530..b61563fd32449c200b6915484b4fcc9a3d3c7a33 100644 (file)
@@ -51,6 +51,8 @@ typedef struct RgbImage {
    */
 } RgbImage;
 
    */
 } RgbImage;
 
+typedef unsigned long Rgb;
+
 void identify_rgbimage(const RgbImage *base, Rect portion,
                       char result[MAXIMGIDENT], const char *what);
 RgbImage *alloc_rgb_image(int w, int h);
 void identify_rgbimage(const RgbImage *base, Rect portion,
                       char result[MAXIMGIDENT], const char *what);
 RgbImage *alloc_rgb_image(int w, int h);
@@ -58,6 +60,13 @@ void fwrite_ppmraw(FILE *f, const RgbImage *ri);
 
 #define RI_PIXEL(ri,x,y) ((ri)->data + ((y)*(ri)->w + (x)) * 3)
 
 
 #define RI_PIXEL(ri,x,y) ((ri)->data + ((y)*(ri)->w + (x)) * 3)
 
+static inline Rgb ri_rgb(const RgbImage *ri, int x, int y) {
+  const unsigned char *rip= RI_PIXEL(ri,x,y);
+  return (rip[0] << 16) |
+         (rip[1] <<  8) |
+         (rip[2]      );
+}
+
 /*----- from structure.c -----*/
 
 void find_structure(const CanonImage *im, int *max_relevant_y_r);
 /*----- from structure.c -----*/
 
 void find_structure(const CanonImage *im, int *max_relevant_y_r);
index f3fbb72ed2d157ea01a3b103e2d2854544bb2f85..beadfed469a9476644ce4673d9b6cfa68e2fbf7f 100644 (file)
@@ -34,7 +34,7 @@
 
 
 typedef struct {
 
 
 typedef struct {
-  unsigned long rgb; /* on screen */
+  Rgb rgb; /* on screen */
   char c; /* canonical */
 } CanonColourInfo;
 
   char c; /* canonical */
 } CanonColourInfo;
 
@@ -45,7 +45,7 @@ CanonImage *alloc_canon_image(int w, int h);
 #define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{            \
     /* compute_rgb should be a number of statements, or                \
      * a block, which assigns to                               \
 #define CANONICALISE_IMAGE(im,w,h, COMPUTE_RGB) do{            \
     /* compute_rgb should be a number of statements, or                \
      * a block, which assigns to                               \
-     *   unsigned long rgb;                                    \
+     *   Rgb rgb;                                              \
      * given the values of                                     \
      *   int x,y;                                              \
      * all of which are anamorphic.  Result is stored in im.   \
      * given the values of                                     \
      *   int x,y;                                              \
      * all of which are anamorphic.  Result is stored in im.   \