Subclassing NSImageRep for preexisting types
Subclassing NSImageRep for preexisting types
- Subject: Subclassing NSImageRep for preexisting types
- From: David Remahl <email@hidden>
- Date: Wed, 13 Mar 2002 19:42:48 +0100
My app needs to be able to load XP icons. They have the same .ico extension
as classic Win icons, but the Apple provided image handling code for these
only load the 32x32 representation, not the high-fidelity 48x48 one, though
supported by the format.
So, what I intended to do was to create an NSBitmapImageRep subclass that
would load all representations stored in an ICO.
Something like this (I'm just assuming I can use the NSData - that is not
the point yet):
@implementation DRXPIconImageRep
+ (void)load {
[NSImageRep registerImageRepClass:self];
[super load];
NSLog([[NSImage imageUnfilteredFileTypes] description]);
}
+ (NSArray*)imageUnfilteredFileTypes { return [NSArray
arrayWithObject:@"ico"];
}
- (BOOL)canInitWithData:(NSData *)data { return YES; }
- (id)initWithData:(NSData*)inData {
NSLog(@"%i",[inData length]); //just to verify we get called - we don't
return NULL;
}
@end
The problem is that even though my load method is called and I inform the
repository that I can load ico's, the system provided method takes
precedence. Is there anything I can do about this, short of posing?
/ david
_______________________________________________
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.