Re: NSBitmapImageRep subclass problem
Re: NSBitmapImageRep subclass problem
- Subject: Re: NSBitmapImageRep subclass problem
- From: Alan Hart <email@hidden>
- Date: Sun, 9 Apr 2006 01:32:15 +0100
On 8 Apr 2006, at 23:58, Daniel Vollmer wrote:
On 07.04.2006, at 20:03, Alan Hart wrote:
However, I'd really prefer to do it using a PCXImageRep class,
defined and registered as a subclass of NSBitMapImageRep, since it
seems that's the way the Cocoa image architecture ought to work.
Then it would be available to read a .pcx file anywhere in my app,
and it would be more reusable elsewhere.
I am not quite sure what the preferred way would be. For example
PNG, JPG, and most other bitmap types all return an
NSBitmapImageRep. So wouldn't the "proper" way to implement PCX
loading be a filter service (see for example the IFF sample code)?
Thanks. I've looked at filter services, and I think I can see how it
may be relevant, but it seems over-kill if everything has to go via
pasteboard types within my own app. And installation appears to
involve a logout/login, just to register the service. However, I
might give it some more thought, as I may have spoken too soon on my
subclass:
It appears to be working OK if I call it from -(NSImage*)
initWithData: but -(NSImage*)initWithContentsOfFile: doesn't play. I
can obviously read the date from the file myself and then use -
initWithData:, and that's working now. But it must be polling around
all the NSImageRep subclasses to find those that canInitWithData:, as
it has no way of knowing what file type I extracted it from. That
can't be efficient, specially if other subclasses aren't effective at
saying NO. -initWithContentsOfFile: ought to be more efficient as it
can use imageRepClassForFileType to identify my registered subclass
immediately. Regardless of the efficiency issue, the fact that this
method doesn't work makes me nervous, as it means I'm missing
something. Darned if I know what, though. :-/
I can't find the IFF sample code. Any links?
Alan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden