Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Java - HalfFlipH / HalfFlipW (See related posts)

   1  
   2  	public BufferedImage halfFlipW(BufferedImage bi)
   3  	{
   4  		int width = bi.getWidth();
   5  		int height = bi.getHeight();
   6  		
   7  		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
   8  		
   9  		for(int i=0; i<width; i++)
  10  			for(int j=0; j<height/2; j++)
  11  			{
  12  				biFlip.setRGB(i, j, bi.getRGB(i, j));
  13  				biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j));
  14  			}
  15  		
  16  		return biFlip;
  17  	}


   1  
   2  	public BufferedImage halfFlipH(BufferedImage bi)
   3  	{
   4  		int width = bi.getWidth();
   5  		int height = bi.getHeight();
   6  		
   7  		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
   8  		
   9  		for(int i=0; i<width/2; i++)
  10  			for(int j=0; j<height; j++)
  11  			{
  12  				biFlip.setRGB(i, j, bi.getRGB(i, j));
  13  				biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j));
  14  			}
  15  		
  16  		return biFlip;
  17  	}

You need to create an account or log in to post comments to this site.


Click here to browse all 5556 code snippets

Related Posts