Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

Warning: error_log(/home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.log) [function.error-log]: failed to open stream: Permission denied in /home/zetxek/domains/picateclas.net/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php on line 986

PicaTeclas

11Dic/080

Rotar una BufferedImage en Java

Me he llevado cierto tiempo encontrar una función para conseguir rotar 90 grados una imagen de tipo BufferedImage en Java, así que una vez he hallado cómo hacerlo qué menos que compartirlo por si os es útil:

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

Y en el sentido inverso sería así...

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

Vía | Snippet en Dzone.