|
||||||||||
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.EncodedImage
public class EncodedImage
An image that only keeps the binary data of the source file used to load it in permanent memory. This allows the bitmap to get collected while the binary data remains, a weak reference is used for caching.
Constructor Summary | |
---|---|
protected |
EncodedImage(int width,
int height)
Allows subclasses to create more advanced variations of this class that lazily store the data in an arbitrary location. |
Method Summary | |
---|---|
static EncodedImage |
create(byte[] data)
Creates an image from the given byte array |
static EncodedImage |
create(java.io.InputStream i)
Creates an image from the input stream |
static EncodedImage |
create(java.lang.String i)
Creates an image from the input stream |
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. |
protected void |
drawImage(Graphics g,
java.lang.Object nativeGraphics,
int x,
int y,
int w,
int h)
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 |
byte[] |
getImageData()
Returns the byte array data backing the image allowing the image to be stored and discarded completely from RAM. |
protected Image |
getInternal()
Returns the actual image represented by the encoded image, this image will be cached in a weak/soft reference internally. |
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 |
void |
lock()
This callback indicates that a component pointing at this image is initialized, this allows an image to make performance sensitive considerations e.g. an encoded image might choose to cache itself in RAM. |
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. |
protected void |
resetCache()
A subclass might choose to load asynchroniously and reset the cache when the image is ready. |
Image |
rotate(int degrees)
Returns an instance of this image rotated by the given number of degrees. |
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. |
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. |
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 |
void |
unlock()
This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times. |
Methods inherited from class com.sun.lwuit.Image |
---|
animate, applyMask, applyMask, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, getImage, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isSVG, isSVGSupported, modifyAlphaWithTranslucency |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected EncodedImage(int width, int height)
width
- -1 if unknown ideally the width/height should be known in advanceheight
- -1 if unknown ideally the width/height should be known in advanceMethod Detail |
---|
protected void resetCache()
public byte[] getImageData()
public static EncodedImage create(byte[] data)
data
- the data of the image
public static EncodedImage create(java.io.InputStream i) throws java.io.IOException
i
- the input stream
java.io.IOException
- if thrown by the input streamprotected Image getInternal()
public void lock()
Image
lock
in class Image
public void unlock()
Image
unlock
in class Image
public static EncodedImage create(java.lang.String i) throws java.io.IOException
i
- the resource
java.io.IOException
- if thrown by the input streampublic 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 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.
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 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 Graphics getGraphics()
Image
getGraphics
in class Image
public int getWidth()
Image
getWidth
in class Image
public int getHeight()
Image
getHeight
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 coordinateprotected void drawImage(Graphics g, java.lang.Object nativeGraphics, int x, int y, int w, int h)
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 coordinatew
- the width to occupyh
- the height to occupypublic 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 Image scaledWidth(int width)
Image
scaledWidth
in class Image
width
- the given new image width
public Image scaledHeight(int height)
Image
scaledHeight
in class Image
height
- the given new image height
public Image scaledSmallerRatio(int width, int height)
Image
scaledSmallerRatio
in class Image
width
- the given new image widthheight
- the given new image height
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 boolean isAnimation()
Image
isAnimation
in class Image
public boolean isOpaque()
Image
isOpaque
in class Image
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |