Java Graphics Rotate rotateClockwise(Path source, Path target)

Here you can find the source of rotateClockwise(Path source, Path target)

Description

rotate Clockwise

License

Apache License

Declaration

public static void rotateClockwise(Path source, Path target) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.image.BufferedImage;

import java.io.IOException;
import java.nio.file.Path;

import javax.imageio.ImageIO;

public class Main {
    public static void rotateClockwise(Path source, Path target) throws IOException {
        BufferedImage srcImage = ImageIO.read(source.toFile());
        //      AffineTransform affineTransform = AffineTransform.getRotateInstance(Math.toRadians(90), srcImage.getWidth() / 2, srcImage.getHeight() / 2);
        //      BufferedImage targetImage = new BufferedImage(srcImage.getHeight(), srcImage.getWidth(), srcImage.getType());
        //      Graphics2D g = (Graphics2D) targetImage.getGraphics();
        //      g.setTransform(affineTransform);
        //      g.drawImage(srcImage, 0, 0, null);

        int width = srcImage.getWidth();
        int height = srcImage.getHeight();
        BufferedImage targetImage = new BufferedImage(height, width, srcImage.getType());
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                targetImage.setRGB(y, (width - x - 1), srcImage.getRGB(x, y));
            }//from   w w  w .  j a  v  a2 s.  c  om
        }

        ImageIO.write(targetImage, "jpeg", target.toFile());
    }
}

Related

  1. rotate(Shape shape, float angle, float x, float y)
  2. rotate_point(double rx, double ry, double angle, double cx, double cy)
  3. rotateArea(Area a, double rotation, Point2D rotateAround)
  4. rotateBy(Vector points, double theta, Vector newPoints)
  5. rotateByAngle(final Point2D pos, final Point2D center, final double angle)
  6. rotateCoor(float x, float y, float theta)
  7. rotateCoorAroundPoint(float x, float y, float xctr, float yctr, float theta)
  8. rotateHue(Color color, float fraction)
  9. rotateHue(Color color, float fraction)