Perhaps again? Pixel bug in Mac OS X

Greetings!

I, too, have been plagued by mysterious pixel data mismatches, using color keying with PNG files (alpha channeled) in SDL2, and am very happy to report that building SDL2_image with SDL_IMAGE_USE_COMMON_BACKEND resolved my issue entirely. All I had to do was to include homebrew’s libpng, libtiff & libjpeg dynamic libraries & header files in the Xcode project along with adding “-DSDL_IMAGE_USE_COMMON_BACKEND” to “Other C flags”. (I built both SDL2 and SDL2_image as a Framework bundle).

My testing results:

ImageIO
uint32 colorkey: 1854914047
RGBA colorkey: 110, 143, 189, 255

libpng (SDL_IMAGE_USE_COMMON_BACKEND with linking to homebrew’s libpng, libtiff & libjpeg):
uint32 colorkey: 1854979839
RGBA colorkey: 110, 144, 190, 255

Note that if you are redistributing SDL2_image.framework with your own library’s framework bundle (such as is my case!), you will need to package the libraries within SDL2_image along with install_name_tool patching those extra libraries yourself in order for SDL2_image to find 'em on an end-user’s system without homebrew & co installed.

I would love to see this issue resolved upstream somehow. Did SDL1 not use ImageIO backend? Perhaps that SDL2 maintainers chose to move to ImageIO in hopes of simplifying distribution?

Cheers,
Jeffrey CarpenterOn 2014/02/ 24, at 15:13, Gregory Smith wrote:

On Mon, 24 Feb 2014, Forest Hale wrote:

I’m in the latter camp, so I’m quite put off by the idea that ImageIO can muck with game textures that I load, and this forces me to use a different image library than SDL_image to load those images because platform-dependent behavior on game textures is completely undesirable, especially in game engines with linear lighting (where the texture is being explicitly decoded as sRGB by the GPU - this is a specific color profile and all assets need to match that color profile, regardless of operating system).

There is also unavoidable loss reversing the alpha premultiplication ImageIO does. This affected our use of the alpha channel in PNGs to store the height map for parallax mapping. In the end, it was important to us to be able to load the actual data stored in the image file! This seems like fairly common sense functionality to me ::shrug::

There’s an SDL_IMAGE_USE_COMMON_BACKEND preprocessor definition that can be used when compiling SDL_Image 1.x, which disables the ImageIO stuff and goes back to libpng etc. We haven’t moved to SDL2 yet so I don’t know if it’s still in there. If it isn’t, we’ll have to move to a different image library too.

Gregory


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Jeffrey Carpenter