public class ScaledImage extends Image
Image.scale(int, int)
always makes a scaled copy of the underlying
native image. We use this class ScaledImage to avoid this extensive copying
of pixel arrays in Java, and instead use hardware-accelerated image scaling
when possible. In our implementation, Image.scale(int, int)
returns
an instance of ScaledImage that holds a reference to the unscaled original
image. A copy is created on demand if either the scaled or the unscaled image
gets mutated (copy-on-write idiom). Therefore, a LWUIT client cannot observe
a behavioral difference between our implementation and the original LWUIT
implementation (almost ... see deviation below).
Known observable deviations from LWUIT 1.4:
- In LWUIT 1.4, the following assertion is always satisfied. This is not
the case in aicas's implementation.
image.scaled(w,h) instanceof image.getClass()
In aicas's implementation, the following assertion is satisfied instead:
image.scaled(w,h).getClass() == ScaledImage.classshownWarningForTooSmallBackgroundImage
Modifier | Constructor and Description |
---|---|
protected |
ScaledImage(Image image,
int scaledWidth,
int scaledHeight) |
Modifier and Type | Method and Description |
---|---|
boolean |
animate() |
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.
|
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.
|
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
|
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
|
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.
|
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
|
applyMask, applyMask, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, getRGB, getRGBCached, isAlphaMutableImageSupported, isSVGSupported, scaled, scaledHeight, scaledSmallerRatio, scaledWidth
protected ScaledImage(Image image, int scaledWidth, int scaledHeight)
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y)
Image
public int getWidth()
Image
public int getHeight()
Image
protected void getRGB(int[] rgbData, int offset, int scanWidth, int x, int y, int width, int height)
Image
getRGB
in class Image
rgbData
- an array of integers in which the ARGB pixel data is
storedoffset
- the index into the array where the first ARGB value is
storedx
- 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
toRGB
in class Image
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 Object getSVGDocument()
Image
getSVGDocument
in class Image
public boolean isSVG()
Image
public Image modifyAlpha(byte alpha)
Image
modifyAlpha
in class Image
alpha
- New value for the entire alpha channelpublic Image modifyAlpha(byte alpha, int removeColor)
Image
modifyAlpha
in class Image
alpha
- New value for the entire alpha channelremoveColor
- pixels matching this color are made transparent (alpha channel ignored)public Image modifyAlphaWithTranslucency(byte alpha)
Image
modifyAlphaWithTranslucency
in class Image
alpha
- New value for the entire alpha channelpublic Image subImage(int x, int y, int width, int height, boolean processAlpha)
Image
subImage
in class Image
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)
Image
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.
public Graphics getGraphics()
Image
getGraphics
in class Image
protected void tileRect(Graphics g, Object nativeGraphics, int x, int y, int rect_width, int rect_height)
Image
public Object getImage()
Image
public void scale(int width, int height)
Image
public boolean isAnimation()
Image
isAnimation
in class Image