Proper way to create images?

I start this as a new thread because it really belongs as a tech tip, I think.

In 1.3.1, what is the proper way to create a buffered Image?

There are two that I think are possibles:

Image i = new BufferedImage( width, height, Transparency.TRANSLUCENT);

Image i = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB);

There’s also:

Image i = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

(or Transparency.BITMASK, or Transparency.OPAQUE).

Which is right?

What’s right in 1.4.1?

Since no on else is answering …
For 1.3 a good way should be:
MyVisibleComponent.getGraphicsConfiguration().createCompatibelImage(…)

This will give you an image that is optimised for blitting to the visible component, it has the same format and so the blit can be done 1:1 with no conversion necessary.

A new BufferedImage(…) will usually not result in a blit-optimal Image

One can also use GraphicsConfiguration.createCompatibleImage(w, h) or (w, h, Translucency).

This is usable when you don’t have a component visible.
A typical way to use it would be

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Image im = gc.createCompatibleImage(100, 100);

Thanks, guys.

I started using this but there was no appreciable increase in speed. See my new thread for a possible reason why.