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 / November 2005

Tip: Looking for answers? Try searching our database.

BufferedImage.TYPE_CUSTOM conversion is painfully slow.

Thread view: 
emp - 24 Nov 2005 10:52 GMT
Hello,

I am loading PNG's and the resulting BufferedImage is of TYPE_CUSTOM. I
need to convert it as drawing this type of image with Graphics2D is very
slow (at least on my machine). I am converting using
Graphics.drawImage(dest, 0, 0, null), which is very slow.
I have looked into image.getRGB() which I suspect drawImage is using, as
it is just as slow.

Anyone know a faster way? It is taking me 1 second to load the image and
1/2 a second to convert!

Thanks
-Ed
Thomas Fritsch - 24 Nov 2005 15:56 GMT
> I am loading PNG's and the resulting BufferedImage is of TYPE_CUSTOM. I
> need to convert it as drawing this type of image with Graphics2D is very
> slow (at least on my machine). I am converting using
> Graphics.drawImage(dest, 0, 0, null), which is very slow.
> I have looked into image.getRGB() which I suspect drawImage is using, as
> it is just as slow.
BTW: You can check this by debugging with break-points in BufferedImage.

drawImage does not use BufferedImage.getRGB(int x, int y), which indeed
would be very slow.
Instead it uses BufferedImage.getRGB(int startX, int startY, int w, int
h, int[] rgbArray, int offset, int scansize) with chunks of h=10, which
is much faster. But speed still depends on other things like type of
ColorModel and Raster. It uses ColorModel.getRGB(Object) which is quite
slow for IndexColorModel, and faster for DirectColorModel.

> Anyone know a faster way?
I see little chances to make it faster, because it is outside your
control how the PNG-Reader builds the BufferedImage.

> It is taking me 1 second to load the image and
> 1/2 a second to convert!
I can't judge these times as slow or fast without knowing width and
height of your image.

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Thomas Fritsch - 24 Nov 2005 16:46 GMT
>> I am loading PNG's and the resulting BufferedImage is of TYPE_CUSTOM.
>> I need to convert it as drawing this type of image with Graphics2D is
[quoted text clipped - 12 lines]
> ColorModel and Raster. It uses ColorModel.getRGB(Object) which is quite
> slow for IndexColorModel, and faster for DirectColorModel.
Sorry, I confused things. The findings above apply to
  drawImage(Image, AffineTransform, ImageObserver)
and probably not to your case
  drawImage(Image, int x, int y, ImageObserver)

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

emp - 24 Nov 2005 22:05 GMT
Never mind, after sleeping on it I implemented my own special case
converters, it is now a nice 5x faster and my interface feels much faster :)
-Ed


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



©2009 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.