본문 바로가기

programming/java, Spring, android, js

[Java AWT] Graphics2D.drawImage

BufferedImage img = ImageIO.read(imageSrc);
graphics2D.drawImage(img, 
			    		(int)Math.round(item.getX()), 
			    		(int)Math.round(item.getY()), 
			    		width / n, 
			    		height / n, 
			    		null );

java.awt.Graphics2D 와 관련하여 작업할 내용이 있었다. 요청자의 내용은 기존 색상 Rect Block 출력에서 이미지 리소스 출력으로 바꿔달라는 것이었다. (뭐 다른 요청들은 기본 수준의 로직적인 부분.)

 

알다시피, imageSrc 는 File 형이다.
따라서 read IO 는 반드시 IOException 이 발생할 수 있음을 기억하자.

반응형