2010. 4. 28. 15:05 Program.../Java Language
자바 이미지 썸네일 프로그램
public class ImageThumbnail
{
private Image createThumbnail(Image image, int _thumbWidth, int _thumbHeight) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
int thumbWidth = _thumbWidth;
int thumbHeight = _thumbHeight;
Image thumb = Image.createImage(thumbWidth, thumbHeight);
Graphics g = thumb.getGraphics();
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
g.setClip(x, y, 1, 1);
int dx = x * sourceWidth / thumbWidth;
int dy = y * sourceHeight / thumbHeight;
g.drawImage(image, x - dx, y - dy,
Graphics.LEFT | Graphics.TOP);
}
}
Image immutableThumb = Image.createImage(thumb);
return immutableThumb;
}
}
'Program... > Java Language' 카테고리의 다른 글
자바를 배워보자 Java RMI (0) | 2010.04.28 |
---|---|
자바를 배워보자 Java NET (2) - Socket 통신 (0) | 2010.04.28 |
자바를 배워보자 Java NET (1) (0) | 2010.04.28 |
자바를 배워보자 Java NET (사전조사) (0) | 2010.04.28 |
자바를 배워보자 Java IO (3) (0) | 2010.04.28 |