Como recortar determinada parte de uma foto

1 resposta
R

Olá pessoal estou com mais uma dúvida hehehe

seguinte
BufferedImage bi = ImageIO.read(new File("C:/fotos/festa.jpg"));
			double x = bi.getHeight();
			double y = bi.getWidth();
			int height = (int) x;
			int width = (int) y;
			BufferedImage dest = new BufferedImage(width / 2, height / 2,
					BufferedImage.TYPE_INT_ARGB);
			Graphics2D g2d = dest.createGraphics();
			g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
			g2d.drawImage(bi, AffineTransform.getScaleInstance(0.5, 0.5), null);
			g2d.dispose();
			
			ImageIO.write(dest, "png", new File("C:/fotos/festa.jpg"));

Este códico diminue a figura gostaria de saber como faço para recortar um quadrado de 50% do tamando da tela e no centro da tela ao invez de diminuilo.

ok grato pela ajuda pessoal abraços

1 Resposta

Marky.Vasconcelos

Procure o método getSubimage do Graphics2D.

Criado 16 de março de 2010
Ultima resposta 16 de mar. de 2010
Respostas 1
Participantes 2