Java Utililty Methods BufferedImage Rotate

List of utility methods to do BufferedImage Rotate

Description

The list of methods to do BufferedImage Rotate are organized into topic(s).

Method

BufferedImagerotateImage(BufferedImage img, double degree)
rotate Image
double angle = Math.toRadians(degree);
return tilt(img, angle);
BufferedImagerotateImage(BufferedImage src, double degrees)
Rotates a BufferedImage
double radians = Math.toRadians(degrees);
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
double sin = Math.abs(Math.sin(radians));
double cos = Math.abs(Math.cos(radians));
int newWidth = (int) Math.floor(srcWidth * cos + srcHeight * sin);
int newHeight = (int) Math.floor(srcHeight * cos + srcWidth * sin);
BufferedImage result = new BufferedImage(newWidth, newHeight, src.getType());
...
BufferedImagerotateImage(final BufferedImage image, final double theta)
Rotates an image around its center by a given number of radians.
AffineTransform transform = new AffineTransform();
transform.rotate(theta, image.getWidth() / 2.0, image.getHeight() / 2.0);
AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
return transformOp.filter(image, null);
BufferedImagerotateImage(final BufferedImage savedImage, final int angle)
rotate Image
final BufferedImage rotatedImage;
if (angle == 180) {
    final AffineTransform tx = AffineTransform.getScaleInstance(-1, -1);
    tx.translate(-savedImage.getWidth(null), -savedImage.getHeight(null));
    final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    rotatedImage = op.filter(savedImage, null);
} else {
    final int w = savedImage.getWidth();
...
BufferedImagerotateImage(final BufferedImage src, final double degrees)
DOCUMENT ME!
final AffineTransform affineTransform = AffineTransform.getRotateInstance(Math.toRadians(degrees),
        src.getWidth() / 2, src.getHeight() / 2);
final BufferedImage rotatedImage = new BufferedImage(src.getWidth(), src.getHeight(), src.getType());
final Graphics2D g = (Graphics2D) rotatedImage.getGraphics();
g.setTransform(affineTransform);
g.drawImage(src, 0, 0, null);
return rotatedImage;
BufferedImagerotateImage180(BufferedImage image, final int bufferedImageType)
rotate Image
return rotateImage90(rotateImage90(image, bufferedImageType), bufferedImageType);
BufferedImagerotateImageLeft90(BufferedImage bufferedimage)
rotate Image Left
int w = bufferedimage.getWidth();
int h = bufferedimage.getHeight();
int type = bufferedimage.getColorModel().getTransparency();
BufferedImage img;
Graphics2D graphics2d;
(graphics2d = (img = new BufferedImage(h, w, type)).createGraphics())
        .setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2d.rotate(Math.toRadians(270), w / 2, h / 2 + (w - h) / 2);
...
BufferedImagerotateImageRect(final BufferedImage image, final int degrees)
rotate Image Rect
double phi = Math.toRadians(degrees);
int width = image.getWidth(null);
int height = image.getHeight(null);
Point a = new Point(0, 0);
Point b = new Point(width, 0);
Point c = new Point(0, height);
Point d = new Point(width, height);
Point newA = rotate(a, phi);
...
BufferedImage[]rotateImages(BufferedImage imgs[], double angle)
rotateImages
   public static BufferedImage[] rotateImages(BufferedImage imgs[],  double angle)

This is a delegator method for the method 'rotateImage' but this method allows for a whole array to be rotated.

BufferedImage[] rotated_copy = copyImages(imgs);
for (int i = 0; i < imgs.length; i++) {
    rotated_copy[i] = rotateImage(rotated_copy[i], angle);
return rotated_copy;
BufferedImageRotateLeft(BufferedImage bi)
Rotate Left
AffineTransform afLeft = AffineTransform.getRotateInstance(Math.toRadians(270));
afLeft.translate(bi.getWidth() * -1, 0);
AffineTransformOp lOp = new AffineTransformOp(afLeft, null);
BufferedImage dstbi = lOp.filter(bi, null);
return dstbi;