com.davisor.graphics
Class ImageFactory

java.lang.Object
  extended bycom.davisor.graphics.ImageFactory
All Implemented Interfaces:
ImageParams

public class ImageFactory
extends java.lang.Object
implements ImageParams

ImageFactory implements a simple run-time configurable Java BufferedImage generator that supports ImageParams image parameters.


Field Summary
static ColorType COLORTYPE
          ColorType for creating transparent colors.
 
Fields inherited from interface com.davisor.graphics.ImageParams
COMPRESSION, COMPRESSION_HIGH, COMPRESSION_LOW, COMPRESSION_MEDIUM, COMPRESSION_NONE, TRANSPARENT, TYPE, TYPE_PALETTE, TYPE_TRUECOLOR
 
Constructor Summary
ImageFactory()
           
 
Method Summary
static java.awt.image.BufferedImage createBufferedImage(int width, int height, java.lang.String imageParams)
          Creates a BufferedImage of specified size and type.
static void releaseBufferedImage(java.awt.image.BufferedImage image)
          Donates given image for later re-use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLORTYPE

public static final ColorType COLORTYPE
ColorType for creating transparent colors.

Constructor Detail

ImageFactory

public ImageFactory()
Method Detail

createBufferedImage

public static java.awt.image.BufferedImage createBufferedImage(int width,
                                                               int height,
                                                               java.lang.String imageParams)
Creates a BufferedImage of specified size and type. In particular, imageParams argument is expected to contain space separated ImageParams compatible name=value pairs:
name value Description
type truecolor Creates a BufferedImage.TYPE_INT_ARGB image.
palette Creates a BufferedImage.TYPE_BYTE_INDEXED image with a default 6x6x6+40 palette (see below).
transparent ColorType.toData(java.lang.String, java.text.ParsePosition) color string Specifies a transparent palette color. In order to have any effect, the color has to be one of the colors in the default palette.

If image type is not specified, it defaults to truecolor.

Palette details

The default palette contains a 6x6x6 color cube with 40 additional shades of gray. In particular, color indexes 0 (black) - 215 (white) contain all 8 bit combinations of RGB element values multiple of 51: Color indexes 216 (dark) - 255 (light) contain 8 bit RGB shades of gray, starting from element value 18 and continuing with increments of 6 up to 252.

Parameters:
width - image width in pixels
height - image height in pixels
imageParams - image properties
See Also:
releaseBufferedImage(java.awt.image.BufferedImage)

releaseBufferedImage

public static void releaseBufferedImage(java.awt.image.BufferedImage image)
Donates given image for later re-use. After calling this method, the image must not be used by the caller in any way anymore. In particular, the caller must be very carefull not to leave any static or other references to the image around.

Once an image has been released, the image factory may re-use it if someone later requests exactly the same kind of image by calling createBufferedImage(int, int, java.lang.String). Alternatively, the image may be thrown away at some time in the future, in which case it will eventually be claimed by the garbage collector.

Parameters:
image - image to be donated for later re-use
See Also:
createBufferedImage(int, int, java.lang.String)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.