ewe.fx
Class ArrayImageData

java.lang.Object
  extended byewe.fx.ArrayImageData
All Implemented Interfaces:
ImageData

public class ArrayImageData
extends Object
implements ImageData

This implements an ImageData object using an Array to store the pixel information. You may only use an int[] as data if the type of the image is TYPE_RGB or TYPE_ARGB. You MAY use a byte[] as data for TYPE_RGB or TYPE_ARGB, but for TYPE_RGB the number of bytes per pixel must be 3 and for TYPE_ARGB it must be 4.


Field Summary
 
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
 
Constructor Summary
ArrayImageData()
           
 
Method Summary
 Object getArray()
           
static Object getArrayFor(int imageDataType, int width, int height)
          Create and return an array that can hold scan lines for an ImageData of a specified type with specified width and height.
static Object getArrayFor(int imageDataType, int scanLineType, int width, int height)
          Create and return an array that can hold scan lines for an ImageData of a specified type with specified width and height, and using a specified scanline type.
 int[] getImageColorTable()
          For indexed images, this retrieves the color table as an array of ARGB integers.
 int getImageHeight()
           
 int getImageScanLineLength()
          If the scan line type is SCAN_LINE_BYTE_ARRAY then this indicates the number of bytes is needed for one complete scan line.
 void getImageScanLines(int startLine, int numLines, Object destination, int offset, int destScanLineLength)
          Place a set of scan lines into a destination array.
 int getImageScanLineType()
          Get the type of scan line used by the image - either SCAN_LINE_BYTE_ARRAY or SCAN_LINE_INT_ARRAY
 int getImageType()
          This returns one of the TYPE_XXX values
 int getImageWidth()
           
static int getScanLineLengthFor(int imageDataType, int width)
          Get the scan line length needed for an array representation of a particular ImageData type for a particular image width.
static int getScanLineLengthFor(int imageDataType, int scanLineType, int width)
          Get the scan line length needed for an array representation of a particular ImageData type for a particular image width, using a scanLineType of either SCAN_LINE_INT_ARRAY or SCAN_LINE_BYTE_ARRAY.
static int getScanLineTypeFor(int imageDataType)
          Return the scan line type that would be used by default by the specified image data type.
 boolean isWritableImage()
          Returns if you can write data to the Image.
 ArrayImageData set(int imageDataType, int width, int height)
          Create and set the internal array for the ArrayImageData so that it can hold the scan lines for an Image of the specified type with the specified dimensions.
 ArrayImageData set(int imageDataType, int width, int height, int[] colorTable)
          Create and set the internal array for the ArrayImageData so that it can hold the scan lines for an Image of the specified type with the specified dimensions.
 ArrayImageData set(int imageDataType, int width, int height, Object array, int offset)
           
 ArrayImageData set(int imageDataType, int width, int height, Object array, int offset, int arrayScanLineLength, int[] colorTable, boolean writable)
           
 void setImageScanLines(int startLine, int numLines, Object source, int offset, int sourceScanLineLength)
          Place a set of scan lines from a source Array into the ImageData.
 Image toImage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

ArrayImageData

public ArrayImageData()
Method Detail

getArray

public Object getArray()

toImage

public Image toImage()

getScanLineTypeFor

public static int getScanLineTypeFor(int imageDataType)
Return the scan line type that would be used by default by the specified image data type.


set

public ArrayImageData set(int imageDataType,
                          int width,
                          int height,
                          int[] colorTable)
Create and set the internal array for the ArrayImageData so that it can hold the scan lines for an Image of the specified type with the specified dimensions. This method is used to provide a color table, which is necessary for TYPE_INDEXED_XXX values.

You can use the getArray() method to get the array that this method creates.


set

public ArrayImageData set(int imageDataType,
                          int width,
                          int height)
Create and set the internal array for the ArrayImageData so that it can hold the scan lines for an Image of the specified type with the specified dimensions. You can use the getArray() method to get the array that this method creates.


getArrayFor

public static Object getArrayFor(int imageDataType,
                                 int scanLineType,
                                 int width,
                                 int height)
Create and return an array that can hold scan lines for an ImageData of a specified type with specified width and height, and using a specified scanline type.


getArrayFor

public static Object getArrayFor(int imageDataType,
                                 int width,
                                 int height)
Create and return an array that can hold scan lines for an ImageData of a specified type with specified width and height.


getScanLineLengthFor

public static int getScanLineLengthFor(int imageDataType,
                                       int scanLineType,
                                       int width)
Get the scan line length needed for an array representation of a particular ImageData type for a particular image width, using a scanLineType of either SCAN_LINE_INT_ARRAY or SCAN_LINE_BYTE_ARRAY. Only TYPE_RGB and TYPE_ARGB can use both SCAN_LINE_INT_ARRAY or SCAN_LINE_BYTE_ARRAY, all other types must use SCAN_LINE_BYTE_ARRAY.


getScanLineLengthFor

public static int getScanLineLengthFor(int imageDataType,
                                       int width)
Get the scan line length needed for an array representation of a particular ImageData type for a particular image width. This method assumes that images of type TYPE_RGB and TYPE_ARGB use int arrays for scan lines and all others use byte arrays.


set

public ArrayImageData set(int imageDataType,
                          int width,
                          int height,
                          Object array,
                          int offset)

set

public ArrayImageData set(int imageDataType,
                          int width,
                          int height,
                          Object array,
                          int offset,
                          int arrayScanLineLength,
                          int[] colorTable,
                          boolean writable)

getImageType

public int getImageType()
Description copied from interface: ImageData
This returns one of the TYPE_XXX values

Specified by:
getImageType in interface ImageData

getImageHeight

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

getImageWidth

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

isWritableImage

public boolean isWritableImage()
Description copied from interface: ImageData
Returns if you can write data to the Image.

Specified by:
isWritableImage in interface ImageData

getImageColorTable

public int[] getImageColorTable()
Description copied from interface: ImageData
For indexed images, this retrieves the color table as an array of ARGB integers. If the image type is not TYPE_INDEXED_XXX, then null will be returned.

Specified by:
getImageColorTable in interface ImageData

getImageScanLineType

public int getImageScanLineType()
Description copied from interface: ImageData
Get the type of scan line used by the image - either SCAN_LINE_BYTE_ARRAY or SCAN_LINE_INT_ARRAY

Specified by:
getImageScanLineType in interface ImageData

getImageScanLineLength

public int getImageScanLineLength()
Description copied from interface: ImageData
If the scan line type is SCAN_LINE_BYTE_ARRAY then this indicates the number of bytes is needed for one complete scan line.

Specified by:
getImageScanLineLength in interface ImageData

getImageScanLines

public void getImageScanLines(int startLine,
                              int numLines,
                              Object destination,
                              int offset,
                              int destScanLineLength)
Description copied from interface: ImageData
Place a set of scan lines into a destination array. The type of the destination array must be either byte[] or int[] depending on the value of getImageScanLineType().

Specified by:
getImageScanLines in interface ImageData

setImageScanLines

public void setImageScanLines(int startLine,
                              int numLines,
                              Object source,
                              int offset,
                              int sourceScanLineLength)
Description copied from interface: ImageData
Place a set of scan lines from a source Array into the ImageData. The type of the destination array must be either byte[] or int[] depending on the value of getImageScanLineType().

Specified by:
setImageScanLines in interface ImageData