Question

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)?
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top