Can one avoid BufferedImages being managed?

Suppose one is using BufferedImages to hold images but not directly drawing them to the screen. Is there any danger of the JVM trying to manage them and so tying up graphics card resources unnecessarily? If so can one stop the BufferedImages being managed?

I’m particularly concerned about OSX as I think Sun’s JVMs are more developed.

Thanks for any advice!

if you do not blit a buffered image onto “native” surfaces/images it won’t be managed at all but there is no way to control this.

You may explizitly get the Raster and this will set the “rasterStolen” variable but its not guaranteed to help everytime or may only cause extra overhead on new java-versions.

But basically if you don’t blit it to native it won’t get accerlated…

lg Clemens

An image will be attempted to be cached in vram only if you copy it to an accelerated surface (a couple of times), which can either be a screen or a volatile image (on X11, though, images created with Component.createImage are always ‘accelerated’ - since they’re based in a Pixmap)

But if you want to prevent an image from being accelerated,
you can do it in a couple of ways:

  • in 1.5, call Image.setAccelerationPriority(0.0) - this will prevent the image from being accelerated
  • “steal” the raster of the image: call bImage.getRaster().getDataBuffer() (where bimage is a
    BufferedImage) - in this case we can’t guarantee that the
    cached copy will always be up to date with the system
    memory surface, and so we give up any attempts to accelerate it.

Thanks,
Dmitri
Java2D Team

Thanks for the responses people! I’ll make a note of the setAccelerationPriority() call - I’m likely to be on 1.4 for a while.