Detecting image depth/type display error from display.newImage()

I just had a bug reported against my code, wherein an image pulled from a remote server displayed incorrectly. Turns out the image was an 8-bit grayscale png. (ergo the display issue)

I’m checking for nil returned from display.newImage(), but it’s returning a non nil value, even though the image is unsupported.

Question: How should I be detecting an invalid source image display result?

Thanks!

Corona simulator error: " : CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component color space; kCGImageAlphaPremultipliedFirst; 256 bytes/row."
(Apologies if this already is answered in the forums; couldn’t find it addressed from searches.)

[import]uid: 5670 topic_id: 21889 reply_id: 321889[/import]

you will need to open the image in binary form and figure out where the header of the PNG that starts with IHDR is so you can get the width, height, and bit depth.

if you can find the bit-depth right then and there and is 8,16,24, then reject the file. meaning, don’t open it via display.newImage. or for better UI display an image that says "image type not supported’ or something like that.

google png headers, it starts off with a byte, followed by PGN followed by IHDR.

C. [import]uid: 24 topic_id: 21889 reply_id: 87137[/import]