iPhone: Changing CGImageAlphaInfo of CGImage

Posted by TechZen on Stack Overflow See other posts from Stack Overflow or by TechZen
Published on 2010-03-16T18:37:50Z Indexed on 2010/03/16 18:41 UTC
Read the original article Hit count: 503

I have a PNG image that has an unsupported bitmap graphics context pixel format. Whenever I attempt to resize the image, CGBitmapContextCreate() chokes on the unsupported format

(Error formatted for easy reading):

CGBitmapContextCreate: unsupported parameter combination: 
    8 integer bits/component; 
    32 bits/pixel; 
    3-component colorspace; 
    kCGImageAlphaLast; 
    1344 bytes/row.

The list of supported pixel formats definitely does not support this combination. It appears I need to redraw the image and move the alpha channel information to kCGImageAlphaPremultipliedFirst or kCGImageAlphaPremultipliedLast.

I have no idea how to go about doing this.

There is nothing unusual about the PNG file and it isn't corrupted. It works in all other context just fine. I encountered this error just by chance but obviously my users might have similarly formatted files so I will have to check my app's imported images and correct for this problem.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cgimage