how to determine NSImage type ?
how to determine NSImage type ?
- Subject: how to determine NSImage type ?
- From: Robert Miller <email@hidden>
- Date: Wed, 18 Jul 2001 16:37:36 -0400
- Organization: RFM & Associates
Hello,
Does anyone know how to determine the type of image data in an
NSImage ? For example, to check if an image is a GIF I'm looking at the
NSImageRep array returned from the 'representations' method and checking
the NSImageRep class for NSBitmapImageRep and then if it is I check its
color space to see if it is RGB. I've included the code snippet below.
However, in the documentation there are constants defined for FileType
such as NSJPEGFileType, NSPNGFileType, NSGIFFileType, etc. but no
mention of how / where these constants are used ? The question is what
is the correct way of checking a NSImage data type ?
NSArray *reps = [theNSImage representations];
unsigned index;
unsigned count = [reps count];
for (index = 0; index <count; index++) {
NSImageRep *irep = [reps objectAtIndex:index];
if ([irep isKindOfClass:[NSBitmapImageRep class]]) {
NSString *cspace = [irep colorSpaceName];
if ([cspace isEqualToString:NSCalibratedRGBColorSpace]) {
[imageFromFile release];
imageFromFile = nil;
break;
}
}
}
Thanks in advance for any help,
Regards,
Bob m.