title: BufferedImage getScaledInstance changes brightness of picture
body: <p>I use this piece of code to draw a Image into a Graphics component. It should size the image to the maximum space available, if it is big enough:</p>
  
  <pre><code>    // getWidth() = component width, image.getWidth() = image width
      double w = getWidth() * 1.0 / image.getWidth();
      double h = getHeight() * 1.0 / image.getHeight();
      if (w &lt; 1 || h &lt; 1) {
          double d = Math.min(Math.min(w, h), 1);
          g.drawImage(bi.getScaledInstance((int) (d * image.getWidth()), (int) (d * image.getHeight()), Image.SCALE_REPLICATE), 0, 0, null);
      } else {
          g.drawImage(bi, 0, 0, null);
      }
  </code></pre>
  
  <p>The code works, the image gets scaled correctly. But unfortunately when the image is scaled, the brightness of the images changes as well on the Graphics!</p>
  
  <p>Has anyone an idea where this could come from?
  I attached the scaled (first) and the not scaled version of the screen. </p>
  
  <p>I hope someone can help me with that!</p>
  
  <p>Cheers!
  Sebastian</p>
  
  <p><img src="https://i.stack.imgur.com/G7hjT.png" alt="image scaled with &lt;code&gt;getScaledInstance&lt;/code&gt;">
  <img src="https://i.stack.imgur.com/0jFxa.png" alt="without &lt;code&gt;getScaledInstance&lt;/code&gt;"></p>