Using image masks in juce


#1

Hi all,

I’ve been trying to convert a legacy software project to Juce. Most of the UI elements in this project – dials, buttons and so on – are just images showing the UI element in different states and/or values. The images are all rectangular, but rather than having a non-transparent part and a transparent part for circular UI elements, they have an accompanying image mask to indicate which part of the image should be painted; in the image mask black indicated that a pixel should be painted while white indicates that it shouldn’t be painted. I could cycle through each image’s pixels when loading it to create a transparent image from the source image and the image mask, but this isn’t terribly efficient. And I was wondering whether there is any built in functionality in Juce somewhere that I could use for this problem…

Thanks.
Greg


#2

just make sure your component has setOpaque (false) and draw as little or as much as you want!

Components can be non-rectangular by default unless you use setOpaque (true).