title: Creating a composited image with a transparent background
body: <p>In Eclipse, I have a view that uses GEF and for some of the figures that I display. I need to paint some background.</p>
  
  <p>For some of the background, I use a system of folders with a set of predefined images (<code>top_left.png</code>, <code>top.png</code>, <code>top_right.png</code>, <code>left.png</code>, <code>middle.png</code>, ...., <code>bottom_right.png</code>) and, while I can recreate the background when needed, it is highly inefficient (especially since it redraws every time the view is being scrolled or a fly is passing by).</p>
  
  <p>To avoid having to recreate the background image everytime, I want to use a cache system: I create an Image object on which I paint each image, and then I cache that image in a map (the key being the dimension of the image).</p>
  
  <p>To be able to have rounded corners, the cache image needs to have a transparent background and this is where I am blocking:</p>
  
  <ul>
  <li><p>I have tried to set the transparent pixel and paint with the same color but without success</p></li>
  <li><p>I tried to use ImageData to set the alpha depending on the alpha of each source image but in that case, while the transparency is done well, the image created is all white.</p></li>
  </ul>
  
  <p>Is there a way in <a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" rel="nofollow">SWT</a> to do a transparent background image that I can paint some images on?</p>
  
  <hr>
  
  <p><em>Update:</em></p>
  
  <p>I found a possible solution by using a BufferedImage from <a href="http://en.wikipedia.org/wiki/Abstract_Window_Toolkit" rel="nofollow">AWT</a> and converting to SWT using code found in <a href="http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/ConvertbetweenSWTImageandAWTBufferedImage.htm" rel="nofollow">http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/ConvertbetweenSWTImageandAWTBufferedImage.htm</a></p>
  
  <p>While a good base, this code doesn't actually handle transparency, and I modified it quickly (and quite dirtily) to do it. Is there a reliable code for converting Images from AWT to SWT and inverse?</p>
  
  <p>I would prefer some solution to my problem that doesn't involve converting back and forth between images format.</p>