com.wirefusion.player
Class WfImage

java.lang.Object
  extended by com.wirefusion.player.WfImage

public class WfImage
extends java.lang.Object

A WfImage is the object representing a WireFusion Image. It resembles the class java.awt.Image. A common usage for these images is to draw them on WfGraphics objects (WfGraphica.drawWfImage) in the method Wob.paint(WfGraphics g).


Field Summary
static int TYPE_INT_ARGB
          Represents an image with 8-bit RGBA color components packed into integer pixels.
static int TYPE_INT_RGB
          Represents an image with 8-bit RGB color components packed into integer pixels.
 
Constructor Summary
WfImage(int[] pixels, int width, int height, Core core, int imageType)
          Constructs a new WfImage with the specified pixels.
WfImage(int width, int height, Core core, int imageType)
          Constructs a new WfImage.
 
Method Summary
 int getHeight()
          Returns the image height.
 int getImageType()
          Returns the image type.
 int getMemoryUsage()
          Returns the number of bytes used by the pixel buffer.
 int[] getPixels()
          Returns the pixel storage of this image.
 int getWidth()
          Returns the image width.
 void setAlphaFromBlueMask(WfImage blueMaskImg)
          Copies the blue component in each pixel of blueMaskImg to the alpha component in this image.
 void setAlphaFromBlueMask(WfImage blueMaskImg, java.awt.Rectangle destRect)
          Copies the blue component in each pixel of blueMaskImg to the alpha component in this image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_INT_ARGB

public static final int TYPE_INT_ARGB
Represents an image with 8-bit RGBA color components packed into integer pixels. The color data in this image is considered not to be premultiplied with alpha.

See Also:
Constant Field Values

TYPE_INT_RGB

public static final int TYPE_INT_RGB
Represents an image with 8-bit RGB color components packed into integer pixels.

See Also:
Constant Field Values
Constructor Detail

WfImage

public WfImage(int[] pixels,
               int width,
               int height,
               Core core,
               int imageType)
Constructs a new WfImage with the specified pixels. The parameter imageType should be WfImage.TYPE_INT_ARGB or WfImage.TYPE_INT_RGB, depending on the pixel type used in the pixel array.

Parameters:
pixels - WfImage will use this pixel array as pixel data storage
width - width of the created image
height - height of the created image
core - a reference to the Core object
imageType - the type of the pixels in the pixel array

WfImage

public WfImage(int width,
               int height,
               Core core,
               int imageType)
Constructs a new WfImage. The pixel storage will not be created (and thus allocate memory) until it is actually needed. The parameter imageType should be WfImage.TYPE_INT_ARGB or WfImage.TYPE_INT_RGB, depending on the type of image you want.

Parameters:
width - width of the created image
height - height of the created image
core - a reference to the core object
imageType - type of the created image
Method Detail

setAlphaFromBlueMask

public void setAlphaFromBlueMask(WfImage blueMaskImg,
                                 java.awt.Rectangle destRect)
Copies the blue component in each pixel of blueMaskImg to the alpha component in this image. If this image is of type TYPE_INT_RGB, it is converted to TYPE_INT_ARGB.

Parameters:
blueMaskImg - a blue mask image

setAlphaFromBlueMask

public void setAlphaFromBlueMask(WfImage blueMaskImg)
Copies the blue component in each pixel of blueMaskImg to the alpha component in this image. If this image is of type TYPE_INT_RGB, it is converted to TYPE_INT_ARGB.

Parameters:
blueMaskImg - a blue mask image

getImageType

public int getImageType()
Returns the image type.

Returns:
the image type

getPixels

public int[] getPixels()
Returns the pixel storage of this image. It is a direct reference to the storage, so changing the values in the int array will change the pixel data in this image. If this WfImage object reference/use cached pixels, it will no longer use the cached pixels after the call to this method. It will use a clone of the cached pixels instead.

Returns:
the pixel storage

getWidth

public int getWidth()
Returns the image width.

Returns:
the image width

getHeight

public int getHeight()
Returns the image height.

Returns:
the image height

getMemoryUsage

public int getMemoryUsage()
Returns the number of bytes used by the pixel buffer. If the pixel buffer is null, for example if the pixels are cached, 0 will be returned.

Returns:
the number of bytes used by the pixel buffer