Java BufferedImage Rotate rotateImage(final BufferedImage image, final double theta)

Here you can find the source of rotateImage(final BufferedImage image, final double theta)

Description

Rotates an image around its center by a given number of radians.

License

Open Source License

Parameter

Parameter Description
image The image to be rotated.
theta The number of radians to rotate the image.

Return

The given image, rotated by the given theta.

Declaration

public static BufferedImage rotateImage(final BufferedImage image, final double theta) 

Method Source Code

//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);
    }
}

Related

  1. rotateImage(BufferedImage imageToRotate, float degrees)
  2. rotateImage(BufferedImage img, double angle)
  3. rotateImage(BufferedImage img, double angle, int type)
  4. rotateImage(BufferedImage img, double degree)
  5. rotateImage(BufferedImage src, double degrees)
  6. rotateImage(final BufferedImage savedImage, final int angle)
  7. rotateImage(final BufferedImage src, final double degrees)
  8. rotateImage180(BufferedImage image, final int bufferedImageType)
  9. rotateImageLeft90( BufferedImage bufferedimage)