Hi All,
I'm having some issues with a pixel buffer I create via GWorlds and
DrawString() on Intel-based Mac.
I'm basically creating a GWorld with the k32RGBAPixelFormat and writing
some text in the GWorld using DrawString(). I first make all the pixels
in the GWorld black and then draw my text using white. Since the font
is antialiased, I expect grayscale pixels in the buffer. This is the
case for PowerPC Macs, but not on Intel flavour.
What I see instead in pixel buffer memory after drawing the text is
pixel values like the following:
FF A9 A9 FF
On PowerPC, using k32ARGBPixelFormat, as expected I see:
FF A9 A9 A9
Here is the relevant (Intel) code I'm using. Note that rectTexture,
pImageBuffer, rowStride and a few other variables are previously
declared and initialized.
GWorldPtr textWorld = NULL;
OSErr errQT = ::QTNewGWorldFromPtr(&textWorld, k32RGBAPixelFormat,
rectTexture, NULL, NULL, 0, pImageBuffer, rowStride);
if ((errQT == noErr) && outGworld)
{
// retrieve image pix map
PixMapHandle hPixMap = GetGWorldPixMap(textWorld);
PixMapPtr pixMapP = *hPixMap;
Rect bounds = pixMapP->bounds;
// now we have to render the text into this gworld:
::SetGWorld(textWorld, NULL);
::RGBForeColor(gRGBBlack);
::PaintRect(&bounds);
::TextFace(inMacStyle);
::TextSize(inFontSize);
short fontID = 1;
::GetFNum(inFontName, &fontID);
::TextFont(fontID);
::RGBForeColor(gRGBWhite);
::MoveTo(0, inAscent);
::DrawString(inString);
if (::LockPixels(hPixMap))
{
char* pixelBuffer = ::GetPixBaseAddr(hPixMap);
...
...
}
...
...
}
If I inspect the memory pointed to by pixelBuffer, I should find mostly
black pixels with the odd grayscale pixels corresponding to the string
I've drawn. I've requested 32-bit RGBA pixel format so I would expect
the following memory for a black pixel:
00 00 00 FF
What I find instead is:
FF 00 00 00
I realize there is an oddity in the XCode debugger memory display where
unless you specify a word size of 1, the order of the bytes is
reversed. I'm taking this into account. The first byte is definitely
FF.
What's more confusing is that the grayscale pixels I find do not look
like:
FF A9 A9 A9
but instead are like:
FF A9 A9 FF
I'm really confused. Can anyone shed any light on what might be
happening?
Best regards,
Clint Weisbrod.
Eric Albert - 17 Nov 2005 18:29 GMT
> I'm having some issues with a pixel buffer I create via GWorlds and
> DrawString() on Intel-based Mac.
[quoted text clipped - 13 lines]
>
> FF A9 A9 A9
Please file a bug report at <http://bugreport.apple.com/> and include
both what you said here and a copy of your application built as a
universal binary.
Thanks,
Eric

Signature
Eric Albert ejalbert@cs.stanford.edu
http://outofcheese.org/