Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  BufferedImage vs. VolatileImage  (Read 6023 times)
0 Members and 1 Guest are viewing this topic.
Offline zaphod

Senior Newbie

Java Developer by day, Java Developer by ... hey

« Posted 2003-07-06 03:09:00 »

I was under the impression that VolatileImages are the only images that take advantage of VRAM (and hence have much superior speed).  However I've also heard that BufferedImages do this as well.  Can anyone confirm or refute this?

I'd like to be able to use to create my images.  Are all BufferedImages accelerated, or only those created using a call to the GraphicsConfiguration ie : graphicsConfiguration.createCompatibleImage( int, int, int)

Offline immudium

Junior Devvie

Gorram it!

« Reply #1 - Posted 2003-07-06 04:33:58 »

Well, I'm by no means an expert on the subject and I only know what I've read, but according to The VolatleImage API User Guide located at, "...offscreen images were moved to system memory in the form of the new image type: BufferedImage."  It goes on to say that "the performance of BufferedImage software rendering has improved greatly...however, there is still a need for even better performance".  At which point it simply indicates that, "a VolatileImage allows an application to take advantage of hardware acceleration".

I also remember reading, though I can't remember where, that if you simply made the correct calls to the super class, Image, that the jdk would determine the best derivative to use, i.e. BufferedImage or VolatileImage for the current situation.  I've never really tried verify that method, however.

I hope that helps in answering your question.  I would recommend reading the rest of that API, it's pretty informative not just in the VolatileImage API but in the history and evolution of Swing as well to some degree.
Offline zaphod

Senior Newbie

Java Developer by day, Java Developer by ... hey

« Reply #2 - Posted 2003-07-06 04:53:41 »

I had read through the entire API before I really even got started playing around with this business, but before I got too far with that I started reading the forums here, which is where I heard that BufferedImages were accelerated as well...

Since that API was put out a while ago, and 1.4.2 is now out and all, I thought maybe someone could give me the straight answer on the performance of BufferedImages vs. VolatileImages...  Perhaps I'll have to do the testing myself...

I appreciate all your input though!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Ninja

Medals: 71

falling into the abyss of reality

« Reply #3 - Posted 2003-07-06 12:04:42 »

Search the forums, its been covered many times before.

but cos i'm nice, i'll summarise it here Smiley

Images returned from these methods are 'ManagedImages' (previously known as Automatic Images)
This means they are elligable for caching in VRAM, and hence are hardware accelerated.


These slides maybe helpful :-

and also, this example program :-

Images returned from are not accelerated (in the current java version, though I believe the intention is to make them so)
If you want to load images using ImageIO, you must then subsequently copy the image into a ManagedImage.
The code to do that will look something like this :-

import java.awt.*;
import java.awt.image.*;
public class ImageLoader
   final GraphicsConfiguration gc;
   public ImageLoader(GraphicsConfiguration gc)
         gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
      this.gc = gc;

   public BufferedImage loadImage(String resource, int transparencyType)
         BufferedImage src =;
         //Images returned from ImageIO are NOT managedImages
         //Therefor, we copy it into a ManagedImage
         BufferedImage dst = gc.createCompatibleImage(src.getWidth(),src.getHeight(),transparencyType);
         Graphics2D g2d = dst.createGraphics();
         return dst;
      catch( e)
         return null;

Currently accelerated Transparency is only possible using ManagedImages. (not with VolatileImages)

Also, currently only bitmask transparency is *by default* accelerated.
However, there are flags to enabled hardware acceleration for images with a full alpha channel (Translucent). These flags also make AlphaComposite operations hardware accelerated.

The code to set the flags is :-

System.setProperty("sun.java2d.translaccel", "true");
System.setProperty("sun.java2d.ddforcevram", "true");

This Thread covers the flags in more detail;action=display;num=1048663269;start=0#0

Offline zaphod

Senior Newbie

Java Developer by day, Java Developer by ... hey

« Reply #4 - Posted 2003-07-06 13:54:39 »


Many thanks for that.  I've been reading through the forums and APIs and trying to sort out the truth from the "other stuff".  I really appreciate you putting together that fine list of links, as well as all the other info.  Hopefully armed with this new data I can eliminate most of the graphics headaches I've been having of late!

Offline immudium

Junior Devvie

Gorram it!

« Reply #5 - Posted 2003-07-07 02:42:24 »

I guess I'm still too much of a newb to be of much use to anyone.  Oh well, I'm glad you asked to question though, I learned much more than I expected I would today from Abuse's great summary and explanation.  Grin
Pages: [1]
  ignore  |  Print  

hadezbladez (736 views)
2018-11-16 13:46:03

hadezbladez (372 views)
2018-11-16 13:41:33

hadezbladez (726 views)
2018-11-16 13:35:35

hadezbladez (187 views)
2018-11-16 13:32:03

EgonOlsen (2385 views)
2018-06-10 19:43:48

EgonOlsen (2539 views)
2018-06-10 19:43:44

EgonOlsen (1473 views)
2018-06-10 19:43:20

DesertCoockie (2137 views)
2018-05-13 18:23:11

nelsongames (1934 views)
2018-04-24 18:15:36

nelsongames (2615 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!