chiark / gitweb /
New inline function ri_rgb; introduce typedef for rgb sample
[ypp-sc-tools.db-test.git] / pctb / convert.h
index 83be1e8bced1ab8fce05d7233588595792f74530..b61563fd32449c200b6915484b4fcc9a3d3c7a33 100644 (file)
@@ -51,6 +51,8 @@ typedef struct 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);
@@ -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)
 
+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);