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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to