Java BufferedImage Rotate rotateImage(BufferedImage image, double angle)

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

Description

rotate Image

License

Apache License

Declaration

public static BufferedImage rotateImage(BufferedImage image, double angle) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics2D;
import java.awt.RenderingHints;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage rotateImage(BufferedImage image, double angle) {
        int width = image.getWidth();
        int height = image.getHeight();

        BufferedImage destinationImage = new BufferedImage(width, height, image.getType());
        Graphics2D graphics = destinationImage.createGraphics();
        graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.rotate(Math.toRadians(angle), width / 2, height / 2);
        graphics.drawImage(image, null, 0, 0);
        graphics.dispose();/*from   ww w.  j a  v a 2 s. c o m*/

        return destinationImage;
    }
}

Related

  1. rotate90ToRight(BufferedImage inputImage)
  2. rotateAndFlipSwappingRowsAndColumns(BufferedImage srcImage)
  3. rotateBufferedImage(BufferedImage bufferedImage, double angle)
  4. rotateByRightAngle(BufferedImage source, int degrees)
  5. rotateFortyFiveClockwise(BufferedImage img)
  6. rotateImage(BufferedImage image, double angle)
  7. rotateImage(BufferedImage image, double radians)
  8. rotateImage(BufferedImage image, float angle)
  9. rotateImage(BufferedImage image, int cwRotationNeeded)