ewe.fx
Class RGBImageData

java.lang.Object
  extended byewe.fx.RGBImageData
All Implemented Interfaces:
IImage, ImageData

public class RGBImageData
extends Object
implements ImageData, IImage

This class can be used to wrap up an IImage or ImageData of any type to act as an ImageData of type TYPE_ARGB or TYPE_RGB and, which uses int[] scan lines.

It can also be used to wrap up an ImageData of any type to act as an IImage.


Field Summary
protected  boolean canWrite
           
protected  boolean deferToImageData
           
protected  int height
           
protected  IImage image
           
protected  ImageData imageData
           
protected  boolean usesAlpha
           
protected  int width
           
 
Fields inherited from interface ewe.fx.ImageData
IS_AN_IMAGE_DATA_TYPE, SCAN_LINE_BYTE_ARRAY, SCAN_LINE_INT_ARRAY, TYPE_ARGB, TYPE_GRAY_SCALE_16, TYPE_GRAY_SCALE_2, TYPE_GRAY_SCALE_256, TYPE_GRAY_SCALE_4, TYPE_INDEXED_16, TYPE_INDEXED_2, TYPE_INDEXED_256, TYPE_INDEXED_4, TYPE_MONO, TYPE_RGB, TYPE_UNKNOWN
 
Fields inherited from interface ewe.fx.IImage
DISABLED, OUTLINED
 
Constructor Summary
RGBImageData()
          If you use this constructor, make sure you call one of the set() method before using any of the other methods.
RGBImageData(Object image)
           
RGBImageData(Object image, boolean useImageDataOverIImage)
           
 
Method Summary
static boolean actsAsRGBImageData(ImageData image)
          Return true if the specified ImageData acts in the same way that an RGBImageData would act.
 void draw(Graphics g, int x, int y, int options)
          Draw the full image at the specified co-ordinates in the graphics provided.
 void free()
          This frees system resources associated with the Image.
 Color getBackground()
          This returns a background color if one is set for the image.
 int getHeight()
          This returns the height of the image.
 int[] getImageColorTable()
          This always returns null.
 int getImageHeight()
           
 int getImageScanLineLength()
          This always returns the width of the original image.
 void getImageScanLines(int startLine, int numLines, Object destArray, int offset, int destScanLineLength)
          Get the image scan lines, always as ARGB integer values.
 int getImageScanLineType()
          This always returns SCAN_LINE_INT_ARRAY;
 int getImageType()
          This returns either TYPE_ARGB or TYPE_RGB.
 int getImageWidth()
           
 int[] getPixels(int[] dest, int offset, int x, int y, int width, int height, int options)
          Retrieve the pixels from the Image in encoded ARGB values.
 int getWidth()
          This returns the width of the image.
 boolean isWritableImage()
          Returns if you can write data to the Image.
 void set(Object newImage)
           
 void set(Object newImage, boolean useImageDataOverIImage)
          This can be used to set or change the image the RGBImageData is using.
 void setImageScanLines(int startLine, int numLines, Object sourceArray, int offset, int sourceScanLineLength)
          Set the image scan lines, always as ARGB integer values.
static IImage toIImage(Object image, RGBImageData wrapper)
           
 Image toImage()
           
static ImageData toImageData(Object image, RGBImageData wrapper)
          If the specified Image implements RGBImageData in exactly the same way as an RGBImageData does, then return the Image itself.
 boolean usesAlpha()
          Returns whether the image uses the Alpha channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

image

protected IImage image

imageData

protected ImageData imageData

deferToImageData

protected boolean deferToImageData

usesAlpha

protected boolean usesAlpha

canWrite

protected boolean canWrite

width

protected int width

height

protected int height
Constructor Detail

RGBImageData

public RGBImageData()
If you use this constructor, make sure you call one of the set() method before using any of the other methods.


RGBImageData

public RGBImageData(Object image)

RGBImageData

public RGBImageData(Object image,
                    boolean useImageDataOverIImage)
Method Detail

actsAsRGBImageData

