ewe.fx
Class Image

java.lang.Object
  extended byewe.fx.Image
All Implemented Interfaces:
IImage, ImageData, ISurface
Direct Known Subclasses:
Buffer

public class Image
extends Object
implements ISurface, IImage, ImageData

Image represents a rectangular bitmapped image and is a very bottom level object for dealing with images and icons. The ewe.fx.mImage class is a better class for using images and icons since it can optimaly handle images with any degree of transparency.

However, Image objects do implement ISurface, and so you can draw directly to them and set their pixels data (if they are not created from an encoded image).


Field Summary
static int ALPHA_CHANNEL
          This is an option to be used in Image initializers.
static int ARGB_IMAGE
          This is an option to be used in Image initializers.
 Color background
           
static int BLACK_AND_WHITE_IMAGE
          Use this to specify a black and white image that is optimized for the default display.
static boolean debugImages
           
static int debugImageSize
          If this is set to a value > 0 then whenever numImages % debugImageSize is zero during creation, the number of images will be displayed on the screen.
static int EXACT_TYPE_IMAGE
          Use this during image creation that the EXACT image type must be created and if it cannot, then an ImageTypeNotSupportedException should be thrown.
static int FASTEST_DISPLAY_IMAGE
          Used as an option with the constructor Image(Image other,int options).
static int FOR_DISPLAY
          Used as an option with the constructor Image(Image other,int options).
 boolean freed
           
static int GRAY_SCALE_16_IMAGE
          Use this to specify a GRAY_SCALE_IMAGE image at one byte per pixel.
static int GRAY_SCALE_2_IMAGE
          Use this to specify a GRAY_SCALE_IMAGE image at one bit per pixel - this is the same as MONO_IMAGE;
static int GRAY_SCALE_256_IMAGE
          Use this to specify a GRAY_SCALE_IMAGE image at one byte per pixel.
static int GRAY_SCALE_4_IMAGE
          Use this to specify a GRAY_SCALE_IMAGE image at two bits per pixel.
static int GRAY_SCALE_IMAGE
          Use this to specify a GRAY_SCALE_IMAGE image that is optimized for the default display - without specifying the actual number of gray levels.
 boolean hasAlpha
           
static int INDEXED
          Deprecated. - use INDEXED_IMAGE instead. Use this to specify an indexed image. If neither INDEXED nor TRUE_COLOR is specified in the option for the constructor - then the appropriate one will be picked depending on the image type (i.e. INDEXED for bitmap images, and TRUE_COLOR for PNG images).
static int INDEXED_16_IMAGE
          Use this to specify an INDEXED_IMAGE image at 4 bits per pixel.
static int INDEXED_2_IMAGE
          Use this to specify an INDEXED_IMAGE image at 2 bits per pixel.
static int INDEXED_256_IMAGE
          Use this to specify an INDEXED_IMAGE image at one byte per pixel.
static int INDEXED_4_IMAGE
          Use this to specify an INDEXED_IMAGE image at 2 bits per pixel.
static int INDEXED_IMAGE
          Use this to specify an indexed image that is optimized for the display.
static int MONO_IMAGE
          Use this to specify a monochrome image, thereby using the smallest amount of space for the image.
 String name
           
static int numImages
          This is the number of Images that have been created but not freed.
static int RGB_IMAGE
          This is an option to be used in Image initializers.
static int SCALE_IMAGE
          This is an option for use with the constructor Image(ewe.io.Stream stream,int options,int requestedWidth,int requestedHeight) It specifies that the image should be scaled in the X and Y plane to be exactly the size specified.
 Color transparent
           
static int TRUE_COLOR
          Deprecated. - use RGB_IMAGE instead. This is an option to be used in Image initializers. Use this when creating an image to force the use of 24-bit or 32-bit images. Use it without ALPHA_CHANNEL for 24-bit.
 
Fields inherited from interface ewe.fx.ISurface
IMAGE_SURFACE, PRINTERJOB_SURFACE, WINDOW_SURFACE
 
