| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
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.
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.