"Smudged" double-buffering
"Smudged" double-buffering
- Subject: "Smudged" double-buffering
- From: Glen Low <email@hidden>
- Date: Sun, 4 Apr 2004 13:10:39 +0800
Hi All,
I have some NSView drawRect that does this, more or less:
NSImage* image = [[NSImage alloc] initWithSize:[self frame].size];
[image lockFocus];
// draw draw draw
[image unlockFocus];
[image compositeToPoint: NSMakePoint (0, 0)
operation: NSCompositeCopy];
Effectively, this is a double-buffering scheme where I image first into
an NSImage, then draw the cached NSImage. (For efficiency's sake, I
don't exactly do the above, but the resulting bug is the same.)
The NSView has an enclosing scroll view and sometimes the above code
causes a slight smudge compared to the straightforward equivalent. If I
turn off image interpolation before doing the compositeToPoint:, the
smudge disappears but I get a glitch every scan line or so.
Thus my analysis is, the compositeToPoint is not drawing to the exact
device pixel, and thus it attempts to interpolate all of the cached
image.
Qn: how to I force compositeToPoint to do a 1-1 match of pixels and not
interpolate? (Turning off image interpolation won't work, and I tried
the sparely documented centerScanRect which looked promising but
doesn't seem to do anything.)
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
P.S. Note this isn't just a problem with explicitly double-buffered
drawing. Even drawing a NSPDFImageRep with a cached representation will
trigger this.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.