Recommended color depth?

Does anyone know what the generally recommended color depth is for png images (both for IOS and Android)? I read somewhere that “color depth should not be more than 16 bit since most devices can not handle more”. Is that really true?

If so, is there a way to convert 16-bit png:s to 24 or 32 bit without actually re-drawing them?

Corona always renders to the GPU using 32-bit color.  So, for best image loading performance, your PNGs should be 32-bit color.  If they’re not 32-bit color, then you’re forcing Corona to convert it to 32-bit color when decoding the file, which will slow down the load time a bit.  Might only be by milliseconds, but if you’re loading a lot of images, then those precious milliseconds starting adding up.

For masks, you should save your PNGs as 8-bit grayscaled images for best performance.  If they’re not grayscaled, then you’re forcing Corona to convert it to an 8-bit grayscale image, which again is a bit of a performance hit.  Especially when converting 32-bit to 8-bit, which is pretty wasteful.

Regarding devices that can’t handle 32-bit color, that used to be true of older Android devices.  But those days are long over (thankfully). I wouldn’t worry about it.

The only other benefit that I can think of to use a lower color PNG instead of 32-bit is in case you want to just-make-it under the 50 MB app size limit for Google Play.  But that said, we do support Google expansion files which allows you to bundle 2 GB of assets to a separate file, making this less of an issue.

Anyways, I hope this helps!

Thank you Joshua, that certainly clarified a lot!

I downloaded InspectPNG and it says “uint8 bit_depth = 16” for my images. I thought that this meant that the color depth of the image was 16-bit, but then I found that the definition of the IHDR chunk contained this: “bit depth is a single-byte integer giving the number of bits per sample or per palette index (not per pixel). Valid values are 1, 2, 4, 8, and 16”.

In other words, the maximum value is 16, which I assume (?) are the bits used for each channel, making the color depth of ny image 64-bit (4 x 16). Have I understood this correctly, and if so, how does my 64-bit png:s affect corona performance?

While we are at it, is it also true that “to prevent images from using too much texture memory, the image should be between 72 and 170 DPI.”? I read all this about a year ago and made a note of it in my project log, but I forgot to write down which website it was…

Thanks again, Joshua, I really appreciate your help!

I’m going to assume you need 8 bits per channel.  A 16 bit per channel or 32 bit per channel image will need to be converted to 8 bits before we can display it, much like Joshua explained above.  

Depending on your software you’re using to produce the images, PNG’s can either be 24 bit or 32 bit and be the same.  For instance, Photoshop doesn’t call it’s images 32 bit, but 24 bit (R+G+B at 8 bit each) but it does include the 4th Alpha channel which makes up the other 8 bits to bring the total to 32.

Rob

Hi Rob, thanks for your answer!

I’m using Photoshop and at the creation of an image you get to choose bit depth. I chose 16, which I thought meant the bit depth for the whole image but know I understand that it means depth per channel. In other words, I may want to see i I can convert the depth of my images to 8 bits per channel (i.e. 32-bit total)…

Do you have some input on the question regarding the recommended maximum resolution of 170 DPI?

Image->Mode->RGB Color

then

Image->Mode->8 bit

While Android throws around the term “dpi” it only matters if your outputting to something measured in inches such as printing.  Most digital displays are simply 2D arrays of pixels.   Consider a 300x300 pixel image.   At 300 dpi, it’s still a 300x300 image, but it would print at 1 inch by 1 inch.  At 30 dpi, it would print a 10 inch x 10 inch image, but still be 300x300 pixels.

Since Corona SDK for the most part is about a 2D grid of “points”, such as a 320x480 content area, a 300x300 pixel image at 300 dpi is still going to take up 300x300 points on the screen.  Inches doesn’t factor in.   You don’t think of your screen as 3 inches by 4 inches and think about drawing a 2 inch image on it.

Hope that helps!

Rob

Thanks!

Corona always renders to the GPU using 32-bit color.  So, for best image loading performance, your PNGs should be 32-bit color.  If they’re not 32-bit color, then you’re forcing Corona to convert it to 32-bit color when decoding the file, which will slow down the load time a bit.  Might only be by milliseconds, but if you’re loading a lot of images, then those precious milliseconds starting adding up.

For masks, you should save your PNGs as 8-bit grayscaled images for best performance.  If they’re not grayscaled, then you’re forcing Corona to convert it to an 8-bit grayscale image, which again is a bit of a performance hit.  Especially when converting 32-bit to 8-bit, which is pretty wasteful.

Regarding devices that can’t handle 32-bit color, that used to be true of older Android devices.  But those days are long over (thankfully). I wouldn’t worry about it.

The only other benefit that I can think of to use a lower color PNG instead of 32-bit is in case you want to just-make-it under the 50 MB app size limit for Google Play.  But that said, we do support Google expansion files which allows you to bundle 2 GB of assets to a separate file, making this less of an issue.

Anyways, I hope this helps!

Thank you Joshua, that certainly clarified a lot!

I downloaded InspectPNG and it says “uint8 bit_depth = 16” for my images. I thought that this meant that the color depth of the image was 16-bit, but then I found that the definition of the IHDR chunk contained this: “bit depth is a single-byte integer giving the number of bits per sample or per palette index (not per pixel). Valid values are 1, 2, 4, 8, and 16”.

In other words, the maximum value is 16, which I assume (?) are the bits used for each channel, making the color depth of ny image 64-bit (4 x 16). Have I understood this correctly, and if so, how does my 64-bit png:s affect corona performance?

While we are at it, is it also true that “to prevent images from using too much texture memory, the image should be between 72 and 170 DPI.”? I read all this about a year ago and made a note of it in my project log, but I forgot to write down which website it was…

Thanks again, Joshua, I really appreciate your help!

I’m going to assume you need 8 bits per channel.  A 16 bit per channel or 32 bit per channel image will need to be converted to 8 bits before we can display it, much like Joshua explained above.  

Depending on your software you’re using to produce the images, PNG’s can either be 24 bit or 32 bit and be the same.  For instance, Photoshop doesn’t call it’s images 32 bit, but 24 bit (R+G+B at 8 bit each) but it does include the 4th Alpha channel which makes up the other 8 bits to bring the total to 32.

Rob

Hi Rob, thanks for your answer!

I’m using Photoshop and at the creation of an image you get to choose bit depth. I chose 16, which I thought meant the bit depth for the whole image but know I understand that it means depth per channel. In other words, I may want to see i I can convert the depth of my images to 8 bits per channel (i.e. 32-bit total)…

Do you have some input on the question regarding the recommended maximum resolution of 170 DPI?

Image->Mode->RGB Color

then

Image->Mode->8 bit

While Android throws around the term “dpi” it only matters if your outputting to something measured in inches such as printing.  Most digital displays are simply 2D arrays of pixels.   Consider a 300x300 pixel image.   At 300 dpi, it’s still a 300x300 image, but it would print at 1 inch by 1 inch.  At 30 dpi, it would print a 10 inch x 10 inch image, but still be 300x300 pixels.

Since Corona SDK for the most part is about a 2D grid of “points”, such as a 320x480 content area, a 300x300 pixel image at 300 dpi is still going to take up 300x300 points on the screen.  Inches doesn’t factor in.   You don’t think of your screen as 3 inches by 4 inches and think about drawing a 2 inch image on it.

Hope that helps!

Rob

Thanks!