From cec9583fe97a74a44625e63cfa22318db2699ee4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 4 Jul 2009 01:23:53 +0100 Subject: [PATCH] New inline function ri_rgb; introduce typedef for rgb sample --- pctb/convert.h | 9 +++++++++ pctb/structure.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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. \ -- 2.30.2