码迷,mamicode.com
首页 > 编程语言 > 详细

java从本地获取图片,并反转图片

时间:2015-09-06 13:03:28      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

public static void main(String[] args) throws InterruptedException, IOException {
	
		File file=new File("zp2.png");
		Image im=ImageIO.read(file);
		int w=im.getWidth(null);
		int h=im.getHeight(null);
		BufferedImage b=new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_INT_RGB);
		 b.getGraphics().drawImage(im.getScaledInstance(w,h, Image.SCALE_SMOOTH),  
	                0, 0, null);  
		 BufferedImage b2=new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_INT_RGB);
		 b2.getGraphics().drawImage(im.getScaledInstance(w,h, Image.SCALE_SMOOTH),  
	                0, 0, null);  
		 for(int x=0;x<h;x++)
			for(int y=0;y<w;y++)
			{
				int rgb=b.getRGB(y, x);
				b2.setRGB(w-1-y, x, rgb);
			}
		ImageIO.write(b2, "png", new File("4.png"));   
	}

  

java从本地获取图片,并反转图片

标签:

原文地址:http://www.cnblogs.com/bokeofzp/p/4785157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!