public class Image extends Object
Modifier and Type | Field and Description |
---|---|
boolean |
shownWarningForTooSmallBackgroundImage
Used in Component.BGPainter.paint() for warning on too small
background image.
|
Modifier | Constructor and Description |
---|---|
protected |
Image() |
protected |
Image(Image img,
Void v) |
protected |
Image(Object image)
Subclasses may use this and point to an underlying native image which might be
null for a case of an image that doesn't use native drawing
|
Modifier and Type | Method and Description |
---|---|
boolean |
animate() |
Image |
applyMask(Object mask)
Applies the given alpha mask onto this image and returns the resulting image
see the createMask method for indication on how to convert an image into an alpha
mask.
|
Image |
applyMask(Object mask,
int x,
int y)
Applies the given alpha mask onto this image and returns the resulting image
see the createMask method for indication on how to convert an image into an alpha
mask.
|
static Image |
createImage(byte[] bytes,
int offset,
int len)
creates an image from a given byte array data
|
static Image |
createImage(InputStream stream)
creates an image from an InputStream
|
static Image |
createImage(int[] rgb,
int width,
int height)
creates an image from an RGB image
|
static Image |
createImage(int width,
int height)
Creates a mutable image that may be manipulated using getGraphics
|
static Image |
createImage(int width,
int height,
int fillColor)
Creates a mutable image that may be manipulated using getGraphics
|
static Image |
createImage(Object nativeImage)
creates an image from the given native image (e.g.
|
static Image |
createImage(String path)
creates an image from the given path based on MIDP's createImage(path)
|
static Image |
createIndexed(int width,
int height,
int[] palette,
byte[] data)
Creates an indexed image with byte data this method may return a native indexed image rather than
an instance of the IndexedImage class
|
Object |
createMask()
Creates a mask from the given image, a mask can be used to apply an arbitrary
alpha channel to any image.
|
static Image |
createSVG(String baseURL,
boolean animated,
byte[] data)
Creates an SVG Image from the given byte array data and the base URL, this method
will throw an exception if SVG is unsupported.
|
protected void |
drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)
Callback invoked internally by LWUIT to draw the image/frame onto the display.
|
Graphics |
getGraphics()
If this is a mutable image a graphics object allowing us to draw on it
is returned.
|
int |
getHeight()
Returns the height of the image
|
Object |
getImage()
Returns the platform specific image implementation, warning the
implementation class can change between revisions of LWUIT and platforms.
|
int[] |
getRGB()
Returns the content of this image as a newly created ARGB array.
|
protected void |
getRGB(int[] rgbData,
int offset,
int scanWidth,
int x,
int y,
int width,
int height)
Obtains ARGB pixel data from the specified region of this image and
stores it in the provided array of integers.
|
int[] |
getRGBCached()
Returns the content of this image as a newly created ARGB array or a cached
instance if possible.
|
Object |
getSVGDocument()
Returns a platform specific DOM object that can be manipulated by the user
to change the SVG Image
|
int |
getWidth()
Returns the width of the image
|
static boolean |
isAlphaMutableImageSupported()
Returns true if mutable images support alpha transparency
|
boolean |
isAnimation()
Returns true if this is an animated image
|
boolean |
isOpaque()
Indicates whether this image is opaque or not
|
boolean |
isSVG()
Indicates if this image represents an SVG file or a bitmap file
|
static boolean |
isSVGSupported()
Indicates whether the underlying platform supports creating an SVG Image
|
Image |
modifyAlpha(byte alpha)
Creates a new image instance with the alpha channel of opaque/translucent
pixels within the image using the new alpha value.
|
Image |
modifyAlpha(byte alpha,
int removeColor)
Creates a new image instance with the alpha channel of opaque/translucent
pixels within the image using the new alpha value.
|
Image |
modifyAlphaWithTranslucency(byte alpha)
Creates a new image instance with the alpha channel of opaque
pixels within the image using the new alpha value.
|
Image |
rotate(int degrees)
Returns an instance of this image rotated by the given number of degrees.
|
void |
scale(int width,
int height)
Deprecated.
scale should return an image rather than modify the image in place
use scaled(int, int) instead
|
Image |
scaled(int width,
int height)
Returns a scaled version of this image image using the given width and height,
this is a fast algorithm that preserves translucent information.
|
Image |
scaledHeight(int height)
Scales the image to the given height while updating the width based on the
aspect ratio of the height
|
Image |
scaledSmallerRatio(int width,
int height)
Scales the image while maintaining the aspect ratio to the smaller size
image
|
Image |
scaledWidth(int width)
Scales the image to the given width while updating the height based on the
aspect ratio of the width
|
Image |
subImage(int x,
int y,
int width,
int height,
boolean processAlpha)
Extracts a subimage from the given image allowing us to breakdown a single large image
into multiple smaller images in RAM, this actually creates a standalone version
of the image for use.
|
protected void |
tileRect(Graphics g,
Object nativeGraphics,
int x,
int y,
int rect_width,
int rect_height)
Callback invoked internally by LWUIT to draw tiles over the image/frame
onto the display.
|
void |
toRGB(RGBImage image,
int destX,
int destY,
int x,
int y,
int width,
int height)
Extracts data from this image into the given RGBImage
|
public boolean shownWarningForTooSmallBackgroundImage
protected Image()
protected Image(Object image)
image
- native image object passed to the LWUIT implementationpublic static boolean isSVGSupported()
public Object getSVGDocument()
public static Image createSVG(String baseURL, boolean animated, byte[] data) throws IOException
baseURL
- URL which is used to resolve relative references within the SVG fileanimated
- indicates if the SVG features an animationdata
- the conten of the SVG fileIOException
- if resource lookup fail SVG is unsupportedpublic boolean isSVG()
public Object createMask()
public Image applyMask(Object mask, int x, int y)
mask
- mask object created by the createMask() method.x
- starting x where to apply the masky
- starting y where to apply the maskpublic Image applyMask(Object mask)
mask
- mask object created by the createMask() method.IllegalArgumentException
- if the image size doesn't match the mask sizepublic Image subImage(int x, int y, int width, int height, boolean processAlpha)
x
- the x offset from the imagey
- the y offset from the imagewidth
- the width of internal imagesheight
- the height of internal imagesprocessAlpha
- whether alpha should be processed as well as part of the cuttingpublic Image rotate(int degrees)
E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90 and then rotate the 45 to another 90 degrees to achieve the same effect with less memory.
degrees
- A degree in right angle must be larger than 0 and up to 359 degreespublic static Image createIndexed(int width, int height, int[] palette, byte[] data)
width
- image widthheight
- image heightpalette
- the color palette to use with the byte datadata
- byte data containing palette offsets to map to ARGB colorspublic Image modifyAlpha(byte alpha)
alpha
- New value for the entire alpha channelpublic Image modifyAlphaWithTranslucency(byte alpha)
alpha
- New value for the entire alpha channelpublic Image modifyAlpha(byte alpha, int removeColor)
alpha
- New value for the entire alpha channelremoveColor
- pixels matching this color are made transparent (alpha channel ignored)public static Image createImage(String path) throws IOException
path
- IOException
public static Image createImage(Object nativeImage)
nativeImage
- public static Image createImage(InputStream stream) throws IOException
stream
- a given InputStreamIOException
public static Image createImage(int[] rgb, int width, int height)
rgb
- the RGB image array datawidth
- the image widthheight
- the image heightpublic static Image createImage(int width, int height)
width
- the image widthheight
- the image heightpublic static boolean isAlphaMutableImageSupported()
public static Image createImage(int width, int height, int fillColor)
width
- the image widthheight
- the image heightfillColor
- the color with which the image should be initially filledpublic static Image createImage(byte[] bytes, int offset, int len)
bytes
- the array of image data in a supported image formatoffset
- the offset of the start of the data in the arraylen
- the length of the data in the arraypublic Graphics getGraphics()
public int getWidth()
public int getHeight()
protected void tileRect(Graphics g, Object nativeGraphics, int x, int y, int rect_width, int rect_height)
nativeGraphics
- the underlying native graphics which might
be essential for some image typesx
- the x coordinatey
- the y coordinateprotected void drawImage(Graphics g, Object nativeGraphics, int x, int y)
g
- the graphics objectnativeGraphics
- the underlying native graphics which might be essential for some image typesx
- the x coordinatey
- the y coordinateprotected void getRGB(int[] rgbData, int offset, int scanWidth, int x, int y, int width, int height)
rgbData
- an array of integers in which the ARGB pixel data is
storedoffset
- the index into the array where the first ARGB value is
storedscanwidth
- the scan width of the target array (rgbData)scanlength
- the relative offset in the array between
corresponding pixels in consecutive rows of the regionx
- the x-coordinate of the upper left corner of the regiony
- the y-coordinate of the upper left corner of the regionwidth
- the width of the regionheight
- the height of the regionpublic void toRGB(RGBImage image, int destX, int destY, int x, int y, int width, int height)
image
- RGBImage that would receive pixel datadestX
- x location within RGBImage into which the data will
be writtendestY
- y location within RGBImage into which the data will
be writtenx
- location within the source imagey
- location within the source imagewidth
- size of the image to extract from the source imageheight
- size of the image to extract from the source imagepublic int[] getRGB()
public int[] getRGBCached()
public Image scaledWidth(int width)
width
- the given new image widthpublic Image scaledHeight(int height)
height
- the given new image heightpublic Image scaledSmallerRatio(int width, int height)
width
- the given new image widthheight
- the given new image heightpublic Image scaled(int width, int height)
width
- width for the scalingheight
- height of the scaled imagepublic Object getImage()
public void scale(int width, int height)
width
- width for the scalingheight
- height of the scaled imagepublic boolean isAnimation()
public boolean animate()
public boolean isOpaque()