Skip navigation.
 
mlNSImage and 8 bit
FROM : Robert W. Kuhn
DATE : Thu Nov 25 15:29:47 2004

Hello,

can NSImage not handle grayscale (8 bit) images?

ti-pcl2:~/Programmierung/Disparity rkuhn$ file A_000_000.bmp
A_000_000.bmp: PC bitmap data, Windows 3.x format, 1280 x 1020 x 8


But:

mLeftImg  = [[NSImage alloc]
                      initWithContentsOfFile:@"A_000_000.bmp"];
NSLog(@"BPP: %i", [mLeftImg bitsPerPixel]); 

gives in the Log:

2004-11-25 15:29:03.447 Disparity[6999] BPP: 32


This is bitsPerPixel:

-(int)bitsPerPixel
{
   return [[self bitmapImageRep] bitsPerPixel];
}


with

-(NSBitmapImageRep*)bitmapImageRep
{
    NSArray *reps=[self representations];
    NSEnumerator *enumerator = [reps objectEnumerator];
    id obj;
    NSBitmapImageRep *bir=nil;
   
    // cycle through the image reps until we find a suitable one
    while ((obj = [enumerator nextObject])) {
   bir=nil;
   if([obj isKindOfClass: [NSBitmapImageRep class]]) {
         bir=(NSBitmapImageRep *)obj;
         break;
   }
    }
   
    return bir;
}

Mit freundlichen Grüßen
Robert W. Kuhn

Related mailsAuthorDate
mlNSImage and 8 bit Robert W. Kuhn Nov 25, 15:29
mlRe: NSImage and 8 bit Marcel Weiher Nov 29, 21:13
mlRe: NSImage and 8 bit Robert W. Kuhn Nov 30, 09:26
mlRe: NSImage and 8 bit Marcel Weiher Nov 30, 11:56