Premultiplication problem on iOS using SDL_Image

I’m having trouble getting unmodified RGBA data from a png image through to my OpenGl texture using SDL_Image on iOS. Same stuff works fine on android. First problem was that XCode does premultiplication when packaging png images by default. I already disabled that.

Seems that at some stage when loading the png image, iOS does premultiplication anyway and SDL_Image does the inverse to get the original RGB values. The problem with this is that on parts where my alpha channel is zero or near to zero I’m losing all my color information. Or at least that’s what I think is happening by glancing the code @ IMG_ImageIO.m

I want to use the RGB data for color as it is, and alpha for other stuff in the shader. The texture is used in a fragment shader that my program uses a lot, so I’d like to avoid making the alpha channel a separate image (and adding another texture lookup). Could be that it doesn’t really affect perf that much, but I still think this should be fixed if possible.

Any ideas?

Hi there,

Ow, your problem sounds a lot awfully like a known issue, see "Perhaps again? Pixel bug in Mac OS X? at https://forums.libsdl.org/viewtopic.php?t=10013&sid=34e8ef7cf74074039495037c1a077025 https://forums.libsdl.org/viewtopic.php?t=10013&sid=34e8ef7cf74074039495037c1a077025 for the ugly details ? applies to iOS, too, AFAIK. Try the workaround that is mentioned in the thread to help confirm if this is indeed the same issue.

If it turns out that it is the same issue, you might consider doing what I have, and rebuild SDL_image with the libpng & friends backends instead.

Cheers,
Jeffrey Carpenter <@Jeffrey_Carpenter>

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1572 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20141119/46c5546f/attachment.bin

Hello,

Have you figured out the problem yet? I?m curious if the issue turned out to be related to the problem I mentioned. If it was, a patch I wrote concerning the issue might be of interest to you ? https://bugzilla.libsdl.org/show_bug.cgi?id=2788 https://bugzilla.libsdl.org/show_bug.cgi?id=2788

I?d love to know if it resolves your problem …

Cheers,
Jeffrey Carpenter <@Jeffrey_Carpenter>

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1572 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20141127/59bd49df/attachment.bin