Java 对图片90度旋转详解编程语言

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; 
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/11085.html

(0)
上一篇 2021年7月19日 10:40
下一篇 2021年7月19日 10:40

相关推荐

发表回复

登录后才能评论