Re: [GD-DEVEL] Problem using gdImageGetPixel()

[email protected] (Takeshi Abe) Thu, 18 Dec 2008 20:49:28 +0900 (JST)
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hi,

On Thu, 18 Dec 2008 10:41:29 +0100, Yorn <[email protected]> wrote:
> I tried the example code from the web-page, which also does not work:
>
> ----------- snipp ------------
> #include <stdio.h>
> #include <gd.h>
> 
> int main()
> {
>     FILE *in;
>     gdImagePtr im;
>     int c;
>     in = fopen("pic1.jpg", "rb");
>     im = gdImageCreateFromJpeg(in);
>     fclose(in);
>     c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);
>     printf("The value of the center pixel is %d", c);
> //    int red = im->red[c];
> //    int green = im->green[c];
> //    int blue = im->blue[c];
> 
> //    printf(" RGB values are %d %d %d\n", red, green, blue);
>     gdImageDestroy(im);
>     return(0);
> }
> 
> ---------- snipp ------------

The example seems to lead to misunderstanding. In fact gdImage's members 
'red', 'green', 'blue' etc. are considered private. The sentence leading 
the example are more helpful:
  you can use gdImageRed or gdTrueColorGetRed
 (be careful with this function, use it only with true color images).

Cheers,
-- Takeshi Abe