Fields inherited from interface ewe.fx.IImage
DISABLED, OUTLINED
 
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
protected Image()
           
  Image(ByteArray image, int options)
          Use this to load a formatted image from an array of bytes.
  Image(ByteArray image, int options, int requestedWidth, int requestedHeight)
          Use this to load a formatted image from an array of bytes, optionally resizing the image during decoding if possible.
  Image(ByteArray image, int options, Rect sourceArea, int requestedWidth, int requestedHeight)
          Use this to load a formatted image from an array of bytes, optionally resizing a portion of the image during decoding if possible.
  Image(Image other, int options)
          This is the best way to create a copy of an image.
  Image(int width, int height)
          Creates an image of the specified width and height that can be used for drawing, with default (zero) options.
  Image(int width, int height, int options)
          Creates an image of the specified width and height that can be used for drawing.
  Image(int width, int height, int options, byte[] bits, int offset, int scanLineLength, int[] colorTable)
          Use this to create a mono, grayscale or indexed image from a the image pixel bits and the color table (for indexed images).
  Image(int width, int height, int options, int[] pixels, int offset, int scanLineLength)
          Use this to create an RGB_IMAGE or an ARGB_IMAGE from the image pixels.
  Image(Object nativeImage, int options)
          This creates an Image from a system dependant native image type.
  Image(Stream stream, int options)
          Use this to load a formatted image from an ewe.io.Stream.
  Image(Stream stream, int options, int requestedWidth, int requestedHeight)
          Use this to load a formatted image from an ewe.io.Stream, optionally resizing the image during decoding if possible.
  Image(Stream stream, int options, Rect sourceArea, int requestedWidth, int requestedHeight)
          Use this to load a formatted image from an ewe.io.Stream, optionally resizing a portion of the image during decoding if possible.
  Image(String path)
          Loads and constructs an image from a resource or file which contains a formatted image.
  Image(String path, int options)
          Loads and constructs an image from a resource or file which contains a formatted image.
 
Method Summary
 void draw(Graphics g, int x, int y, int options)
          Draw the full image at the specified co-ordinates in the graphics provided.
 boolean enableAlpha()
          Use this to enable the storing of an Alpha (transparency) channel with the image data.
protected static void fixMasks(Image image, Image mask, Color c)
           
 void free()
          Sets the image width and height to 0 and frees any systems resources associated with the image.
 void freeze()
          This tells the VM that you will no longer be making changes to this Image.
 Color getBackground()
          This returns a background color if one is set for the image.
 int getHeight()
          This returns the height of the image.
 byte[] getImageBits()
           
 int[] getImageColorTable()
          For indexed images, this retrieves the color table as an array of ARGB integers.
 int getImageHeight()
           
static ImageInfo getImageInfo(ByteArray imageBytes, ImageInfo destination)
          Get the information on an Image as stored in a formatted form.
static ImageInfo getImageInfo(Stream imageBytes, ImageInfo destination)
          Get the information on an Image as stored in a formatted form.
 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 destArray, 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()
           
 Object getNativeResource()
          Return an Object that holds a reference to the native resource used by the Image.
 int[] getPixels(int[] dest, int offset, int x, int y, int width, int height, int options)
          Gets a block of pixels in ARGB integer values.
 int getWidth()
          This returns the width of the image.
static Image invert(Image what)
          Get a new Image that is the inverse of the specified image.
 boolean isWritableImage()
          Returns if you can write data to the Image.
 void makeGray(Color transparent)
           
 Image rotate(Image destination, int degree)
          This rotates the image and places it into the destination Image (which should) be the correct size to receive the rotated image.
 Image scale(int newWidth, int newHeight)
           
 Image scale(int newWidth, int newHeight, int destOptions)
           
 Image scaleStrip(int newWidth, int newHeight, int destOptions, int yOffset, int height, Image destination)
           
 void setImageScanLines(int startLine, int numLines, Object sourceArray, int offset, int sourceScanLineLength)
          Place a set of scan lines from a source Array into the ImageData.
 void setPixels(int[] source, int offset, int x, int y, int width, int height, int options)
          Sets a block of pixels in ARGB integer values.
 void setPixels(int bitsPerPixel, int[] colorMap, int bytesPerRow, int numRows, int y, Object pixels)
          Deprecated. - Use the other setPixels() instead.
protected  void setSize(ImageCodec ic, Rect sourceArea, int requestedWidth, int requestedHeight, int options)
           
 Object toIcon(Image mask)
          Create a native Icon object.
