NSBitmapImageRep bitmapData full of 0 on HEIF RGB 10bits per component

Hi,

I got a bitmapData full of zeros after creating a NSImage with initWithContentsOfURL on a HEIF RGB image with 10 bits per component (bitsPerPixel is 40). The image is correctly displayed by the Finder and Preview.

If I convert the bitmap representation with:

CGImageRef cgImage = imageRep.CGImage;
CGDataProviderRef provider = CGImageGetDataProvider(cgImage);
CFDataRef data = CGDataProviderCopyData(provider);

... the subsequent CFData contains non-zero bytes.

The call to CGDataProviderCopyData is not free and takes some time, as if there is some kind of unpacking process.

I do not have such a null content with any other kind of image.

Is there something I forgot before calling bitmapData?

Thanks.

And finally, it seems that

CGImageRef cgImage = imageRep.CGImage;

destroys the original representation, as CGImageGetBitsPerComponent(cgImage) returns 8 (initially 10) and CGImageGetBitsPerPixel(cgImage) 32 (initially 40).

And a direct construction of the CGImage via:

CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)url, nil);
CGImageRef image = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);

contains 8bits components too...

NSBitmapImageRep bitmapData full of 0 on HEIF RGB 10bits per component
 
 
Q