Skip navigation.
 
mlRe: NSImage and 8 bit
FROM : Marcel Weiher
DATE : Mon Nov 29 21:13:25 2004

On 25 Nov 2004, at 14:29, Robert W. Kuhn wrote:



> can NSImage not handle grayscale (8 bit) images?


Try using NSBitmapImageRep directly, the code you are using may or may
not do what you're thinking.

>
> 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;
> }


This is probably a cached representation, so you are getting the depth
of the bitmap cache.  The last time I checked NSImage discards the
original data unless you tell it to -setDataRetained:YES.

And it seems that the cached representations are "kinds of"
NSBitmapImageRep these days.

Marcel





--
Marcel Weiher                Metaobject Software Technologies
<email_removed>        www.metaobject.com
Metaprogramming for the Graphic Arts.  HOM, IDEAs, MetaAd etc.
        1d480c25f397c4786386135f8e8938e4

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