Java Image to BufferedImage toBufferedImage(Image i)

Here you can find the source of toBufferedImage(Image i)

Description

to Buffered Image

License

Open Source License

Declaration

public static BufferedImage toBufferedImage(Image i) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;
import java.awt.image.*;

import javax.swing.*;

public class Main {
    public static BufferedImage toBufferedImage(Image i) {
        BufferedImage result = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = result.createGraphics();
        g.drawImage(i, 0, 0, null);/*from w w  w  .ja  v  a2 s . co  m*/
        g.dispose();
        return result;
    }

    public static BufferedImage toBufferedImage(Icon icon) {
        BufferedImage result = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(null, result.createGraphics(), 0, 0);
        return result;
    }
}

Related

  1. imageToBufferedImage(Image img)
  2. imageToBufferedImage(Image img)
  3. imageToBufferedImage(Image pImage)
  4. imageToBufferedImage(Image src)
  5. makeRGBABufferedImageFromImage( Image image)
  6. toBufferedImage(Image image)
  7. toBufferedImage(Image image)
  8. toBufferedImage(Image image)
  9. toBufferedImage(Image image)