Here you can find the source of rotateImage(BufferedImage img, double angle)
public static BufferedImage rotateImage(BufferedImage img, double angle)
This method rotates the parsed image to the parsed angle.
Parameter | Description |
---|
public static BufferedImage rotateImage(BufferedImage img, double angle)
//package com.java2s; //License from project: Open Source License import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; public class Main { /**//www. j a va 2 s . c o m * <i><b>rotateImage</b></i> * <pre> public static BufferedImage rotateImage(BufferedImage img, * double angle)</pre> * <p>This method rotates the parsed image to the parsed angle.</p> * @param * @return BufferedImage * @see {@link dev.lucas.game.utils} * **/ public static BufferedImage rotateImage(BufferedImage img, double angle) { int w = img.getWidth(); int h = img.getHeight(); AffineTransform tx = new AffineTransform(); tx.translate(w / 2, h / 2); tx.rotate(angle); tx.scale(1, 1); tx.translate(-w / 2, -h / 2); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); return op.filter(img, null); } }