Here you can find the source of rotate(BufferedImage image, int degrees)
Parameter | Description |
---|---|
image | The image file to rotate |
degrees | The amount of rotation in degrees |
public static BufferedImage rotate(BufferedImage image, int degrees)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.BufferedImage; public class Main { /**/*ww w. j av a 2 s. c o m*/ * Method used to rotate an image based on an inputted degree value * @param image The image file to rotate * @param degrees The amount of rotation in degrees * @return The rotated image file */ public static BufferedImage rotate(BufferedImage image, int degrees) { BufferedImage blankCanvas = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2D = (Graphics2D) blankCanvas.getGraphics(); g2D.rotate(Math.toRadians(degrees), image.getWidth() / 2, image.getHeight() / 2); g2D.drawImage(image, 0, 0, null); return image = blankCanvas; } }