在路上

 找回密码
 立即注册
在路上 站点首页 学习 查看内容

Java 对图像进行90度旋转

2016-12-20 13:15| 发布者: zhangjf| 查看: 453| 评论: 0

摘要: public BufferedImage rotate90DX(BufferedImage bi){ int width = bi.getWidth(); int height = bi.getHeight(); BufferedImage biFlip = new BufferedImage(height, width, bi.getType()); ...
  1. public BufferedImage rotate90DX(BufferedImage bi)
  2. {
  3. int width = bi.getWidth();
  4. int height = bi.getHeight();
  5. BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
  6. for(int i=0; i<width; i++)
  7. for(int j=0; j<height; j++)
  8. biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j));
  9. return biFlip;
  10. }
  11. public BufferedImage rotate90SX(BufferedImage bi)
  12. {
  13. int width = bi.getWidth();
  14. int height = bi.getHeight();
  15. BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
  16. for(int i=0; i<width; i++)
  17. for(int j=0; j<height; j++)
  18. biFlip.setRGB(j, i, bi.getRGB(i, j));
  19. return biFlip;
  20. }
复制代码

最新评论

小黑屋|在路上 ( 蜀ICP备15035742号-1 

;

GMT+8, 2025-7-8 13:23

Copyright 2015-2025 djqfx

返回顶部