Notice
                              
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                            Link
                            
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
                            Tags
                            
                        
                          
                          - Redirect
 - TextBox
 - scrollView
 - Web Service
 - MANTIS
 - varags
 - Bootstrap
 - WebView
 - 이클립스
 - 자바
 - jsp
 - MSsql
 - MS-SQL
 - Maven
 - Java
 - 자바스크립트
 - Eclipse
 - html
 - 웹뷰
 - asp.net
 - SpringSource Tool Suite
 - Android
 - 웹 서비스
 - javascript
 - decompiler
 - 컬럼명
 - STS
 - Apache Lucene
 - C#
 - 안드로이드
 
                            Archives
                            
                        
                          
                          - Today
 
- Total
 
bboks.net™
Java Image to Buffered Image 본문
public BufferedImage toBufferedImage(Image input) {
    if (input instanceof BufferedImage)
        return (BufferedImage) input;
    if (input instanceof VolatileImage) 
        return ((VolatileImage)input).getSnapshot();
	    
    //too lazy to use MediaTracker directly:
    ImageIcon imageIcon = new ImageIcon(input);
    if (imageIcon.getImageLoadStatus() != MediaTracker.COMPLETE)
        throw new IllegalArgumentException("Can't load image");
    input = imageIcon.getImage();
    int w = input.getWidth(null);
    int h = input.getHeight(null);
 
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    BufferedImage output = gc.createCompatibleImage(w,h);
    //what about transparency? This code assumes it's OPAQUE,
    //but you can interrogate the image's source for its ColorModel
    Graphics2D g = output.createGraphics();
    g.drawImage(input, 0, 0, null);
    g.dispose();
    return output;
}