package aaa;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class img2 {
public static void main(String[] args) {
try {
//获取图片
File raw = new File("d:/img/1.jpg");
BufferedImage bufferedImage = ImageIO.read(raw);
//旋转图片为指定角度 图片宽高不变
BufferedImage bufferedImage2 = rotateImage(bufferedImage, 270);
File outputfile2 = new File("d:/img/12.jpg");
//生成旋转后的图片
ImageIO.write(bufferedImage2,"jpg",outputfile2);
//旋转图片为指定角度 同时旋转宽高
BufferedImage buf
【JAVA】 图片旋转实现代码
最新推荐文章于 2024-07-01 03:15:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)