Offscreen and palette

Offscreen and palette

Post by jean-jacqu » Wed, 04 Aug 2004 09:42:36


Hi, first time user of this forum.

here my problem: I want to know the exact value of an RGB color of a pixel;

first, I read a palette in the resource fork:

aPalette = GetNewPalette(noPalette);
nbColors = (* aPalette)->pmEntries;
for (i = 0; i <= nbColors; i++)
theColorsRGB[i] = (* aPalette)->pmInfo[i].ciRGB;


then, I open an offScreen port and set the pixels colors:

error = NewGWorld(&offScreenGWorld, 0, &imageRect, NULL, NULL, 0);
...
SetCPixel(h, v, & theColorsRGB[k]);
GetCPixel(h, v, &aColorRGB);
if (aColorRGB.red != theColorsRGB[k].red)
{
Alert("different");
}

I test the color and get a message telling me that the color is not the
one I gave to SetCPixel();

The colors are very similar but not identical.
I must say that there is no code between SetCPixel() and GetCPixel();

I have try
SetPalette((GrafPort *)offScreenGWorld, aPalette, false);
et
error = NewGWorld(&offScreenGWorld, 32, &imageRect, NULL, NULL, 0);
without success.

Is there somebody having an idea around here?
thank you
JJC
Montreal
 
 
 

Offscreen and palette

Post by Herb Petsc » Sat, 14 Aug 2004 15:58:16

In article < XXXX@XXXXX.COM >,



It has been a while since I've poked at this stuff so I could be wrong...

Since you've created a NewGWorld by specifying a zero pixel depth, no
colour table and no GDHandle you are probably going to get a GWorld of
some maximum depth of some device. You'll also get that device's colour
table. When you set the pixel some colour matching is probably
performed which would explain why the colour you get back is similar but
not exact.


I'd dig around up on http://www.yqcomputer.com/ . There was a wonderful
section on colour matching (etc.) in the old Inside Macs that explained
all this nicely. Either that or move over to Quartz :-)

Perhaps this has jogged someone else's memory. We used to make calls
like:

GetGWorld( &saveWorld, &orgGDH );

err = NewGWorld( &theGWorldP, 8, &bounds,
theCTableH, orgGDH, noNewDevice );

Good luck!

H.

--
To reply via email, replace "LastNameHere" with my last name.