static Object toIcon(String imageName, String maskName)
          Create a native Icon given the name of an Image and the name of its mask.
 Object toNativeImage(Object colorOrMask)
          Create a platform specific version of this image.
 boolean usesAlpha()
          Returns whether the image uses the Alpha channel.
 boolean wasDecoded()
          Returns true if this image was decoded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

transparent

public Color transparent

background

public Color background

name

public String name

freed

public boolean freed

hasAlpha

public boolean hasAlpha

TRUE_COLOR

public static final int TRUE_COLOR
Deprecated. - use RGB_IMAGE instead. This is an option to be used in Image initializers. Use this when creating an image to force the use of 24-bit or 32-bit images. Use it without ALPHA_CHANNEL for 24-bit.

See Also:
Constant Field Values

ALPHA_CHANNEL

public static final int ALPHA_CHANNEL
This is an option to be used in Image initializers. Use this when creating an image with an alpha (transparency) channel.

See Also:
Constant Field Values

RGB_IMAGE

public static final int RGB_IMAGE
This is an option to be used in Image initializers. It is used to specify a 24-bit image RGB image. It is the same as TRUE_COLOR

See Also:
Constant Field Values

ARGB_IMAGE

public static final int ARGB_IMAGE
This is an option to be used in Image initializers. It is used to specify a 32-bit image RGB image with an Alpha (transparency) channel. It is the same as RGB_IMAGE|ALPHA_CHANNEL.

See Also:
Constant Field Values

INDEXED

public static final int INDEXED
Deprecated. - use INDEXED_IMAGE instead. Use this to specify an indexed image. If neither INDEXED nor TRUE_COLOR is specified in the option for the constructor - then the appropriate one will be picked depending on the image type (i.e. INDEXED for bitmap images, and TRUE_COLOR for PNG images).

See Also:
Constant Field Values

INDEXED_IMAGE

public static final int INDEXED_IMAGE
Use this to specify an indexed image that is optimized for the display.

See Also:
Constant Field Values

FOR_DISPLAY

public static final int FOR_DISPLAY
Used as an option with the constructor Image(Image other,int options). Use this to specify that the new image is to be displayed on screen. This ensures that its alpha pixels are correctly rendered when used with Java 1.1 and PersonalJava.

See Also:
Constant Field Values

SCALE_IMAGE

public static final int SCALE_IMAGE
This is an option for use with the constructor Image(ewe.io.Stream stream,int options,int requestedWidth,int requestedHeight) It specifies that the image should be scaled in the X and Y plane to be exactly the size specified. If this is omitted the image will be scaled to fit in the specfied dimensions but keeping the same aspect ratio.

See Also:
Constant Field Values

MONO_IMAGE

public static final int MONO_IMAGE
Use this to specify a monochrome image, thereby using the smallest amount of space for the image.

See Also:
Constant Field Values

BLACK_AND_WHITE_IMAGE

public static final int BLACK_AND_WHITE_IMAGE
Use this to specify a black and white image that is optimized for the default display. This may be actually represented by a gray scale image.

See Also:
Constant Field Values

GRAY_SCALE_IMAGE

public static final int GRAY_SCALE_IMAGE
Use this to specify a GRAY_SCALE_IMAGE image that is optimized for the default display - without specifying the actual number of gray levels.

See Also:
Constant Field Values

GRAY_SCALE_256_IMAGE

public static final int GRAY_SCALE_256_IMAGE
Use this to specify a GRAY_SCALE_IMAGE image at one byte per pixel.

See Also:
Constant Field Values

GRAY_SCALE_16_IMAGE

public static final int GRAY_SCALE_16_IMAGE
Use this to specify a GRAY_SCALE_IMAGE image at one byte per pixel.

See Also:
Constant Field Values

GRAY_SCALE_4_IMAGE

public static final int GRAY_SCALE_4_IMAGE
Use this to specify a GRAY_SCALE_IMAGE image at two bits per pixel.

See Also:
Constant Field Values

GRAY_SCALE_2_IMAGE

public static final int GRAY_SCALE_2_IMAGE
Use this to specify a GRAY_SCALE_IMAGE image at one bit per pixel - this is the same as MONO_IMAGE;

