Here you can find the source of rotate(BufferedImage source, int angle)
Parameter | Description |
---|---|
source | The source image. |
angle | The angle to rotate by (in degrees). |
public static BufferedImage rotate(BufferedImage source, int angle)
//package com.java2s; //License from project: Apache License import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { private static BufferedImage bimg; private static Graphics2D g2; private static int w; private static int h; /**/*from w ww . j a va 2 s . c om*/ * Rotates a given image to a given angle. * @param source The source image. * @param angle The angle to rotate by (in degrees). * @return BufferedImage */ public static BufferedImage rotate(BufferedImage source, int angle) { w = source.getWidth(); h = source.getHeight(); bimg = new BufferedImage(w, h, source.getType()); g2 = bimg.createGraphics(); g2.rotate(Math.toRadians(angle), w / 2, h / 2); g2.drawImage(source, null, 0, 0); return bimg; } }