NSImage not using NSImageRep when drawing to NSPSAndPDFGraphicsContext
NSImage not using NSImageRep when drawing to NSPSAndPDFGraphicsContext
- Subject: NSImage not using NSImageRep when drawing to NSPSAndPDFGraphicsContext
- From: Brock Brandenberg <email@hidden>
- Date: Sat, 22 Mar 2003 12:07:05 -0600
Why is it that NSImage doesn't call upon its ONLY representation to draw
itself to a NSPSAndPDFGraphicsContext if it isn't an Apple-native NSImageRep
subclass? It calls the rep subclass once to establish an image cache (not an
NSCachedImageRep) even though the data is retained and image caching is set
to "never", but it will never call the subclass rep again to draw. Ever. The
NSImage is created empty, caching is explicitly set to never, data is set to
retained, and the rep is added as the only rep. And at any time, the rep
remains the sole rep visible in the representations array.
This happens for a custom EPS subclass and you can make it happen with an
NSPDFImageRep by making a subclass of it without any overridden methods. The
EPS subclass is implementing all of the necessary methods, returning proper
bits per sample, color space name, unfiltered image types, etc. To make it
work, I have to explicitly switch on the context type to draw the rep
directly instead of relying on NSImage to choose for me. Because I can
subclass NSPDFImageRep and break the behavior, it makes me suspicious that
there is something inside NSImage looking at the isMemberOfClass: to
determine when to use a cached image. It's almost as though NSImage doesn't
know the rep can support anything other than source copy modes and feels it
needs to always draw from a cache so that it can support other compositing
modes.
I think that I have seen every page of NeXT, Sun, GNU and Apple doc dealing
with NSImage and NSImageReps, including all of the AppKit release notes, and
I have not found the smoking gun that points to the behavior or problem. The
closest that I can find it to the effect of "NSImage will do everything in
its power to use a rep before resorting to using a cached image." I'm about
to throw up my hands with NSImage and switch to CoreGraphics for everything
because it's more predictable.
Can any framework engineers elaborate more on this undocumented NSImage
behavior?
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
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.