See Also:
Constant Field Values

INDEXED_256_IMAGE

public static final int INDEXED_256_IMAGE
Use this to specify an INDEXED_IMAGE image at one byte per pixel.

See Also:
Constant Field Values

INDEXED_16_IMAGE

public static final int INDEXED_16_IMAGE
Use this to specify an INDEXED_IMAGE image at 4 bits per pixel.

See Also:
Constant Field Values

INDEXED_4_IMAGE

public static final int INDEXED_4_IMAGE
Use this to specify an INDEXED_IMAGE image at 2 bits per pixel.

See Also:
Constant Field Values

INDEXED_2_IMAGE

public static final int INDEXED_2_IMAGE
Use this to specify an INDEXED_IMAGE image at 2 bits per pixel.

See Also:
Constant Field Values

FASTEST_DISPLAY_IMAGE

public static final int FASTEST_DISPLAY_IMAGE
Used as an option with the constructor Image(Image other,int options). Use this to specify that the new image is to be displayed on screen. This ensures that its alpha pixels are correctly rendered when used with Java 1.1 and PersonalJava.

See Also:
Constant Field Values

EXACT_TYPE_IMAGE

public static final int EXACT_TYPE_IMAGE
Use this during image creation that the EXACT image type must be created and if it cannot, then an ImageTypeNotSupportedException should be thrown. Note that this does not apply to INDEXED_IMAGE - which tells the system to create the best INDEXED_IMAGE suitable for display on the platform, or BLACK_AND_WHITE_IMAGE which tells the system to create the best image type for display on the platform which will display only black and white pixels.

See Also:
Constant Field Values

debugImageSize

public static int debugImageSize
If this is set to a value > 0 then whenever numImages % debugImageSize is zero during creation, the number of images will be displayed on the screen.


numImages

public static int numImages
This is the number of Images that have been created but not freed. This will also count images that have been garbage collected but not freed before collection.


debugImages

public static boolean debugImages
Constructor Detail

Image

protected Image()

Image

public Image(int width,
             int height,
             int options)
      throws IllegalArgumentException,
             SystemResourceException,
             ImageTypeNotSupportedException
Creates an image of the specified width and height that can be used for drawing.

Parameters:
width - The width of the image. This must be greater than 0.
height - The height of the image. This must be greater than 0.
options - one or more of the image option values (e.g. TRUE_COLOR, MONO_IMAGE, GRAY_SCALE_IMAGE etc).
Throws:
IllegalArgumentException - if the image width or height is not within range.
SystemResourceException - if the underlying system could not create the image because of system resource problems.
ImageTypeNotSupportedException

Image

public Image(int width,
             int height)
      throws IllegalArgumentException,
             SystemResourceException,
             ImageTypeNotSupportedException
Creates an image of the specified width and height that can be used for drawing, with default (zero) options.

Parameters:
width - The width of the image. This must be greater than 0.
height - The height of the image. This must be greater than 0.
Throws:
IllegalArgumentException - if the image width or height is not within range.
SystemResourceException - if the underlying system could not create the image because of system resource problems.
ImageTypeNotSupportedException

Image

public Image(Image other,
             int options)
      throws SystemResourceException
This is the best way to create a copy of an image. The new Image CAN be drawn to, even if the original image was a decoded BMP/PNG image. If the old image had an alpha channel, then this new one will as well.

Parameters:
other - The image to copy.
options - Options used when creating the new image.
Throws:
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(Object nativeImage,
             int options)
      throws IllegalArgumentException,
             SystemResourceException
This creates an Image from a system dependant native image type. When running on a Java VM, a java.awt.Image object can be used. This will convert the Java image into a Ewe Image. There is no object currently that can be used with this constructor in a native Ewe VM.

Parameters:
nativeImage - an appropriate native image.
options - options for image creation.
Throws:
IllegalArgumentException - if the nativeImage is not appropriate.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(String path,
             int options)
      throws ImageDecodingException,
             UnsupportedImageFormatException,
             ImageNotFoundException,
             SystemResourceException
Loads and constructs an image from a resource or file which contains a formatted image. See the class documentation for information on which types of formatted images the Ewe VM can decode.

