This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes ImageIcon performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ImageIcon performance" Watch "ImageIcon performance" New topic

ImageIcon performance

Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
Hi, I'm trying to load a large list of images from my HD into an application using ImageIcon to get the images width and height, but I'm experiencing performance issues, without creating an Imagicon (so I don't get image attributes) it works really fast, but if I create an imageicon to get those attributes (I need them) it works so slow, anyone has a solution?? Thanks.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You don't need to create an ImageIcon to get the size from an Image. Why don't you use Image#getWidth and Image#getHeight?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
the only way I've found to create an image from a path is using imageicon. If you know how to do it without using it, please tell me. I haven't had much time to search...
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Take a look at package javax.imageio. In it, ImageReader has methods getHeight and getWidth.

There is no emoticon for what I am feeling!
Emili Calonge
Ranch Hand

Joined: May 17, 2003
Posts: 84
I'm using it now actually, but it has the same performance problem. Thanks for the advice.
wood burning stoves
subject: ImageIcon performance
Similar Threads
how do i get an image of the icon from an JLabel
custom DefaultListCellRenderer only works on one PC
Cant load images from my jar
Image ath for JButtons using NetBeans
problem with MyClass.class.getResource()