title: How to rotate a BufferedImage in Java?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4918482/rotating-bufferedimage-instances">Rotating BufferedImage instances</a>  </p>
  </blockquote>
  
  
  
  <p>The method I am currently using (below) results in a BufferedImage that becomes increasingly distorted with smaller angle arguments.</p>
  
  <pre><code>public static BufferedImage getRotatedImage(BufferedImage src, int angle) { 
  
      if (src == null) {
  
        System.out.println("getRotatedImage: input image is null");
        return null;
  
      }
  
      int transparency = src.getColorModel().getTransparency();
      BufferedImage dest =  gc.createCompatibleImage(
                                src.getWidth(), src.getHeight(), transparency );
      Graphics2D g2d = dest.createGraphics();
  
      AffineTransform origAT = g2d.getTransform(); 
  
      AffineTransform rot = new AffineTransform(); 
      rot.rotate(Math.toRadians(angle), src.getWidth()/2, src.getHeight()/2); 
      g2d.transform(rot); 
  
      g2d.drawImage(src, 0, 0, null);   
  
      g2d.setTransform(origAT);   
      g2d.dispose();
  
      return dest; 
  </code></pre>