Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ImageIcon performance

 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at package javax.imageio. In it, ImageReader has methods getHeight and getWidth.
 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using it now actually, but it has the same performance problem. Thanks for the advice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic