Java BufferedImage Rotate rotateImage(BufferedImage image, double radians)

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

Description

rotate Image

License

Open Source License

Declaration

public static BufferedImage rotateImage(BufferedImage image, double radians) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage rotateImage(BufferedImage image, double radians) {
        BufferedImage rotatedImage = new BufferedImage(image.getWidth(), image.getHeight(),
                BufferedImage.TYPE_BYTE_GRAY);
        Graphics2D g2d = rotatedImage.createGraphics();
        g2d.rotate(radians);/* ww  w .java 2  s  .  c  om*/
        g2d.setBackground(Color.WHITE);
        int maxOfWidthHieght = Math.max(image.getWidth(null), image.getHeight(null));
        g2d.clearRect(-5 * maxOfWidthHieght, -5 * maxOfWidthHieght, 10 * maxOfWidthHieght, 10 * maxOfWidthHieght);
        g2d.drawImage(image, 0, 0, Color.WHITE, null);
        g2d.dispose();
        return rotatedImage;
    }
}

Related

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