--- leptonlib-1.51.orig/src/pix2.c 2007-10-25 06:41:17.000000000 +0400 +++ leptonlib-1.51/src/pix2.c 2007-11-19 12:21:31.000000000 +0300 @@ -1213,6 +1213,57 @@ return 0; } +/*! + * pixGetRGBPixel() + * + * Input: pixs (32 bpp) + * (x,y) pixel coords + * &red (red sample) + * &green (green sample) + * &blue (blue sample) + * Return: 0 if OK; 1 on error + * + * Notes: + * (1) This puts RGB sample values of the specified pixel into the given buffers. + */ +l_int32 +pixGetRGBPixel(PIX *pixs, + l_int32 x, + l_int32 y, + l_uint8 *red, + l_uint8 *green, + l_uint8 *blue) +{ +l_uint32 *line, *data; +l_int32 j, w, h; +l_int32 wpl; + + PROCNAME("pixGetRGBPixel"); + + if (!pixs) + return ERROR_INT("pixs not defined", procName, 1); + if (pixGetDepth(pixs) != 32) + return ERROR_INT("pixs not 32 bpp", procName, 1); + if (!red || !green || !blue) + return ERROR_INT("buffer not defined", procName, 1); + + pixGetDimensions(pixs, &w, &h, NULL); + if (x < 0 || x >= w) + return ERROR_INT("x out of bounds", procName, 1); + if (y < 0 || y >= h) + return ERROR_INT("y out of bounds", procName, 1); + + wpl = pixGetWpl(pixs); + data = pixGetData(pixs); + line = data + y * wpl; + + *red = GET_DATA_BYTE(line, COLOR_RED); + *green = GET_DATA_BYTE(line, COLOR_GREEN); + *blue = GET_DATA_BYTE(line, COLOR_BLUE); + + return 0; +} + /*-------------------------------------------------------------* * Pixel endian conversion * --- leptonlib-1.51.orig/src/leptprotos.h 2007-10-25 06:41:52.000000000 +0400 +++ leptonlib-1.51/src/leptprotos.h 2007-11-19 12:20:43.000000000 +0300 @@ -650,6 +650,7 @@ extern l_int32 pixSetData ( PIX *pix, l_uint32 *data ); extern l_int32 pixPrintStreamInfo ( FILE *fp, PIX *pix, const char *text ); extern l_int32 pixGetPixel ( PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval ); +extern l_int32 pixGetRGBPixel ( PIX *pix, l_int32 x, l_int32 y, l_uint8 *red, l_uint8 *green, l_uint8 *blue); extern l_int32 pixSetPixel ( PIX *pix, l_int32 x, l_int32 y, l_uint32 val ); extern l_int32 pixClearPixel ( PIX *pix, l_int32 x, l_int32 y ); extern l_int32 pixFlipPixel ( PIX *pix, l_int32 x, l_int32 y );