public class Image extends ImageObject implements ISurface
Modifier and Type | Field and Description |
---|---|
static boolean |
debugImages |
background, height, width
IMAGE_SURFACE, PRINTERJOB_SURFACE, WINDOW_SURFACE
CREATE_OPTION_DONT_SCALE_UP, CREATE_OPTION_IGNORE_ALPHA, CREATE_OPTION_KEEP_ASPECT_RATIO, CREATE_OPTION_ROUGH_SCALING, 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_MASK, TYPE_MONO, TYPE_RGB, TYPE_UNKNOWN
Constructor and Description |
---|
Image(Image other,
int options) |
Image(int width,
int height) |
Image(int width,
int height,
int typeAndOptions) |
Image(int width,
int height,
int typeAndOptions,
Object data,
int offset,
int length,
int[] colorTable) |
Image(int width,
int height,
Object compatibleWith)
Do not use this constructor - it is temporary and will be removed
in future versions.
|
Image(int options,
Object nativeObject)
Returns if the Image was decoded.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canCapture()
This returns true if it is possible to read pixel data from the surface
into an Image.
|
boolean |
canMove()
This returns true if it is possible to move pixel within the surface.
|
boolean |
captureImage(Image dest,
int x,
int y,
int width,
int height)
Capture pixel data from the surface to an Image.
|
void |
draw(Graphics g,
int x,
int y,
int options) |
void |
drawImage(Image src,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
int destX,
int destY,
int width,
int height)
This should always work for any surface and is the minimum functionality
expected.
|
void |
free() |
Image |
getCompatibleImage(int width,
int height)
Get an Image that is optimized for display on the surface.
|
FontMetrics |
getFontMetrics(Font f)
Return a FontMetrics for the surface.
|
Graphics |
getGraphics()
This returns a new Graphics for use on the surface IF it is supported.
|
int[] |
getImageColorTable()
For indexed images, this retrieves the color table as an array of ARGB integers.
|
static ImageInfo |
getImageInfo(FormattedDataSource source,
ImageInfo destination)
Get information about a possible image file.
|
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[] |
getPixels(int[] dest,
int offset,
int x,
int y,
int width,
int height,
int rowStride)
Retrieve the pixels from the Image in encoded ARGB values.
|
int |
getSurfaceType()
This returns one of the XXX_SURFACE values.
|
boolean |
isWriteableImage()
This always returns true for an Image.
|
boolean |
moveImage(int srcX,
int srcY,
int srcWidth,
int srcHeight,
int destX,
int destY)
Move pixel data within the surface.
|
Graphics |
newGraphics() |
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.
|
boolean |
setPixels(int[] src,
int offset,
int x,
int y,
int width,
int height,
int rowStride)
Set the pixels in the IImage in encoded ARGB values.
|
Picture |
toPicture() |
Picture |
toPicture(Object maskObject) |
boolean |
usesAlpha()
Returns whether the image uses the Alpha channel.
|
createImageFor, draw, draw, freeImage, getBackground, getCompatibleImagePoints, getDPI, getHeight, getImageData, getImageHeight, getImageWidth, getNativeDrawable, getPixelsUsingScanLines, getScanLinesUsingPixels, getWidth, isReadableImage, scanLinesComplete, setPixelsUsingScanLines, setScanLinePixels, setScanLinesUsingPixels
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCompatibleImagePoints, getDPI, getNativeDrawable
public Image(int options, Object nativeObject)
public Image(int width, int height, Object compatibleWith) throws SystemResourceException
SystemResourceException
public Image(int width, int height, int typeAndOptions) throws SystemResourceException
SystemResourceException
public Image(int width, int height, int typeAndOptions, Object data, int offset, int length, int[] colorTable) throws SystemResourceException
SystemResourceException
public Image(int width, int height)
public Image(Image other, int options)
public FontMetrics getFontMetrics(Font f)
ISurface
getFontMetrics
in interface ISurface
f
- the Font to use.public int getSurfaceType()
ISurface
getSurfaceType
in interface ISurface
public void free()
free
in interface Drawable
free
in class ImageObject
public boolean usesAlpha()
IImage
public Graphics newGraphics()
public int getImageType()
ImageData
getImageType
in interface ImageData
getImageType
in class ImageObject
public int getImageScanLineType()
ImageData
getImageScanLineType
in interface ImageData
getImageScanLineType
in class ImageObject
public int getImageScanLineLength()
ImageData
getImageScanLineLength
in interface ImageData
getImageScanLineLength
in class ImageObject
public int[] getImageColorTable()
ImageData
getImageColorTable
in interface ImageData
getImageColorTable
in class ImageObject
public void draw(Graphics g, int x, int y, int options)
public Picture toPicture(Object maskObject) throws IllegalArgumentException
IllegalArgumentException
public Picture toPicture() throws IllegalArgumentException
IllegalArgumentException
public static ImageInfo getImageInfo(FormattedDataSource source, ImageInfo destination) throws ImageDecodingException, IOException
source
- the source of the image file. This is not closed.destination
- an optional ImageInfo destination object.ImageDecodingException
- if the source is not an image file that can be decoded.IOException
- if there was any error reading the source data.public void getImageScanLines(int startLine, int numLines, Object destArray, int offset, int destScanLineLength) throws IllegalStateException
ImageData
getImageScanLines
in interface ImageData
IllegalStateException
public void setImageScanLines(int startLine, int numLines, Object sourceArray, int offset, int sourceScanLineLength) throws IllegalStateException
ImageData
setImageScanLines
in interface ImageData
IllegalStateException
public int[] getPixels(int[] dest, int offset, int x, int y, int width, int height, int rowStride)
ImageData
getPixels
in interface ImageData
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.rowStride
- the number of int values between each row in the destination int array. If this is 0 it
will be assumed to be equal to width.public boolean setPixels(int[] src, int offset, int x, int y, int width, int height, int rowStride)
ImageData
setPixels
in interface ImageData
src
- The source int array.offset
- The offset into the array to start retrieving 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.rowStride
- the number of int values between each row in the destination int array. If this is 0 it
will be assumed to be equal to width.public boolean isWriteableImage()
isWriteableImage
in interface ImageData
ImageData.isWriteableImage()
public void drawImage(Image src, int clipX, int clipY, int clipWidth, int clipHeight, int destX, int destY, int width, int height)
ISurface
Note that the image is not scaled. If width and height are smaller than the actual image dimensions, then the image is clipped.
drawImage
in interface ISurface
src
- The source image.clipX
- The x co-ordinate of the clipping rectangle within the surface.clipY
- The y co-ordinate of the clipping rectangle within the surface.clipWidth
- The width of the clipping rectangle within the surface.clipHeight
- The height of the clipping rectangle within the surface.destX
- The destination x co-ordinate for the image.destY
- The destination y co-ordinate for the image.width
- The number of pixels horizontally to draw from the image.height
- The number of pixels vertically to draw from the image.public boolean captureImage(Image dest, int x, int y, int width, int height)
ISurface
captureImage
in interface ISurface
public boolean moveImage(int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY)
ISurface
public boolean canCapture()
ISurface
canCapture
in interface ISurface
public boolean canMove()
ISurface
public Image getCompatibleImage(int width, int height) throws IllegalArgumentException
ISurface
getCompatibleImage
in interface ISurface
width
- the width of the image. This must be greater than or equal to 1.height
- the height of the image. This must be greater than or equal to 1.IllegalArgumentException
- if the width or height is less than 1.public Graphics getGraphics()
ISurface
getGraphics
in interface ISurface