|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.Image com.sun.lwuit.RGBImage
public class RGBImage
An image that stores its data as an integer RGB array internally, this image cannot be manipulated via Graphics primitives however its array is accessible and modifiable programmatically. This is very useful for 2 distinct use cases.
The first use case allows us to manipulate images in a custom way while still preserving alpha information where applicable.
The second use case allows us to store images in the Java heap which is useful for some constrained devices. In small devices images are often stored in a separate "heap" which runs out eventually, this allows us to place the image in the Java heap which is potentially more wasteful but might sometimes be more abundant.
Note that unless specified otherwise most methods inherited from Image will fail when invoked on this subclass often with a NullPointerException. This image can be drawn on graphics as usual
Constructor Summary | |
---|---|
RGBImage(Image img)
Converts an image to an RGB image after which the original image can be GC'd |
|
RGBImage(int[] rgb,
int width,
int height)
Creates an RGB image from scratch the array isn't copied and can be saved and manipulated |
Method Summary | |
---|---|
protected void |
drawImage(Graphics g,
java.lang.Object nativeGraphics,
int x,
int y)
Callback invoked internally by LWUIT to draw the image/frame onto the display. |
Graphics |
getGraphics()
This method is unsupported in this image type |
int |
getHeight()
Returns the height of the image |
int[] |
getRGB()
Returns a mutable array that can be used to change the appearance of the image arranged as AARRGGBB. |
int |
getWidth()
Returns the width of the image |
boolean |
isOpaque()
Indicates if an image should be treated as opaque, this can improve support for fast drawing of RGB images without alpha support. |
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 |
rotate(int degrees)
Unsupported in the current version, this method will be implemented in a future release |
void |
scale(int width,
int height)
Scale the image to the given width and height, this is a fast algorithm that preserves translucent information |
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. |
void |
setOpaque(boolean opaque)
|
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. |
Methods inherited from class com.sun.lwuit.Image |
---|
animate, applyMask, applyMask, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, drawImage, getImage, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isAnimation, isSVG, isSVGSupported, lock, modifyAlpha, modifyAlphaWithTranslucency, scaledHeight, scaledSmallerRatio, scaledWidth, toRGB, unlock |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RGBImage(Image img)
img
- the image to convert to an RGB imagepublic RGBImage(int[] rgb, int width, int height)
rgb
- AARRGGBB arraywidth
- width of imageheight
- height of imageMethod Detail |
---|
public 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 cutting
public Image scaled(int width, int height)
Image
scaled
in class Image
width
- width for the scalingheight
- height of the scaled image
public void scale(int width, int height)
Image
scale
in class Image
width
- width for the scalingheight
- height of the scaled imagepublic Image rotate(int degrees)
rotate
in class Image
degrees
- A degree in right angle must be larger than 0 and up to 359 degrees
public Image modifyAlpha(byte alpha)
Image
modifyAlpha
in class Image
alpha
- New value for the entire alpha channel
public Graphics getGraphics()
getGraphics
in class Image
public int[] getRGB()
getRGB
in class Image
protected void drawImage(Graphics g, java.lang.Object nativeGraphics, int x, int y)
Image
drawImage
in class Image
g
- the graphics objectnativeGraphics
- the underlying native graphics which might be essential for some image typesx
- the x coordinatey
- the y coordinatepublic void setOpaque(boolean opaque)
public boolean isOpaque()
isOpaque
in class Image
public int getWidth()
Image
getWidth
in class Image
public int getHeight()
Image
getHeight
in class Image
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |