ImageFileFormat::loadFrom() when using CoreGraphics (Mac) returns different data


#1

Hi.  On a Mac and seeing bad data come back from PNG files when using loadFrom().  I've moved on after finding a workaround for this (setting JUCE_USE_COREIMAGE_LOADER to 0) and haven't looked any further into why the code integrating with CoreGraphics behaves differently.

Seems just having the Juce library use libpng works just fine.  Not sure why CoreGraphics is even an option?  Maybe it's faster?  Either way - wasn't working for me. 

Here is the output from my function getting colors from a PNG file.  The file is small (4x32) and only contains *some* RED pixels - that's it.  So each pixel is either 0,0,0, or 255,0,0

(Not defined - use libpng)

JUCE_USE_COREIMAGE_LOADER 0

color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0

 

Same function call but using CoreGraphics code on a Mac.

(Defined - use CoreGraphics.  Where are these 38's coming from?)

JUCE_USE_COREIMAGE_LOADER 1

color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 255 38 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0
color is 0 0 0

I'll attach the image when I get back to my Mac.


#2

Maybe something related to a color profile/gamma embedded in your PNG file.

Like CoreGraphics applying it directly while libpng don't

 

http://www.w3.org/TR/PNG/#4Concepts.ColourSpaces

https://hsivonen.fi/png-gamma/

 

Long story short, It's a mess !


#3

Very interesting - I wasn't aware this file format was such a mess! 

I'll read up on those links and stick with libpng right now since it's giving me what I expect.  Thanks!  :)