title: How can I control the brightness of an Image?
body: <p><strong>I have the following problem:</strong></p>
  
  <p>I want to create a method to control the brightness of an Image. I think I have to convert it to a BufferedImage before.<br>
  And if the Image has an alpha channel and I want to convert it with <code>TYPE_INT_RGB</code> the alpha pixels will be black. But it works fine with <code>TYPE_INT_ARGB</code>...<br>
  It doesn't work if the image doesn't have an alpha channel and I convert it with <code>TYPE_INT_ARGB</code>. Then not only the brightness changes, but also the color. When I make the image brighter it becomes more yellow an it becomes blue if I darken it.<br>
  Can I convert it in another way or is there a possibility to check if the Image has an alpha channel?</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>public static Image brightnessControl(Image image, float brightness) {
  
      //First I convert the Image to a BufferedImage
      BufferedImage bi = new BufferedImage
              (image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
      Graphics bg = bi.getGraphics();
      bg.drawImage(image, 0, 0, null);
      bg.dispose();
  
      //here I brighten/darken the BufferedImage
      RescaleOp rescaleOp = new RescaleOp(brightness, 0, null);
      rescaleOp.filter(bi, bi);
  
      //I change the BufferedImage back to the Image again!
      image = bi;
  
      //Last but not least I return the Image...
      return image;
  }
  </code></pre>