Java 对图像进行90度旋转

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public BufferedImage rotate90DX(BufferedImage bi)
{
    int width = bi.getWidth();
    int height = bi.getHeight();
      
    BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
      
    for(int i=0; i<width; i++)
        for(int j=0; j<height; j++)
            biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j));
      
    return biFlip;
}
 
 
public BufferedImage rotate90SX(BufferedImage bi)
{
    int width = bi.getWidth();
    int height = bi.getHeight();
      
    BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
      
    for(int i=0; i<width; i++)
        for(int j=0; j<height; j++)
            biFlip.setRGB(j, i, bi.getRGB(i, j));
      
    return biFlip;
}