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

From: Date: Thu, 18 Dec 2008 11:49:28 +0000
Subject: Re: [GD-DEVEL] Problem using gdImageGetPixel()
References: 1  Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-523@lists.php.net to get a copy of this message
Hi, On Thu, 18 Dec 2008 10:41:29 +0100, Yorn <yorn@gmx.net> 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

« previous php.gd.devel (#523) next »