public class Image extends ImageObject implements ISurface
Modifier and Type | Field and Description |
---|---|
static int |
OPTION_FOR_DISPLAY |
static int |
OPTION_WITH_ALPHA_CHANNEL |
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 options,
Object nativeObject) |
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.
|
protected void |
finalize()
This method (when overriden), will be called when the VM determines that the Object can be
garbage collected.
|
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.
|
static ImageInfo |
getImageInfo(FormattedDataSource source,
ImageInfo destination) |
void |
getImageScanLines(int startLine,
int numLines,
Object destArray,
int offset,
int destScanLineLength)
This optimizes an Image for fast display if possible without losing color quality.
|
Object |
getNativeDrawable()
This is used internally and should not be used.
|
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()
Returns if you can write data to the ImageData.
|
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.
|
Image |
setMask(Mask m)
Assign a Mask to the Image specifying fully opaque and fully transparent areas.
|
boolean |
setPixels(int[] sourcePixels,
int offset,
int x,
int y,
int width,
int height,
int rowStride)
Set a block of pixels within the Image with specified RGB/ARGB
pixel data provided as int values (one int value per pixel)
|
Picture |
toPicture() |
Picture |
toPicture(Object maskObject) |
boolean |
usesAlpha()
Returns whether the image uses the Alpha channel.
|
createImageFor, draw, draw, freeImage, getBackground, getCompatibleImagePoints, getDPI, getHeight, getImageColorTable, getImageData, getImageHeight, getImageScanLineLength, getImageScanLineType, getImageType, getImageWidth, getPixelsUsingScanLines, getScanLinesUsingPixels, getWidth, isReadableImage, scanLinesComplete, setPixelsUsingScanLines, setScanLinePixels, setScanLinesUsingPixels
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCompatibleImagePoints, getDPI
public static final int OPTION_FOR_DISPLAY
public static final int OPTION_WITH_ALPHA_CHANNEL
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 Image(int options, Object nativeObject)
public int getSurfaceType()
ISurface
getSurfaceType
in interface ISurface
public FontMetrics getFontMetrics(Font f)
ISurface
getFontMetrics
in interface ISurface
f
- the Font to use.public Graphics newGraphics()
public void free()
free
in interface Drawable
free
in class ImageObject
protected void finalize()
Object
The finalize() method of a Class is only called if it overrides finalize() - the finalize() method java.lang.Object is never called by the Eve VM.
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 usesAlpha()
IImage
public boolean isWriteableImage()
ImageData
isWriteableImage
in interface ImageData
public Image setMask(Mask m) throws IllegalArgumentException
m
- a Mask to use. All bits in the Mask with a '1' will be considered to be fully opaque,
all bits with a '0' will be considered to be transparent.IllegalArgumentException
public boolean setPixels(int[] sourcePixels, int offset, int x, int y, int width, int height, int rowStride) throws IllegalStateException
setPixels
in interface ImageData
sourcePixels
- the array containing the pixel values.offset
- the start of the pixel data in the source array.x
- the x position of the block in the image.y
- the y position of the block in the image.width
- the width of the block in the image.height
- the height of the block in the image.rowStride
- the number of int values between scan lines
in the sourcePixels array. If this is zero it is assumed to
be the same as the width parameter.IllegalStateException
- if data cannot be written to
the image.public void draw(Graphics g, int x, int y, int options)
public Picture toPicture(Object maskObject) throws IllegalArgumentException
IllegalArgumentException
public Picture toPicture()
public Object getNativeDrawable()
ISurface
getNativeDrawable
in interface ISurface
getNativeDrawable
in class ImageObject
public void getImageScanLines(int startLine, int numLines, Object destArray, int offset, int destScanLineLength) throws IllegalStateException
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 Graphics getGraphics()
ISurface
getGraphics
in interface ISurface
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 static ImageInfo getImageInfo(FormattedDataSource source, ImageInfo destination) throws IOException
IOException