Copying image to VolatileImage or BufferedImage

I noticed some posts on get better results using hardware accelerated Volatile or BufferedImages. That part I understand and I know how to create the images. However what I don’t quite understand is how to load the image file (gif, jpg, bmp, whatever) into said image. Am I thinking wrong? Do these “images” not hold raster data somehow? And if not who thought up these names?

Sorry, I couldn’t find anything on these boards or the Java site. Any help would be appreciated, thanks.

Ok, after doing a little searching on this forum I think I figured it out. You have to create the B or V image, then get the graphics to it, draw the image source onto it and then you can use that, no? Can anyone confirm this?

Although I did a search for VolatileImage and it didn’t produce the answer so I don’t feel to bad.

Honestly, I’m not trying to bump my own thread :slight_smile:

It’s strange, I tried the method I think Abuse described in another thread, but the moment I use the “accelerated” images described in the HW Transparency in 1.4.1_02 thread it slows my graphics to a grind compared to the smooth rendering without HW acceleration. Weird.

yup, you’ve sussed it.

  1. load your image
  2. create the bufferedimage/volatileimage
  3. draw the loaded image onto the volatile/buffered image.

as to the second issue,
it depends what you are actually doing with the image, as to whether it will be faster having it loaded in vram rather than system memory.

if you are performing a drawing operation that isnt hardware accelerated for instance, it will be far slower if the image is in vram!

[quote]yup, you’ve sussed it.

  1. load your image
  2. create the bufferedimage/volatileimage
  3. draw the loaded image onto the volatile/buffered image.

as to the second issue,
it depends what you are actually doing with the image, as to whether it will be faster having it loaded in vram rather than system memory.

if you are performing a drawing operation that isnt hardware accelerated for instance, it will be far slower if the image is in vram!
[/quote]
4. draw V or B image to the screen, using a gfx object from something like a frame.

iIs your frame double buffered? If so youa re doing this:

Java Heap Video Memory
Initial Image -------------> Volatile Image
Frame Buffer <------------ Volatile Image
Frame Buffer --------------> Onscreen Memory

Volatile images are most often used in conjunction with Full Screen and Buffer Strategy in which case (if you have enough
VRAM) the volatile image wil get written straight to the onscreen
memory (or rather screen memory which will be onscreen once you call show() on the buffer strategy.)

If you dont want to take very tight control of the drawing and do it all youself then my advice is to use what we used to call “Automatic Images” and are now called “Managed Images.”

JK

P.S. I assume you reant doing something silly like redrawing the
initial image to the Volatile image every frame, are you? That woudl defeat the purpose and indeed just make it slower.