|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.fx.Image
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 |
public Color transparent
public Color background
public String name
public boolean freed
public boolean hasAlpha
public static final int TRUE_COLOR
public static final int ALPHA_CHANNEL
public static final int RGB_IMAGE
public static final int ARGB_IMAGE
public static final int INDEXED
public static final int INDEXED_IMAGE
public static final int FOR_DISPLAY
public static final int SCALE_IMAGE
public static final int MONO_IMAGE
public static final int BLACK_AND_WHITE_IMAGE
public static final int GRAY_SCALE_IMAGE
public static final int GRAY_SCALE_256_IMAGE
public static final int GRAY_SCALE_16_IMAGE
public static final int GRAY_SCALE_4_IMAGE
public static final int GRAY_SCALE_2_IMAGE
public static final int INDEXED_256_IMAGE
public static final int INDEXED_16_IMAGE
public static final int INDEXED_4_IMAGE
public static final int INDEXED_2_IMAGE
public static final int FASTEST_DISPLAY_IMAGE
public static final int EXACT_TYPE_IMAGE
public static int debugImageSize
public static int numImages
public static boolean debugImages
| Constructor Detail |
protected Image()
public Image(int width,
int height,
int options)
throws IllegalArgumentException,
SystemResourceException,
ImageTypeNotSupportedException
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).
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
public Image(int width,
int height)
throws IllegalArgumentException,
SystemResourceException,
ImageTypeNotSupportedException
width - The width of the image. This must be greater than 0.height - The height of the image. This must be greater than 0.
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
public Image(Image other,
int options)
throws SystemResourceException
other - The image to copy.options - Options used when creating the new image.
SystemResourceException - if the underlying system could not create
the image because of system resource problems.
public Image(Object nativeImage,
int options)
throws IllegalArgumentException,
SystemResourceException
nativeImage - an appropriate native image.options - options for image creation.
IllegalArgumentException - if the nativeImage is not appropriate.
SystemResourceException - if the underlying system could not create the image because of system resource problems.
public Image(String path,
int options)
throws ImageDecodingException,
UnsupportedImageFormatException,
ImageNotFoundException,
SystemResourceException
The path given is the path to the image file which can be in a ewe file or on the file system.
path - the name of the image resource or file.options - creation options.
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.
public Image(String path)
throws ImageDecodingException,
UnsupportedImageFormatException,
ImageNotFoundException,
SystemResourceException
The path given is the path to the image file which can be in a ewe file or on the file system.
path - the name of the image resource or file.
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.
public Image(ByteArray image,
int options,
Rect sourceArea,
int requestedWidth,
int requestedHeight)
throws ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
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.
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.
public Image(ByteArray image,
int options,
int requestedWidth,
int requestedHeight)
throws ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
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.
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.
public Image(ByteArray image,
int options)
throws ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
image - the formatted image bytes.options - creation options.
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.
public Image(Stream stream,
int options,
Rect sourceArea,
int requestedWidth,
int requestedHeight)
throws IOException,
ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
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.
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.
public Image(Stream stream,
int options,
int requestedWidth,
int requestedHeight)
throws IOException,
ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
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.
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.
public Image(Stream stream,
int options)
throws IOException,
ImageDecodingException,
UnsupportedImageFormatException,
SystemResourceException
stream - the formatted image bytes in a Stream.options - creation options.
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.
public Image(int width,
int height,
int options,
int[] pixels,
int offset,
int scanLineLength)
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.
public Image(int width,
int height,
int options,
byte[] bits,
int offset,
int scanLineLength,
int[] colorTable)
throws IllegalArgumentException,
SystemResourceException,
ImageTypeNotSupportedException
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.
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 |
public boolean usesAlpha()
IImage
usesAlpha in interface IImagepublic boolean wasDecoded()
public void freeze()
public boolean enableAlpha()
protected void setSize(ImageCodec ic,
Rect sourceArea,
int requestedWidth,
int requestedHeight,
int options)
public static ImageInfo getImageInfo(ByteArray imageBytes,
ImageInfo destination)
throws IllegalArgumentException
imageBytes - The bytes for the image.destination - An optional destination ImageInfo object.
IllegalArgumentException - If the image bytes is a corrupted or not recognized format.
public static ImageInfo getImageInfo(Stream imageBytes,
ImageInfo destination)
throws IllegalArgumentException,
IOException
imageBytes - The bytes for the image.destination - An optional destination ImageInfo object.
IllegalArgumentException - If the image bytes is a corrupted or not recognized format.
IOException
public void setPixels(int bitsPerPixel,
int[] colorMap,
int bytesPerRow,
int numRows,
int y,
Object pixels)
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.
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 arraynumRows - the number of rows of pixels in the source pixels arrayy - y coordinate in the image to start setting pixelspixels - 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.public void free()
free in interface IImagepublic int getHeight()
IImage
getHeight in interface IImagepublic int getWidth()
IImage
getWidth in interface IImagepublic Color getBackground()
IImage
getBackground in interface IImage
public void draw(Graphics g,
int x,
int y,
int options)
IImage
draw in interface IImage
public void setPixels(int[] source,
int offset,
int x,
int y,
int width,
int height,
int options)
public int[] getPixels(int[] dest,
int offset,
int x,
int y,
int width,
int height,
int options)
getPixels in interface IImagedest - 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.
public static Image invert(Image what)
public Object toIcon(Image mask)
mask - An image that is used as a mask for this image to define the transparent area of the icon.
public Object toNativeImage(Object colorOrMask)
public Object getNativeResource()
public static Object toIcon(String imageName,
String maskName)
imageName - The name of the image.maskName - The name of the mask
protected static void fixMasks(Image image,
Image mask,
Color c)
public void makeGray(Color transparent)
public Image rotate(Image destination,
int degree)
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).
public Image scale(int newWidth,
int newHeight)
public Image scaleStrip(int newWidth,
int newHeight,
int destOptions,
int yOffset,
int height,
Image destination)
public Image scale(int newWidth,
int newHeight,
int destOptions)
public int getImageScanLineType()
ImageData
getImageScanLineType in interface ImageDatapublic int getImageScanLineLength()
ImageData
getImageScanLineLength in interface ImageData
public void getImageScanLines(int startLine,
int numLines,
Object destArray,
int offset,
int destScanLineLength)
ImageData
getImageScanLines in interface ImageData
public void setImageScanLines(int startLine,
int numLines,
Object sourceArray,
int offset,
int sourceScanLineLength)
ImageData
setImageScanLines in interface ImageDatapublic int getImageWidth()
getImageWidth in interface ImageDatapublic int getImageHeight()
getImageHeight in interface ImageDatapublic boolean isWritableImage()
ImageData
isWritableImage in interface ImageDatapublic int getImageType()
ImageData
getImageType in interface ImageDatapublic byte[] getImageBits()
public int[] getImageColorTable()
ImageData
getImageColorTable in interface ImageData
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||