Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Fast PNG loading - which mechanism?

Thread view: 
abickford@gmail.com - 14 Jun 2006 14:36 GMT
Hi all,

I'm writing an application that needs to load a few large PNGs as fast
as possible.  I've previously been using
javax.imageio.ImageIO.read(File) to get a BufferedImage, but I'm
wondering if there's a faster way?  I'm aware that there's
Toolkit.getImage(String) but I have no clue as to which is going to
give me the best performance.  Thanks for any tips you can provide.

Thanks,
Andre
Knute Johnson - 14 Jun 2006 18:42 GMT
> Hi all,
>
[quoted text clipped - 7 lines]
> Thanks,
> Andre

Your best bet for file loading performance increase is to get a faster
processor and a faster disk.  Beyond that I don't think there is any way
to modify the ImageIO classes to improve performance.

Do you need the complete image loaded at once?  Can you load a lower
resolution version and then load your hires asynchronously?

The only other thought I had, which probably won't work, is to use a
BufferedInputStream with a very large buffer (for faster disk I/O) and
then a PipedInputStream to send the data to your ImageIO.read() to
convert it to the BufferedImage asynchronously.  All of the extra I/O
will probably be slower but it might be worth a try.

Signature

Knute Johnson
email s/nospam/knute/

Mark Space - 14 Jun 2006 19:56 GMT
> Hi all,
>
[quoted text clipped - 7 lines]
> Thanks,
> Andre

In other applications, I've seen programmers spawn multiple threads to
load lots of data.  The idea is that multiple threads will create as
many IO requests as possible, allowing the OS to optimize the IO channel
and load as much as possible.

If you only read one thing at a time with one thread, there's a chance
the OS will preform no read ahead, and only load small bits at a time,
forcing lots of waiting for a slow IO channel.

Besides thumbnails, you could also look at compression.  Compressed
images load faster.  You could also load low resolution images first,
display them, then load higher resolution images in the background.
jcsnippets.atspace.com - 16 Jun 2006 16:09 GMT
> Hi all,
>
[quoted text clipped - 4 lines]
> Toolkit.getImage(String) but I have no clue as to which is going to
> give me the best performance.  Thanks for any tips you can provide.

One thing you could try, is preloading the images in a separate thread (if
that is an option) while you are doing other stuff.

For example, I've once written a small image viewer where, upon opening a
directory, the first, last, next, and previous image were loaded. If a user
wanted to see images one by one, they were always preloaded and therefor
available instantly.

Best regards,

JayCee
--
http://jcsnippets.atspace.com/
a collection of source code, tips and tricks


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.