public static boolean actsAsRGBImageData(ImageData image)
Return true if the specified ImageData acts in the same way that an RGBImageData would act. That is, its type is TYPE_RGB or TYPE_ARGB, and it uses scan lines of type int[], and its scan line length is equal to its width.


toImageData

public static ImageData toImageData(Object image,
                                    RGBImageData wrapper)
If the specified Image implements RGBImageData in exactly the same way as an RGBImageData does, then return the Image itself. Otherwise return the image wrapped in an RGBImageData object - using the provided wrapper object if it is not null. If this method returns null this indicates that the image parameter did not act as an RGBImageData would, but could not itself be wrapped up in an RGBImageData object.


toIImage

public static IImage toIImage(Object image,
                              RGBImageData wrapper)

set

public void set(Object newImage)

set

public void set(Object newImage,
                boolean useImageDataOverIImage)
This can be used to set or change the image the RGBImageData is using. The type of newImage can be IImage or ImageData.


getImageType

public int getImageType()
This returns either TYPE_ARGB or TYPE_RGB.

Specified by:
getImageType in interface ImageData

getImageScanLineType

public int getImageScanLineType()
This always returns SCAN_LINE_INT_ARRAY;

Specified by:
getImageScanLineType in interface ImageData

getImageScanLineLength

public int getImageScanLineLength()
This always returns the width of the original image.

Specified by:
getImageScanLineLength in interface ImageData

getImageScanLines

public void getImageScanLines(int startLine,
                              int numLines,
                              Object destArray,
                              int offset,
                              int destScanLineLength)
Get the image scan lines, always as ARGB integer values.

Specified by:
getImageScanLines in interface ImageData

setImageScanLines

public void setImageScanLines(int startLine,
                              int numLines,
                              Object sourceArray,
                              int offset,
                              int sourceScanLineLength)
                       throws IllegalStateException
Set the image scan lines, always as ARGB integer values.

Specified by:
setImageScanLines in interface ImageData
Throws:
IllegalStateException

getImageWidth

public int getImageWidth()
Specified by:
getImageWidth in interface ImageData

getImageHeight

public int getImageHeight()
Specified by:
getImageHeight in interface ImageData

getImageColorTable

public int[] getImageColorTable()
This always returns null.

Specified by:
getImageColorTable in interface ImageData

isWritableImage

public boolean isWritableImage()
Returns if you can write data to the Image.

Specified by:
isWritableImage in interface ImageData

getBackground

public Color getBackground()
Description copied from interface: IImage
This returns a background color if one is set for the image.

Specified by:
getBackground in interface IImage

draw

public void draw(Graphics g,
                 int x,
                 int y,
                 int options)
Description copied from interface: IImage
Draw the full image at the specified co-ordinates in the graphics provided.

Specified by:
draw in interface IImage

free

public void free()
Description copied from interface: IImage
This frees system resources associated with the Image.

Specified by:
free in interface IImage

usesAlpha

public boolean usesAlpha()
Description copied from interface: IImage
Returns whether the image uses the Alpha channel.

Specified by:
usesAlpha in interface IImage

getWidth

public int getWidth()
Description copied from interface: IImage
This returns the width of the image.

Specified by:
getWidth in interface IImage

getHeight

public int getHeight()
Description copied from interface: IImage
This returns the height of the image.

Specified by:
getHeight in interface IImage

getPixels

public int[] getPixels(int[] dest,
                       int offset,
                       int x,
                       int y,
                       int width,
                       int height,
                       int options)
Description copied from interface: IImage
Retrieve the pixels from the Image in encoded ARGB values. If the usesAlpha() method returns false, then the A component of each pixel value (the top 8 bits) should be ignored.

Specified by:
getPixels in interface IImage
Parameters:
dest - The destination int array. If this is null then a new array should be created.
offset - The offset into the array to start placing pixels.
x - the x co-ordinate within the image.
y - the y co-ordinate within the image.
width - the width of the pixel block to get.
height - the height of the pixel block to get.
options - options for retrieving pixels - currently unused.
Returns:
The array containing the pixels, or null if getting pixels is not supported.

toImage

public Image toImage()