The path given is the path to the image file which can be in a ewe file or on the file system.

Parameters:
path - the name of the image resource or file.
options - creation options.
Throws:
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
ImageNotFoundException - if the image could not be found.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(String path)
      throws ImageDecodingException,
             UnsupportedImageFormatException,
             ImageNotFoundException,
             SystemResourceException
Loads and constructs an image from a resource or file which contains a formatted image. See the class documentation for information on which types of formatted images the Ewe VM can decode.

The path given is the path to the image file which can be in a ewe file or on the file system.

Parameters:
path - the name of the image resource or file.
Throws:
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
ImageNotFoundException - if the image could not be found.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(ByteArray image,
             int options,
             Rect sourceArea,
             int requestedWidth,
             int requestedHeight)
      throws ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an array of bytes, optionally resizing a portion of the image during decoding if possible. If resizing during decoding is not possible, the returned image will be the full sized image. Currently resizing during decoding is only possible on a native Ewe VM decoding a JPEG formatted image.

Parameters:
image - the formatted image bytes.
options - creation options.
sourceArea - an optional area within the source image to decode - if this is null, then the entire image is used.
requestedWidth - the desired width of the decoded image - if this is zero, then the original width is used.
requestedHeight - the desired height of the decoded image - if this is zero, then the original height is used.
Throws:
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(ByteArray image,
             int options,
             int requestedWidth,
             int requestedHeight)
      throws ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an array of bytes, optionally resizing the image during decoding if possible. If resizing during decoding is not possible, the returned image will be the full sized image. Currently resizing during decoding is only possible on a native Ewe VM decoding a JPEG formatted image.

Parameters:
image - the formatted image bytes.
options - creation options.
requestedWidth - the desired width of the decoded image - if this is zero, then the original width is used.
requestedHeight - the desired height of the decoded image - if this is zero, then the original height is used.
Throws:
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(ByteArray image,
             int options)
      throws ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an array of bytes.

Parameters:
image - the formatted image bytes.
options - creation options.
Throws:
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(Stream stream,
             int options,
             Rect sourceArea,
             int requestedWidth,
             int requestedHeight)
      throws IOException,
             ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an ewe.io.Stream, optionally resizing a portion of the image during decoding if possible. If resizing during decoding is not possible, the returned image will be the full sized image. Currently resizing during decoding is only possible on a native Ewe VM decoding a JPEG formatted image.

Parameters:
stream - the formatted image bytes in a Stream.
options - creation options.
sourceArea - an optional area within the source image to decode - if this is null, then the entire image is used.
requestedWidth - the desired width of the decoded image - if this is zero, then the original width is used.
requestedHeight - the desired height of the decoded image - if this is zero, then the original height is used.
Throws:
IOException - if there was an error reading from the stream.
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(Stream stream,
             int options,
             int requestedWidth,
             int requestedHeight)
      throws IOException,
             ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an ewe.io.Stream, optionally resizing the image during decoding if possible. If resizing during decoding is not possible, the returned image will be the full sized image. Currently resizing during decoding is only possible on a native Ewe VM decoding a JPEG formatted image.

Parameters:
stream - the formatted image bytes in a Stream.
options - creation options.
requestedWidth - the desired width of the decoded image - if this is zero, then the original width is used.
requestedHeight - the desired height of the decoded image - if this is zero, then the original height is used.
Throws:
IOException - if there was an error reading from the stream.
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(Stream stream,
             int options)
      throws IOException,
             ImageDecodingException,
             UnsupportedImageFormatException,
             SystemResourceException
Use this to load a formatted image from an ewe.io.Stream.

Parameters:
stream - the formatted image bytes in a Stream.
options - creation options.
Throws:
IOException - if there was an error reading from the stream.
ImageDecodingException - if there was an error decoding the image.
UnsupportedImageFormatException - if the image format is not supported.
SystemResourceException - if the underlying system could not create the image because of system resource problems.

Image

public Image(int width,
             int height,
             int options,
             int[] pixels,
             int offset,
             int scanLineLength)
Use this to create an RGB_IMAGE or an ARGB_IMAGE from the image pixels.

