« on: November 02, 2016, 05:17:42 PM »
I have been using png files for raster etching operation on my Linux application that utilizes the GTK toolkit. When reading the png file I get the number of channels (3 or 4) that represent the R,G,G,A data channels.
I was converting the RGB into gray scale by averaging the 3 color channels. Then I imported a png that was created in grayscale only where RGB are all zero and the intensity is in the A channel.
Note: If there are only 3 channels then it must be RGB.
Both are fine except I don't know how to determine which one is really there. So far I scan the A channels looking to see it they are all 0xFF. If so then calculate the grey from RGB. Or I can scan all the RGB channels for all 0xFF or 0x00 and use the A channel. Problem is what if there is info in both RGB & A or is that an invalid condition?
An acceptable alternative would be a utility that rewrites the file as grayscale only.