What different image types (classes) are available in Java? I know of BufferedImage, VolatileImage and I have heard about some other hardware accelerated image type called automated image or something.
Automatic Images (otherwise known as Managed Images), are images that are stored in main memory, and after several draw operations, will be cached in vram.
Automatic Images are the only way of getting hardware accelerated bitmask transparency.
There are only 3 classes you will need to worry about :-
- Image
The super class of all Images.
The Image reference returned from toolkit.getImage() and toolkit.createImage(URL or String) will be an automatic image.
- BufferedImage
BufferedImages created using any of the BufferedImage constructors will NOT be hardware accelerated.
BufferedImages returned from graphicsConfiguration.createCompatibleImage() will be elligable for hardware accleration as long as a direct reference to the images raster is never obtained.
(bufferedImage.getData())
Once this occurs, the image will no longer be cached in vram.
- VolatileImage
VolatileImages (obtained from graphicsconfiguration.createCompatibleVolatileImage() or component.createVolatileImage()) exist in vram only.
There is no copy of them in main memory.
if possible, VolatileImages will always be stored in vram (regardless of whether they are drawn or not)
If I make a gif image, which Java image types will support transparency? How do they support transparency? Do I have to specify what color is transparent etc.
No special code is required to create a transparent image.
The gif format itself provides for bitmask transparency.
As to how to achieve this, it varies between paint packages.
Can I get transparency on jpeg images? How?
no, the jpeg format has no support for transparency.
If you want >8bit images with transparency or translucency, use png.
Is automated images (sp?) the fastest way to do transparency? Is it handled automatically by the image if I want to draw it using Graphics or Graphics2D’s drawImage() methods?
automatic images (managed images) are the ONLY way of getting hardware accelerated transparency.
Johan Tibell
[/quote]