Return to Snippet

Revision: 1728
at November 10, 2006 00:09 by whitetiger


Updated Code
public BufferedImage halfFlipW(BufferedImage bi)
	{
		int width = bi.getWidth();
		int height = bi.getHeight();
		
		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width; i++)
			for(int j=0; j<height/2; j++)
			{
				biFlip.setRGB(i, j, bi.getRGB(i, j));
				biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j));
			}
		
		return biFlip;
	}


	public BufferedImage halfFlipH(BufferedImage bi)
	{
		int width = bi.getWidth();
		int height = bi.getHeight();
		
		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width/2; i++)
			for(int j=0; j<height; j++)
			{
				biFlip.setRGB(i, j, bi.getRGB(i, j));
				biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j));
			}
		
		return biFlip;
	}

Revision: 1727
at November 9, 2006 23:54 by whitetiger


Initial Code
	public BufferedImage halfFlipW(BufferedImage bi)
	{
		int width = bi.getWidth();
		int height = bi.getHeight();
		
		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width; i++)
			for(int j=0; j<height/2; j++)
			{
				biFlip.setRGB(i, j, bi.getRGB(i, j));
				biFlip.setRGB(i, (height-1)-j, bi.getRGB(i, j));
			}
		
		return biFlip;
	}


	public BufferedImage halfFlipH(BufferedImage bi)
	{
		int width = bi.getWidth();
		int height = bi.getHeight();
		
		BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width/2; i++)
			for(int j=0; j<height; j++)
			{
				biFlip.setRGB(i, j, bi.getRGB(i, j));
				biFlip.setRGB((width-1)-i, j, bi.getRGB(i, j));
			}
		
		return biFlip;
	}

Initial URL


Initial Description


Initial Title
Java - HalfFlipH / HalfFlipW

Initial Tags
image, java, filter, images

Initial Language
Java