From: Ian Jackson Date: Sat, 4 Jul 2009 00:23:53 +0000 (+0100) Subject: New inline function ri_rgb; introduce typedef for rgb sample X-Git-Tag: 1.9.2~49 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=cec9583fe97a74a44625e63cfa22318db2699ee4;hp=9334b48a221df6f96a88933be8fde35e2ef41b35 New inline function ri_rgb; introduce typedef for rgb sample --- diff --git a/pctb/convert.h b/pctb/convert.h index 83be1e8..b61563f 100644 --- a/pctb/convert.h +++ b/pctb/convert.h @@ -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); diff --git a/pctb/structure.h b/pctb/structure.h index f3fbb72..beadfed 100644 --- a/pctb/structure.h +++ b/pctb/structure.h @@ -34,7 +34,7 @@ typedef struct { - unsigned long rgb; /* on screen */ + Rgb rgb; /* on screen */ 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 \ - * unsigned long rgb; \ + * Rgb rgb; \ * given the values of \ * int x,y; \ * all of which are anamorphic. Result is stored in im. \