Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CopyBits/QDFlush error



On Wednesday, September 4, 2002, at 03:29 PM, Bob Sabiston wrote:

I have been having a persistent problem with discrepancies between Quickdraw coordinates and direct-to-buffer coordinates. Does Quickdraw's origin start at 1,1 instead of 0,0 or something? To demonstrate the problem I wrote the following test code:

LockPortBits(ePort);
AAdestAddr = (unsigned char *)GetPixBaseAddr(GetPortPixMap(ePort));
AAdest_rowbytes = (unsigned long)GetPixRowBytes(GetPortPixMap(ePort));
UnlockPortBits(ePort);

// draw a small rectangle between 10,10 and 19,19
for (short y = 10; y < 20; y++) {
AAdestRowStart = (unsigned long *)(AAdestAddr + y*AAdest_rowbytes);
for (short x = 10; x < 20; x++)
*(AAdestRowStart+x) = 0xff000000; // draw a black square
}

// first just flush the whole buffer, to check
if (QDIsPortBuffered(ePort)) {
RgnHandle theRgn;
theRgn = NewRgn();
RectRgn(theRgn, &backRect);
QDSetDirtyRegion(ePort,theRgn);
QDFlushPortBuffer(ePort, theRgn);
DisposeRgn(theRgn);
}

// wait until user presses command key
while (!CheckKey(COMMAND_KEY));

for (short y = 10; y < 20; y++) {
AAdestRowStart = (unsigned long *)(AAdestAddr + y*AAdest_rowbytes);
for (short x = 10; x < 20; x++)
*(AAdestRowStart+x) = 0xffffffff; // now draw with white
}

Thanks very much to anyone who can answer this. It has been driving me crazy.

The only thing I noticed in particular was that you were unlocking the GWorld's PixMap just after getting its base address and rowBytes. You're allocating a dirty region in between the two drawing operations. Is it possible that the buffer has moved? Try moving the UnlockPortBits call to the end. Does that change anything?

steve
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.