Here you can find the source of rotate(Image img, float radian)
public static Image rotate(Image img, float radian)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; public class Main { public static Image rotate(Image img, float radian) { if (img == null) { return null; }//from w w w . j a va 2 s .c o m int width = img.getWidth(null); int height = img.getHeight(null); BufferedImage bufImage = null; if (img instanceof BufferedImage) { bufImage = (BufferedImage) img; } else { bufImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); } Graphics2D g2d = bufImage.createGraphics(); bufImage = g2d.getDeviceConfiguration().createCompatibleImage(height, width, Transparency.TRANSLUCENT); g2d.dispose(); g2d = bufImage.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); AffineTransform origXform = g2d.getTransform(); AffineTransform newXform = (AffineTransform) (origXform.clone()); double xRot = height / 2.0f; newXform.rotate(Math.toRadians(90.0), xRot, xRot); g2d.setTransform(newXform); g2d.drawImage(img, 0, 0, null); g2d.setTransform(origXform); Image newImg = bufImage; float x = radian - 90.0f; if (x > 0) { newImg = rotate(bufImage, x); } return newImg; } }