Change Picture Color

Is there an easy way to change the color of a picture? For example, let’s say I have a black and white PNG icon that I want to display in various user chosen colors.

My guess is the best way is to turn the PNG into a mask . It becomes a white square with a mask the shape of the icon in the middle. Then draw a coloured picture and overlay the white PNG with the icon shaped hole in the middle.

I can confirm that making an image drawn white with the icon drawn transparent inside works fine. Then just change the background color.

Here’s a quickie demo.