How to correctly use syncPixels
Posted: 2008-11-28T13:36:19-07:00
I am having trouble getting syncPixels to work. Here is my simple example:
My problem is that tR = tG = tB = 0 when in fact they should (if I understand correctly) contain the RGB values of the first pixel contained in chData. What am I doing wrong?
Note, the data pointed to by iPtr1 contains the correct values, I just can't get these values "copied" back to the variable image1.
Code: Select all
//Create empty image
Image image1 = Image(Geometry(w,h),Color(0,0,0));//w and h contain the width and height of the image stored in chData
PixelPacket *iPtr1 = image1.setPixels(0,0,image1.columns(), image1.rows());
image1.readPixels(RGBQuantum, chData); //unsigned char *chData containing image data
image1.syncPixels();
Color clrTemp = image1.pixelColor(0,0);
Quantum tR,tG,tB;
tR = clrTemp.redQuantum();
tG = clrTemp.greenQuantum();
tB = clrTemp.blueQuantum();
Note, the data pointed to by iPtr1 contains the correct values, I just can't get these values "copied" back to the variable image1.