title: Java rotate image turns part of background black
body: <p>When I try to rotate an image it appears that a part of the background turns black (my images are transparents)      </p>
  
  <p><a href="http://i.stack.imgur.com/i32EH.png" rel="nofollow">Background white</a><br>
  <a href="http://i.stack.imgur.com/7g2VY.png" rel="nofollow">Part of background turns black</a>  </p>
  
  <p>Here's the code that rotate the image :</p>
  
  <pre><code>public BufferedImage rotate(int height, int width, BufferedImage originalImg, int angle) {
      BufferedImage rotateImage = null;
      try {
          rotateImage = new BufferedImage(height, width, BufferedImage.TYPE_INT_RGB);
          AffineTransform a90 = AffineTransform.getRotateInstance(Math.toRadians(angle), height / 2, width / 2);
          AffineTransformOp op90 = new AffineTransformOp(a90, AffineTransformOp.TYPE_BILINEAR);
          op90.filter(originalImg, rotateImage);
      }
      catch (Exception e) {
          System.err.println(e);
      }
      return rotateImage;
  }
  </code></pre>