Parameters:
width - The width of the image - this must be greater than 0.
height - The height of the image - this must be greater than 0.
options - The exact image type, either RGB_IMAGE or ARGB_IMAGE.
pixels - an int[] containing the pixel data.
offset - the start point of the pixel data in the array.
scanLineLength - the length of each scan line in the pixel array.

Image

public Image(int width,
             int height,
             int options,
             byte[] bits,
             int offset,
             int scanLineLength,
             int[] colorTable)
      throws IllegalArgumentException,
             SystemResourceException,
             ImageTypeNotSupportedException
Use this to create a mono, grayscale or indexed image from a the image pixel bits and the color table (for indexed images).

Parameters:
width - The width of the image - this must be greater than 0.
height - The height of the image - this must be greater than 0.
options - The exact image type, either MONO_IMAGE, or GRAY_SCALE_xxx_IMAGE or INDEXED_xxx_IMAGE.
bits - The bits for the images.
offset - The start of the bits for the images within the bits array.
scanLineLength - The number of bytes per scan line within the bits array.
colorTable - For INDEXED_xxx_IMAGE types, this is the color table as ARGB color values - but where the A value is not used. This array must be the correct length for the image type.
Throws:
IllegalArgumentException - if the image dimensions are not valid.
SystemResourceException - if the underlying system could not create the image because of system resource problems.
ImageTypeNotSupportedException - if the specified type is not supported by the system.
Method Detail

usesAlpha

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

Specified by:
usesAlpha in interface IImage

wasDecoded

public boolean wasDecoded()
Returns true if this image was decoded. A decoded image cannot be drawn to.


freeze

public void freeze()
This tells the VM that you will no longer be making changes to this Image. It gives the VM the option of caching pixel information about the Image. This is not necessary for Images that are decoded from a Formatted image representation.


enableAlpha

public boolean enableAlpha()
Use this to enable the storing of an Alpha (transparency) channel with the image data. This should only be used on an empty image - it will not work on an Image that was already loaded.

Returns:
true if alpha channel has been set up.

setSize

protected void setSize(ImageCodec ic,
                       Rect sourceArea,
                       int requestedWidth,
                       int requestedHeight,
                       int options)

getImageInfo

public static ImageInfo getImageInfo(ByteArray imageBytes,
                                     ImageInfo destination)
                              throws IllegalArgumentException
Get the information on an Image as stored in a formatted form.

Parameters:
imageBytes - The bytes for the image.
destination - An optional destination ImageInfo object.
Returns:
An ImageInfo object holding information on the image.
Throws:
IllegalArgumentException - If the image bytes is a corrupted or not recognized format.

getImageInfo

public static ImageInfo getImageInfo(Stream imageBytes,
                                     ImageInfo destination)
                              throws IllegalArgumentException,
                                     IOException
Get the information on an Image as stored in a formatted form.

Parameters:
imageBytes - The bytes for the image.
destination - An optional destination ImageInfo object.
Returns:
An ImageInfo object holding information on the image.
Throws:
IllegalArgumentException - If the image bytes is a corrupted or not recognized format.
IOException

setPixels

public void setPixels(int bitsPerPixel,
                      int[] colorMap,
                      int bytesPerRow,
                      int numRows,
                      int y,
                      Object pixels)
Deprecated. - Use the other setPixels() instead.

Sets one or more row(s) of pixels in an image. This method sets the values of a number of pixel rows in an image and is commonly used when writing code to load an image from a stream such as a file. The source pixels byte array must be in 1, 4 or 8 bit per pixel format with a matching color map size of 2, 16 or 256 colors.

Each color in the color map of the source pixels is identified by a single integer value. The integer is composed of 8 bits (value [0..255]) of red, green and blue using the following calculation:

 int color = (red << 16) | (green << 8) | blue;
 
As an example, to load a 16 color image, we would pass bitsPerPixel as 4 and would create a int array of 16 values for the color map. Then we would set each of the values in the color map to the colors used using the equation above. We could then either read data line by line from the source stream, calling this method for each row of pixels or could read a number of rows at once and then call this method to set the pixels.

The former approach uses less memory, the latter approach is faster.

