• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: subclassing NSBitmapImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subclassing NSBitmapImageRep


  • Subject: Re: subclassing NSBitmapImageRep
  • From: Patrick Tepesch <email@hidden>
  • Date: Wed, 20 Feb 2002 21:17:55 -0500

I did find one way to do this, although I think there must be a more elegant solution:

+(void)load
{
printf("MyBitmapImageRep load!!!!\n");
[NSImageRep registerImageRepClass:[MyBitmapImageRep class]];
[NSImageRep unregisterImageRepClass:[NSBitmapImageRep class]];
}

This assures that MyBitmapImageRep will always be called, however it also means I have to check the type of file against the types I want to handle in all of the image loading functions. If anyone knows a better solution, I'd be really happy to find it!

Patrick Tepesch

On Wednesday, February 20, 2002, at 12:00 AM, Patrick Tepesch wrote:

I am trying to create a subclass of NSBitmapImageRep to handle reading 16-bit tiff files. To test this, I have overridden the following methods, and all the methods for creating reps:

+ (NSArray *)imageUnfilteredFileTypes {
static NSArray *types = nil;

printf("MyBitmapImageRep imageUnfilteredFileTypes!!!!\n");
if (!types) types = [[NSArray alloc]
initWithObjects:@"TIF", nil];
return types;
}

+(void)load
{
printf("MyBitmapImageRep load!!!!\n");
[NSImageRep registerImageRepClass:[MyBitmapImageRep class]];
}

Both printf statements execute in my code, and my code is called if I give it a new type rather than a type already handled by NSBitmapImageRep. But when the a .TIF image is loaded from NSImage it still calls NSBitmapImageRep methods, rather than the methods in my subclass, thus the load continues to fail.

Any suggestions on how to get my subclass methods called before the NSBitmapImageRep methods?

Thanks,

Patrick Tepesch
_______________________________________________
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.

References: 
 >subclassing NSBitmapImageRep (From: Patrick Tepesch <email@hidden>)

  • Prev by Date: Setting up an 'About' window
  • Next by Date: Re: Name for '#' glyph.
  • Previous by thread: subclassing NSBitmapImageRep
  • Next by thread: Editing defaults of other apps
  • Index(es):
    • Date
    • Thread