I have a set of images that consist of a single channel of transparency information, with no colour (i.e. grayscale images). I want to draw the image to the screen using a particular color, where each grayscale pixel in the image is used as a transparency value to transfer the desired colour (which can itself have transparency).
At first I didn’t see the fillAlphaChannelWithCurrentBrush parameter to Graphics::drawImage. But then I saw it and realized it was exactly what I needed.
So, I load my Image using the PNG loader. In Photoshop, my PNG is an 8-bit grayscale image. But when I load it up using ImageFileFormat::loadFrom(), it comes out as RGB. This seems to be happening in juce_PNGLoader.cpp:
if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb (pngReadStruct);
This seems very unfriendly! I want my PNG to stay as Image::PixelFormatType::SingleChannel (I speak Juce now).
And, I want Graphics::drawImage() to treat this as the alpha channel when I pass fillAlphaChannelWithCurrentBrush=true