Parameters:
bitsPerPixel - bits per pixel of the source pixels (1, 4 or 8) for index images, 32 for true color ARGB images.
colorMap - the color map of the source pixels - must be 2, 16 or 256 in length) or it can be null for true color ARGB images.
bytesPerRow - number of bytes per row of pixels in the source pixels array
numRows - the number of rows of pixels in the source pixels array
y - y coordinate in the image to start setting pixels
pixels - array containing the source pixels - for true color ARGB images this can be an array of integers. For indexed images it should be an array of bytes.

free

public void free()
Sets the image width and height to 0 and frees any systems resources associated with the image.

Specified by:
free 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

getWidth

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

Specified by:
getWidth in interface IImage

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

setPixels

public void setPixels(int[] source,
                      int offset,
                      int x,
                      int y,
                      int width,
                      int height,
                      int options)
Sets a block of pixels in ARGB integer values. Each value in the source array represents a single pixel in Alpha-Red-Green-Blue format (8-bits per color). "offset" is the start of the int values in the array. x,y,width,height specify the rectangle that the pixels cover (a height of 1 represents a single line of pixels). At the moment, no options are defined.


getPixels

public int[] getPixels(int[] dest,
                       int offset,
                       int x,
                       int y,
                       int width,
                       int height,
                       int options)
Gets a block of pixels in ARGB integer values. Each value put in the destination array represents a single pixel in Alpha-Red-Green-Blue format (8-bits per color). "offset" is the start of the int values in the array. x,y,width,height specify the rectangle that the pixels cover (a height of 1 represents a single line of pixels). At the moment, no options are defined.

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.

invert

public static Image invert(Image what)
Get a new Image that is the inverse of the specified image.


toIcon

public Object toIcon(Image mask)
Create a native Icon object. This will create a native Icon reference which can be used for any system calls that require a native Icon. For this to work the image must be defined with all pixels that are to be transparent being white. Other pixels that are not to be transparent can also be white. The mask must be loaded from a monochrome ".bmp" file and it should be black where the icon is not to be transparent and white where it is to be transparent.

Parameters:
mask - An image that is used as a mask for this image to define the transparent area of the icon.
Returns:
An Object which can be passed to any method that requires a native icon reference. It will return null if an icon could not be made.

toNativeImage

public Object toNativeImage(Object colorOrMask)
Create a platform specific version of this image. Under Win32 or Linux this returns itself. Under Java it returns a java.awt.Image.

Returns:
a native version of the image.

getNativeResource

public Object getNativeResource()
Return an Object that holds a reference to the native resource used by the Image. On a Java VM this will be a java.awt.Image, while on other platforms this will be an ewe.sys.Long() object which contains a 32-bit pointer to a platform specific structure. The structure will be defined in the "eni.h" and will allow you to access the image bits directly.


toIcon

public static Object toIcon(String imageName,
                            String maskName)
Create a native Icon given the name of an Image and the name of its mask. The mask must be a monochrome BMP file. The images created are freed and only the native Icon itself is returned.

Parameters:
imageName - The name of the image.
maskName - The name of the mask
Returns:
a native Icon.

fixMasks

protected static void fixMasks(Image image,
                               Image mask,
                               Color c)

makeGray

public void makeGray(Color transparent)

rotate

public Image rotate(Image destination,
                    int degree)
This rotates the image and places it into the destination Image (which should) be the correct size to receive the rotated image. If the destination Image is null a new one will be created and returned.

Parameters:
destination - The destination image. If it is null it will return a new Image.
degree - This should be 90 for a 90 degree clockwise rotation, 180 for 180 degree rotation or 270 for 270 degree clockwise rotation (or 90 degree anti-clockwise rotation).
Returns:
The destination image or a new Image if destination was null.

scale

public Image scale(int newWidth,
                   int newHeight)

scaleStrip

public Image scaleStrip(int newWidth,
                        int newHeight,
                        int destOptions,
                        int yOffset,
                        int height,
                        Image destination)

scale

public Image scale(int newWidth,
                   int newHeight,
                   int destOptions)

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 destArray,
                              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 sourceArray,
                              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

getImageWidth

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

getImageHeight

public int getImageHeight()
Specified by:
getImageHeight 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

getImageType

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

Specified by:
getImageType in interface ImageData

getImageBits

public byte[] getImageBits()

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