Java BufferedImage Rotate rotateImage(BufferedImage img, double angle)

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

Description

rotateImage
   public static BufferedImage rotateImage(BufferedImage img,  double angle)

This method rotates the parsed image to the parsed angle.

License

Open Source License

Parameter

Parameter Description

Return

BufferedImage

Declaration

public static BufferedImage rotateImage(BufferedImage img, double angle) 

Method Source Code

//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);

    }
}

Related

  1. rotateImage(BufferedImage image, double angle)
  2. rotateImage(BufferedImage image, double radians)
  3. rotateImage(BufferedImage image, float angle)
  4. rotateImage(BufferedImage image, int cwRotationNeeded)
  5. rotateImage(BufferedImage imageToRotate, float degrees)
  6. rotateImage(BufferedImage img, double angle, int type)
  7. rotateImage(BufferedImage img, double degree)
  8. rotateImage(BufferedImage src, double degrees)
  9. rotateImage(final BufferedImage image, final double theta)