Converting a ImageIcon array to a BufferedImage

I was wondering if there was a way of having a ImageIcon[] converted into a series of Buffered Image, I was thinking along the lines of something like this:

  public BufferedImage iconArrayToBufferedImage(ImageIcon[] icon){
    for (int i = 0; i < icon.length; i++) {
        BufferedImage screenShot = new BufferedImage(icon[i]);
    }


    return screenShot;

}

Answers


E.G. as seen in this answer.

BufferedImage bi = new BufferedImage(
    icon.getIconWidth(),
    icon.getIconHeight(),
    BufferedImage.TYPE_INT_RGB);
Graphics g = bi.createGraphics();
// paint the Icon to the BufferedImage.
icon.paintIcon(null, g, 0,0);
g.dispose();

For many icons, do that in a loop.


Need Your Help

Mat::convertTo does not work with OpenMP

c++ opencv openmp

I use Mat::convertTo() in parallel region, it does not convert matrix data to the specific type. But I tested with other functions e.g. cv::threshold(), cv::imshow(). It works fine. I don't know wh...

Conversion failed when converting the varchar value to int

tsql insert int varchar

I'm getting an error with what should be a simple query to insert data. I've done searching, but for the life of me, I cant figure out whats happening. Here's my SQL:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.