title: Drawing fully transparent "white" in Java BufferedImage
body: <p>This might sound like a bit of strange title, but bear with me, there <strong>is</strong> a reason:</p>
  
  <p>I am trying to generate a white glow around a text on a gray background.</p>
  
  <p>To generate the glow, I created a new BufferedImage that's bigger than the text, then I drew the text in white onto the canvas of the image and ran a Gaussian Blur over the image via a <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/image/ConvolveOp.html" rel="nofollow noreferrer">ConvolveOp</a>, hoping for something like this:</p>
  
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://i.stack.imgur.com/TELD0.png" alt="enter image description here"></p>
  
  <p>At first I was a bit surprised when the glow turned out <strong>darker</strong> than the gray background of the text:</p>
  
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://i.stack.imgur.com/xOMvr.png" alt="enter image description here"></p>
  
  <p>But after a bit of thinking, I understood the problem:</p>
  
  <p>The convolution operates on each color channel (R, G, B, and A) independently to calculate the blurred image. The transparent background of the picture has color value 0x00000000, i.e. a fully transparent <strong>black</strong>! So, when the convolution filter runs over the image, it not only blends the alpha value, but also mixes the black into the RGB values of the white pixels. This is why the glow comes out dark.</p>
  
  <p>To fix this, I need to initialize the image to 0x00FFFFFF, i.e. a fully transparent <strong>white</strong> instead, but if I just set that color and fill a rectangle with it, it simply does nothing as Java says "well, it's a fully transparent rectangle that you're drawing! That's not going to change the image... Let me optimize that away for you... Done... You're welcome.".</p>
  
  <p>If I instead set the color to 0x01FFFFFF, i.e. an almost fully transparent white, it does draw the rectangle and the glow looks beautiful, except I end up with a very faint white box around it...</p>
  
  <p>Is there a way I can initialize the image to 0x00FFFFFF everywhere?</p>
  
  <p><em>UPDATE:</em></p>
  
  <p>I found one way, but it's probably as non-optimal as you can get:</p>
  
  <p>I draw an opaque white rectangle onto the image and then I run a <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/image/RescaleOp.html" rel="nofollow noreferrer">RescaleOp</a> over the image that sets all alpha values to 0. This works, but it's probably a terrible approach as far as performance goes.</p>
  
  <p>Can I do better somehow?</p>
  
  <p>PS: I'm also open to entirely different suggestions for creating such a glow effect</p>