Native (OSX) RGB Image Clearing

If I create a new Image with a RGB pixel format and a NativeImageType and specify clearImage to true the image no longer gets cleared to black, rather a transparent colour. I think this happened with the Image re-write a couple of months ago.

Its not a huge problem as I can manually clear the image but it does seem odd that an RGB image can be transparent and the behaviour is now not as stated in the docs. SoftwareImageType clears to black as expected.

If the meaning of “NativeImageType” is now RGB with Alpha, then starting with a transparent image makes perfect sense.

In fact, I think the whole concept of “clearing” an image makes no sense unless the image has a transparency mask. After all, why black? Why not white? Or pink? If you are creating an image without an alpha mask and drawing into it, then you should be responsible for drawing every pixel. If the image has an alpha mask, then it makes sense to start it out as transparent.

Yes, but I don’t think thats what NativeImageType means, I ‘think’, correct me if I’m wrong, that the Native part means that is uses CoreImage on OSX, DirectSomethingOrOther on Windows instead of the Juce software image loader.

I would have thought that RGB explicitly states that the image doesn’t have an alpha channel (as opposed to ARGB which is another PixelFormat). In this instance I guess clearing means ‘reset to a blank state’ which just so happens to be black as stated by the docs (probably because that is the lowest value R:0, G:0, B:0).

I think the main point here is that Image now has slightly inconsistent behaviour depending on the ImageType you use (haven’t tried it on Windows yet). I don’t mind it starting off clear but the docs should reflect this and probably state that if you use a NativeImageType it will have an alpha channel (if OSX doesn’t do plain RGB).

You’re right that the behaviour is slightly inconsistent on OSX because there was some kind of problem (I forget what…) that meant it was impossible to use a “native” RGB image, so it has to be stored as ARGB internally, which is why it’s ending up transparent. I should add a note to the comments that explains this better.

…but, I also agree with Vinnie that clearing an RGB image is probably the wrong approach. Better to ask for a non-cleared image, and then to explicitly clear it yourself, specifying the background colour that you want, even if that happens to be black.

Jules I think clearImage == true should use pink instead of black for images without alpha channels.