bad behavior from unlockFocus on 10.6
bad behavior from unlockFocus on 10.6
- Subject: bad behavior from unlockFocus on 10.6
- From: Robert Clair <email@hidden>
- Date: Thu, 3 Sep 2009 09:50:32 -0400
I have this piece of code in my drawing program:
[image lockFocus];
NSBitmapImageRep* bitmapRep =
[[NSBitmapImageRep alloc] initWithFocusedViewRect:
NSMakeRect( 0.0, 0.0, width, height) ];
[image unlockFocus];
image is an NSImage with a single representation, either an
NSBitmapImageRep containing a high resolution bitmap or an
NSPDFImageRep. The pixels from the bitmapRep created here are
thresholded and used to make a low resolution mask that is held
separately for use in picking.
This all worked fine until 10.6. The original NSImage object was left
unmolested. But now when this code is executed, -unlockFocus replaces
the original representation held by the NSImage object with an
NSCGImageSnapshotRep. There is no documentation that I can find on a
NSCGImageSnapshotRep, but it's a bitmap. (I assume it's a screen res
bitmap object backed by a CGImage). This causes data loss with the
program. If, for example, a user opens a file with a pdf object in it
to continue working on it , and then saves the file, all the vector
information is lost in any pdf objects is lost.
I understand that a pdf has to be rasterized for this to work. But
since I didn't draw anything on the NSImage, I really expect this code
to discard the temporary rasterized version when it is done and leave
my original object unchanged.
The quick fix is easy, just save the original representation and then
restore it. But, is this a bug or is there some point to this?
Bob Clair
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden