Here you can find the source of rotateImage(final BufferedImage image, final double theta)
Parameter | Description |
---|---|
image | The image to be rotated. |
theta | The number of radians to rotate the image. |
public static BufferedImage rotateImage(final BufferedImage image, final double theta)
//package com.java2s; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; public class Main { /**/*from ww w .jav a2s. com*/ * Rotates an image around its center by a given number of radians. * * @param image The image to be rotated. * @param theta The number of radians to rotate the image. * @return The given image, rotated by the given theta. */ public static BufferedImage rotateImage(final BufferedImage image, final double theta) { AffineTransform transform = new AffineTransform(); transform.rotate(theta, image.getWidth() / 2.0, image.getHeight() / 2.0); AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); return transformOp.filter(image, null); } }