반응형
https://code-zzolbo.tistory.com/55
에서 이미지 파일 사이즈를 변경하고 이미지에서 네모박스로 특별한 표시를 원한다면,
x축 , y축 , width , height 값을 변수로 받아 처리 할 수 있다.
[ 활용 메서드 생성 ]
public void paint(String x , String y , String w , String h , String fileFullpath) {
Image image = null;
Graphics g;
try {
image = ImageIO.read(new File(fileFullpath));
} catch (IOException el) {
el.printStackTrace();
}
Image = resizeImage = image.getScaledInstance(이미지 width , 이미지 hieght, Image.SCALE_SMOOTH);
BufferedImage newImage = new BufferedImage(이미지 width , 이미지 hieght , BufferedImage.TYPE_INT_RGB);
g = newImage.getGraphics();
g.drawImage(resizeImage,0 ,0 ,null);
g.drawRect(x,y,w,h);
g.dispose();
try {
ImageIO.write(newImage, "jpg", new File(fileFullPath));
} catch (IOException e) {
e.printStackTrace();
}
}
[ 사용 방법 ]
paint(20,30,100,120,"C:\test.jpg");
반응형
LIST
'IT > JAVA' 카테고리의 다른 글
[JAVA] TIB/RV 랑데부 통신 관련 로컬 통신 테스트. (0) | 2021.12.23 |
---|---|
[JAVA] 가끔 써먹을 base64 인코딩 전용 메서드 생성. (0) | 2021.12.22 |
[JAVA] 이미지파일 사이즈 변경 및 확인. (2) | 2021.12.21 |
[JAVA] 배열 순서 정렬 , indexof로 특정단어 위치 찾기 (0) | 2020.01.09 |
[JAVA] 배열에 대해서 (0) | 2020.01.09 |
댓글