Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Rotating pngs in Java
  2. AffineTransform identity = new AffineTransform();
  3.         gr.setColor(Color.red);
  4.  
  5.         gr.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY );
  6.  
  7.         AffineTransform trans = new AffineTransform();
  8.         trans.setTransform(identity);
  9.         trans.rotate( -Math.toRadians(15) );
  10.         trans.translate(-25, 220);
  11.  
  12.         gr.drawImage(body.getImage(), 0, 200, null);
  13.         gr.drawImage(gun.getImage(), trans, this);
  14.        
  15. BufferedImage rotatedPhoto = Scalr.rotate(photo, Scalr.Rotation.CW_90, null);