tags:

views:

727

answers:

1

I'm working on a Java 2D rendering program (running on 1.6.0_11), which uses external images for its UI rendering. These large images contain several UI graphics parts at the same time, which I extract now with the BufferedImage.getSubimage(). Assuming an average desktop system (with our without enabling DirectX/OpenGL acceleration), my questions are:

  • The getSubimage() is a memory efficient call, as it shares the underlying image data, but does this affect the rendering speed of these sub images with the Graphics2D.drawImage()?
  • If the images use 8 bit per pixel color palette mode, what would be the gain/loss of using RGBA mode (e.g. 4x memory) or relying on the palette color model (e.g conversion time)?
+1  A: 

As far as I know, getSubimage(...) shouldn't have any significant effect to the rendering.

Converting image data is slow and usually it is better to try to avoid doing it on the fly.


With images slowness can be divided to two categories:

  • Disk I/O
  • Data processing

And disk I/O can easily be the slowest part.

If you are going to use only part of the image, it would be best to be able to load only part of the image from disk.

My experience is that JAI is better at doing only what is really needed than the standard library stuff.

iny
It's not the disk I/O time, because the source image is fully loaded into memory. A sample of this composite image can be seen at http://karnokd.uw.hu/open-ig-starmap.png . All UI graphics components are extracted from this kind of images.
kd304
I accept this answer because it states clearly - although not in detail - what I too found out since then plus suggests an alternative way of handling images. Thank you.
kd304