Erasing part of an Image - drawing a "clear" Rectangle


#1

I’m currently trying to draw stuff to a transparent image in JUCE. So I have an Image object, and then a Graphics object taking the Image in the constructor.

The Image is ARGB and should have transparent parts. Sometimes I want to “clear” a rectangular section of the image, meaning I want to completely nix the pixels in that region and replace them all with transparent black or something.

However, just changing the colour to transparent black and calling fillRect doesn’t work - it just alpha-blends the transparent rectangle with whatever was already there, meaning that it does nothing. I need something that actually erases what was there originally and replaces it with a transparent rectangle, meaning all of the pixels are changed to 0x00000000 or what have you.

Is there any simple way to do this?

Thanks


#2

Image::clear()


#3

Aha, Image::clear()! I was looking so hard at Graphics I didn’t realize success was lurking in the Image class. Thanks to Vinnie for pointing this out in JUCE chat.


#4

Er, and thanks to Jules to responding too, although the reply didn’t show up over here until now.


#5

At this point, I’d like to shamelessly plug my RadialImageConvolutionKernel.

Not only does it offer a faster implementation of Gaussian blur, but it also correctly blurs the alpha channel if the image passed is of type ARGB. Plus, it properly expands the image to the expected post-blur size.