public class RGBImage extends Image
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
protected void |
drawImage(Graphics g,
Object nativeGraphics,
int x,
int y)
Callback invoked internally by Codename One 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.
|
boolean |
requiresDrawImage()
New label optimizations don't invoke drawImage and instead just pass the native image directly to
the underlying renderer.
|
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.
|
addActionListener, animate, applyMask, applyMask, applyMaskAutoScale, asyncLock, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, drawImage, exifRotation, exifRotation, exifRotation, fill, fireChangedEvent, flipHorizontally, flipVertically, getExifOrientationTag, getExifOrientationTag, getImage, getImageName, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isAnimation, isJPEG, isLocked, isPNG, isSVG, isSVGSupported, lock, mirror, modifyAlpha, modifyAlphaWithTranslucency, removeActionListener, rotate180Degrees, rotate270Degrees, rotate90Degrees, scaledHeight, scaledLargerRatio, scaledSmallerRatio, scaledWidth, setImageName, toRGB, unlock
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 imagepublic Image subImage(int x, int y, int width, int height, boolean processAlpha)
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 scaled(int width, int height)
public void scale(int width, int height)
public Image rotate(int degrees)
public Image modifyAlpha(byte alpha)
modifyAlpha
in class Image
alpha
- New value for the entire alpha channelpublic Graphics getGraphics()
getGraphics
in class Image
public int[] getRGB()
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y)
public void setOpaque(boolean opaque)
public boolean isOpaque()
public int getWidth()
public int getHeight()
public boolean requiresDrawImage()
requiresDrawImage
in class Image