public class Image
- Object
- Image
ImplementsActionSource
Known subtypesComponentImage, DynamicImage, EncodedImage, FontImage, GeneratedSVGImage, RGBImage, Timeline
Constructors
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 |
Methods
public static boolean isSimdOptimizationsEnabled() | Indicates whether Image SIMD optimizations are enabled. |
public static void setSimdOptimizationsEnabled(boolean enabled) | Enables or disables Image SIMD optimizations explicitly. |
public static void resetSimdOptimizationsEnabled() | Clears the explicit Image SIMD override and restores the default behavior of using SIMD whenever it is supported by the current platform. |
public static boolean isSVGSupported() | Indicates whether the underlying platform supports creating an SVG Image |
public static Image createSVG(String baseURL, boolean animated, byte[] data)
throws IOException | Creates an SVG Image from the given byte array data and the base URL, this method will throw an exception if SVG is unsupported. |
public static Image createIndexed(int width, int height, int[] palette, byte[] data) | Deprecated Creates an indexed image with byte data this method may return a native indexed image rather than an instance of the IndexedImage class |
public static Image createImage(String path)
throws IOException | Creates an image from a path. |
public static Image createImage(Object nativeImage) | Deprecated creates an image from the given native image (e.g. MIDP image object) |
public static Image createImage(InputStream stream)
throws IOException | creates an image from an InputStream |
public static Image createImage(int[] rgb, int width, int height) | creates an image from an RGB image |
public static Image createImage(int width, int height) | Creates a white opaque mutable image that may be manipulated using #getGraphics(). |
public static boolean isAlphaMutableImageSupported() | Returns true if mutable images support alpha transparency |
public static Image createImage(int width, int height, int fillColor) | Creates a mutable image that may be manipulated using #getGraphics(). |
public static Image createImage(byte[] bytes, int offset, int len) | creates an image from a given byte array data |
public static Image exifRotation(String capturedImage)
throws IOException | The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved. |
public static Image exifRotation(String capturedImage, String rotatedImage)
throws IOException | The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved. |
public static Image exifRotation(String capturedImage, String rotatedImage, int maxSize)
throws IOException | The main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved. |
public static int getExifOrientationTag(String path)
throws IOException | Gets the EXIF orientation tag of an image if it’s available. |
public static int getExifOrientationTag(InputStream is) | Gets the EXIF orientation tag of an image, if it’s available. |
public static boolean isJPEG(InputStream inputStream)
throws IOException | Very fast method to detect if the given inputStream is a JPEG image (according to its guessed mime type) |
public static boolean isPNG(InputStream inputStream)
throws IOException | Very fast method to detect if the given inputStream is a PNG image (according to its guessed mime type) |
public void asyncLock(Image internal) | Async lock is the equivalent of a lock operation, however it uses the given image as the hard cache and performs the actual image loading asynchronously. |
public 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. |
public boolean isLocked() | Returns true if the image is locked |
public void unlock() | This callback indicates that a component pointing at this image is now deinitilized This method may be invoked multiple times. |
public Object getSVGDocument() | Returns a platform specific DOM object that can be manipulated by the user to change the SVG Image |
public boolean isSVG() | Indicates if this image represents an SVG file or a bitmap file |
public Object createMask() | Creates a mask from the given image, a mask can be used to apply an arbitrary alpha channel to any image. |
public 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. |
public 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. |
public Image applyMaskAutoScale(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. |
public 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. |
public Image mirror() | Creates a mirror image for the given image which is useful for some RTL scenarios. |
public Image rotate(int degrees) | Returns an instance of this image rotated by the given number of degrees. |
public 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. |
public Image modifyAlphaWithTranslucency(byte alpha) | Creates a new image instance with the alpha channel of opaque pixels within the image using the new alpha value. |
public 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. |
public Graphics getGraphics() | If this is a mutable image a graphics object allowing us to draw on it is returned. |
public int getWidth() | Returns the width of the image |
public int getHeight() | Returns the height of the image |
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. |
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y, int w, int h) | Callback invoked internally by Codename One to draw the image/frame onto the display. |
public 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 int[] getRGB() | Returns the content of this image as a newly created ARGB array. |
public void getRGB(int[] rgbData) | Returns the content of this image in the supplied ARGB array. |
public int[] getRGBCached() | Returns the content of this image as a newly created ARGB array or a cached instance if possible. |
public Image scaledWidth(int width) | Scales the image to the given width while updating the height based on the aspect ratio of the width |
public Image scaledHeight(int height) | Scales the image to the given height while updating the width based on the aspect ratio of the height |
public Image scaledSmallerRatio(int width, int height) | Scales the image while maintaining the aspect ratio to the smaller size image |
public Image scaledLargerRatio(int width, int height) | Scales the image while maintaining the aspect ratio to the larger size image |
public 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. |
public Image fill(int width, int height) | Resizes/crops the image so that its center fills the given dimensions. |
public Object getImage() | Returns the platform specific image implementation, warning the implementation class can change between revisions of Codename One and platforms. |
public void scale(int width, int height) | Deprecated Scale the image to the given width and height, this is a fast algorithm that preserves translucent information |
public boolean isAnimation() | Returns true if this is an animated image |
public boolean animate() | Advances this image’s animation state, if it is animated. |
public boolean isOpaque() | Indicates whether this image is opaque or not |
public String getImageName() | The name of the image is set for some images mostly to ease the debugging of Codename One application |
public void setImageName(String imageName) | The name of the image is set for some images mostly to ease the debugging of Codename One application |
public void dispose() | Deprecated DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING, IT WILL CAUSE PLATFORM SPECIFC CRASHES OTHERWISE! Images dispose automatically for most cases except for very rare special cases. |
public Image rotate90Degrees(boolean maintainOpacity) | Rotates this image by 90 degrees while changing the ratio of the picture |
public Image rotate180Degrees(boolean maintainOpacity) | Rotates the image by 180 degrees |
public Image rotate270Degrees(boolean maintainOpacity) | Rotates the image by 270 degrees while changing the ratio of the picture |
public Image flipHorizontally(boolean maintainOpacity) | Flips this image on the horizontal axis |
public Image flipVertically(boolean maintainOpacity) | Flips this image on the vertical axis |
public boolean requiresDrawImage() | New label optimizations don’t invoke drawImage and instead just pass the native image directly to the underlying renderer. |
public void addActionListener(ActionListener l) | Adds ActionListener to receive action events form this source. |
public void removeActionListener(ActionListener l) | Removes ActionListener so that it will no longer receive events from this source. |
public void fireChangedEvent() |
Inherited methods
Constructor details
Image
protected Image(Object image)Parameters
imageObject- native image object passed to the Codename One implementation
Method details
isSimdOptimizationsEnabled
public static boolean isSimdOptimizationsEnabled()setSimdOptimizationsEnabled
public static void setSimdOptimizationsEnabled(boolean enabled)resetSimdOptimizationsEnabled
public static void resetSimdOptimizationsEnabled()isSVGSupported
public static boolean isSVGSupported()Returns
createSVG
public static Image createSVG(String baseURL, boolean animated, byte[] data)
throws IOExceptionParameters
baseURLString- URL which is used to resolve relative references within the SVG file
animatedboolean- indicates if the SVG features an animation
databyte[]- the conten of the SVG file
Returns
Throws
IOException- if resource lookup fail SVG is unsupported
createIndexed
public static Image createIndexed(int width, int height, int[] palette, byte[] data)Parameters
widthint- image width
heightint- image height
paletteint[]- the color palette to use with the byte data
databyte[]- byte data containing palette offsets to map to ARGB colors
createImage
public static Image createImage(String path)
throws IOExceptionParameters
pathString- If path begins with file: then the image will be loaded from FileSystemStorage. Otherwise it will load from the jar resources.
Returns
Throws
createImage
public static Image createImage(Object nativeImage)Returns
createImage
public static Image createImage(InputStream stream)
throws IOExceptionParameters
streamInputStream- a given InputStream
Returns
Throws
createImage
public static Image createImage(int[] rgb, int width, int height)Parameters
rgbint[]- the RGB image array data
widthint- the image width
heightint- the image height
Returns
createImage
public static Image createImage(int width, int height)Creates a white opaque mutable image that may be manipulated using #getGraphics().
The sample below shows this method being used to create a screenshot for sharing the image:
Form hi = new Form("ShareButton");
ShareButton sb = new ShareButton();
sb.setText("Share Screenshot");
hi.add(sb);
Image screenshot = Image.createImage(hi.getWidth(), hi.getHeight());
hi.revalidate();
hi.setVisible(true);
hi.paintComponent(screenshot.getGraphics(), true);
String imageFile = FileSystemStorage.getInstance().getAppHomePath() + "screenshot.png";
try(OutputStream os = FileSystemStorage.getInstance().openOutputStream(imageFile)) {
ImageIO.getImageIO().save(screenshot, os, ImageIO.FORMAT_PNG, 1);
} catch(IOException err) {
Log.e(err);
}
sb.setImageToShare(imageFile, "image/png");
The sample below demonstrates the drawing of a mask image to create a round image effect
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Rounder", new BorderLayout());
Label picture = new Label("", "Container");
hi.add(BorderLayout.CENTER, picture);
hi.getUnselectedStyle().setBgColor(0xff0000);
hi.getUnselectedStyle().setBgTransparency(255);
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
Image camera = FontImage.createMaterial(FontImage.MATERIAL_CAMERA, s);
hi.getToolbar().addCommandToRightBar("", camera, (ev) -> {
try {
int width = Display.getInstance().getDisplayWidth();
Image capturedImage = Image.createImage(Capture.capturePhoto(width, -1));
Image roundMask = Image.createImage(width, capturedImage.getHeight(), 0xff000000);
Graphics gr = roundMask.getGraphics();
gr.setColor(0xffffff);
gr.fillArc(0, 0, width, width, 0, 360);
Object mask = roundMask.createMask();
capturedImage = capturedImage.applyMask(mask);
picture.setIcon(capturedImage);
hi.revalidate();
} catch(IOException err) {
Log.e(err);
}
});
Parameters
widthint- the image width
heightint- the image height
Returns
isAlphaMutableImageSupported
public static boolean isAlphaMutableImageSupported()Returns
createImage
public static Image createImage(int width, int height, int fillColor)Creates a mutable image that may be manipulated using #getGraphics().
The sample below shows this method being used to create a screenshot for sharing the image:
Form hi = new Form("ShareButton");
ShareButton sb = new ShareButton();
sb.setText("Share Screenshot");
hi.add(sb);
Image screenshot = Image.createImage(hi.getWidth(), hi.getHeight());
hi.revalidate();
hi.setVisible(true);
hi.paintComponent(screenshot.getGraphics(), true);
String imageFile = FileSystemStorage.getInstance().getAppHomePath() + "screenshot.png";
try(OutputStream os = FileSystemStorage.getInstance().openOutputStream(imageFile)) {
ImageIO.getImageIO().save(screenshot, os, ImageIO.FORMAT_PNG, 1);
} catch(IOException err) {
Log.e(err);
}
sb.setImageToShare(imageFile, "image/png");
Parameters
widthint- the image width
heightint- the image height
fillColorint- the color with which the image should be initially filled
Returns
createImage
public static Image createImage(byte[] bytes, int offset, int len)Parameters
bytesbyte[]- the array of image data in a supported image format
offsetint- the offset of the start of the data in the array
lenint- the length of the data in the array
Returns
exifRotation
public static Image exifRotation(String capturedImage)
throws IOExceptionThe main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
If there is no rotation or flipping, the image is only copied or scaled if necessary; if the capturedImage has a format different from jpeg and png, it is copied as it is. Note that this method doesn’t rely on the file extension, but on the mime type of the capturedImage, since some devices don’t give appropriate extension to images returned from the gallery.
You can test all the possible orientation values downloading the images from the repository EXIF Orientation-flag example images
Code example:
Form hi = new Form("Hi World", BoxLayout.y());
Button cameraBtn = new Button("Open Camera");
Button galleryBtn = new Button("Open Gallery");
Label imageLbl = new Label();
hi.addAll(cameraBtn, galleryBtn, FlowLayout.encloseCenter(imageLbl));
hi.show();
SuccessCallback<String> callback = new SuccessCallback<String>() {
public void onSucess(String capturedPhoto) {
String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
if (capturedPhoto != null) {
try {
// note: we set a maxSize to perform a faster rotation
int maxSize = CN.convertToPixels(50);
Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
imageLbl.setIcon(img);
hi.revalidate();
} catch (IOException ex) {
Log.e(ex);
}
}
}
};
cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}));
galleryBtn.addActionListener(a -> CN.openGallery(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}, CN.GALLERY_IMAGE));
Parameters
capturedImageString- is the FileSystemStorage path of a captured photo, usually inside a temporary directory
Returns
Throws
exifRotation
public static Image exifRotation(String capturedImage, String rotatedImage)
throws IOExceptionThe main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
If there is no rotation or flipping, the image is only copied or scaled if necessary; if the capturedImage has a format different from jpeg and png, it is copied as it is. Note that this method doesn’t rely on the file extension, but on the mime type of the capturedImage, since some devices don’t give appropriate extension to images returned from the gallery.
You can test all the possible orientation values downloading the images from the repository EXIF Orientation-flag example images
Code example:
Form hi = new Form("Hi World", BoxLayout.y());
Button cameraBtn = new Button("Open Camera");
Button galleryBtn = new Button("Open Gallery");
Label imageLbl = new Label();
hi.addAll(cameraBtn, galleryBtn, FlowLayout.encloseCenter(imageLbl));
hi.show();
SuccessCallback<String> callback = new SuccessCallback<String>() {
public void onSucess(String capturedPhoto) {
String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
if (capturedPhoto != null) {
try {
// note: we set a maxSize to perform a faster rotation
int maxSize = CN.convertToPixels(50);
Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
imageLbl.setIcon(img);
hi.revalidate();
} catch (IOException ex) {
Log.e(ex);
}
}
}
};
cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}));
galleryBtn.addActionListener(a -> CN.openGallery(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}, CN.GALLERY_IMAGE));
Parameters
capturedImageString- is the FileSystemStorage path of a captured photo, usually inside a temporary directory
rotatedImageString- is the FileSystemStorage path in which the rotated photo is stored, normally this should be inside the FileSystemStorage.getAppHomePath(); it can be null if you don’t want to save the rotated image to the FileSystemStorage.
Returns
Throws
exifRotation
public static Image exifRotation(String capturedImage, String rotatedImage, int maxSize)
throws IOExceptionThe main use case of this method is the automatic rotation and flipping of an image returned from the camera or from the gallery, preserving the original format (jpeg or png); it detects the Exif Orientation Tag, if available (all the possible Exif Orientation Tag values are supported); transparency is not preserved.
However, rotating and/or flipping an hi-res image is very inefficient, that’s why you should consider to pass a maxSize value as small as possible: it makes this method working faster.
If there is no rotation or flipping, the image is only copied or scaled if necessary; if the capturedImage has a format different from jpeg and png, it is copied as it is. Note that this method doesn’t rely on the file extension, but on the mime type of the capturedImage, since some devices don’t give appropriate extension to images returned from the gallery.
You can test all the possible orientation values downloading the images from the repository EXIF Orientation-flag example images
Code example:
Form hi = new Form("Hi World", BoxLayout.y());
Button cameraBtn = new Button("Open Camera");
Button galleryBtn = new Button("Open Gallery");
Label imageLbl = new Label();
hi.addAll(cameraBtn, galleryBtn, FlowLayout.encloseCenter(imageLbl));
hi.show();
SuccessCallback<String> callback = new SuccessCallback<String>() {
public void onSucess(String capturedPhoto) {
String rotatedPhoto = FileSystemStorage.getInstance().getAppHomePath() + "rotatedPhoto.jpg";
if (capturedPhoto != null) {
try {
// note: we set a maxSize to perform a faster rotation
int maxSize = CN.convertToPixels(50);
Image img = Image.exifRotation(capturedPhoto, rotatedPhoto, maxSize);
imageLbl.setIcon(img);
hi.revalidate();
} catch (IOException ex) {
Log.e(ex);
}
}
}
};
cameraBtn.addActionListener(a -> Capture.capturePhoto(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}));
galleryBtn.addActionListener(a -> CN.openGallery(l -> {
if (l != null && l.getSource() != null) {
callback.onSucess((String) l.getSource());
}
}, CN.GALLERY_IMAGE));
Parameters
capturedImageString- is the FileSystemStorage path of a captured photo, usually inside a temporary directory
rotatedImageString- is the FileSystemStorage path in which the rotated photo is stored, normally this should be inside the FileSystemStorage.getAppHomePath(); it can be null if you don’t want to save the rotated image to the FileSystemStorage.
maxSizeint- is the maximum value of the width and height of the rotated images, that is scaled if necessary, keeping the ratio.
Returns
Throws
getExifOrientationTag
public static int getExifOrientationTag(String path)
throws IOExceptionGets the EXIF orientation tag of an image if it’s available.
The Exif Orientation Tag is a number from 0 to 8, for the explanation of each value see the Exif Orientation Tag page
You can test all the possible orientation values downloading the images from the repository EXIF Orientation-flag example images
Parameters
pathString- FileSystemStorage path
Returns
Throws
getExifOrientationTag
public static int getExifOrientationTag(InputStream is)Gets the EXIF orientation tag of an image, if it’s available.
The Exif Orientation Tag is a number from 0 to 8, for the explanation of each value see the Exif Orientation Tag page
You can test all the possible orientation values downloading the images from the repository EXIF Orientation-flag example images
Returns
isJPEG
public static boolean isJPEG(InputStream inputStream)
throws IOExceptionReturns
Throws
isPNG
public static boolean isPNG(InputStream inputStream)
throws IOExceptionReturns
Throws
asyncLock
public void asyncLock(Image internal)Parameters
internalImage- the image to show while the actual image loads.
lock
public void lock()isLocked
public boolean isLocked()Returns
unlock
public void unlock()getSVGDocument
public Object getSVGDocument()Returns
isSVG
public boolean isSVG()Returns
createMask
public Object createMask()Creates a mask from the given image, a mask can be used to apply an arbitrary alpha channel to any image. A mask is derived from the blue channel (LSB) of the given image, other channels are ignored.
The generated mask can be used with the apply mask method.
The sample below demonstrates the masking of an image based on a circle drawn on a mutable image:
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Rounder", new BorderLayout());
Label picture = new Label("", "Container");
hi.add(BorderLayout.CENTER, picture);
hi.getUnselectedStyle().setBgColor(0xff0000);
hi.getUnselectedStyle().setBgTransparency(255);
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
Image camera = FontImage.createMaterial(FontImage.MATERIAL_CAMERA, s);
hi.getToolbar().addCommandToRightBar("", camera, (ev) -> {
try {
int width = Display.getInstance().getDisplayWidth();
Image capturedImage = Image.createImage(Capture.capturePhoto(width, -1));
Image roundMask = Image.createImage(width, capturedImage.getHeight(), 0xff000000);
Graphics gr = roundMask.getGraphics();
gr.setColor(0xffffff);
gr.fillArc(0, 0, width, width, 0, 360);
Object mask = roundMask.createMask();
capturedImage = capturedImage.applyMask(mask);
picture.setIcon(capturedImage);
hi.revalidate();
} catch(IOException err) {
Log.e(err);
}
});
Returns
applyMask
public 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.
The sample below demonstrates the masking of an image based on a circle drawn on a mutable image:
Toolbar.setGlobalToolbar(true);
Form hi = new Form("Rounder", new BorderLayout());
Label picture = new Label("", "Container");
hi.add(BorderLayout.CENTER, picture);
hi.getUnselectedStyle().setBgColor(0xff0000);
hi.getUnselectedStyle().setBgTransparency(255);
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
Image camera = FontImage.createMaterial(FontImage.MATERIAL_CAMERA, s);
hi.getToolbar().addCommandToRightBar("", camera, (ev) -> {
try {
int width = Display.getInstance().getDisplayWidth();
Image capturedImage = Image.createImage(Capture.capturePhoto(width, -1));
Image roundMask = Image.createImage(width, capturedImage.getHeight(), 0xff000000);
Graphics gr = roundMask.getGraphics();
gr.setColor(0xffffff);
gr.fillArc(0, 0, width, width, 0, 360);
Object mask = roundMask.createMask();
capturedImage = capturedImage.applyMask(mask);
picture.setIcon(capturedImage);
hi.revalidate();
} catch(IOException err) {
Log.e(err);
}
});
Parameters
maskObject- mask object created by the createMask() method.
xint- starting x where to apply the mask
yint- starting y where to apply the mask
Returns
applyMask
public Image applyMask(Object mask)Parameters
maskObject- mask object created by the createMask() method.
Returns
Throws
IllegalArgumentException- if the image size doesn’t match the mask size
applyMaskAutoScale
public Image applyMaskAutoScale(Object mask)Parameters
maskObject- mask object created by the createMask() method.
Returns
subImage
public Image subImage(int x, int y, int width, int height, boolean processAlpha)Parameters
xint- the x offset from the image
yint- the y offset from the image
widthint- the width of internal images
heightint- the height of internal images
processAlphaboolean- whether alpha should be processed as well as part of the cutting
Returns
mirror
public Image mirror()Returns
rotate
public Image rotate(int degrees)Returns an instance of this image rotated by the given number of degrees. By default 90 degree angle divisions are supported, anything else is implementation dependent. This method assumes a square image. Notice that it is inefficient in the current implementation to rotate to non-square angles,
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.
Parameters
degreesint- A degree in right angle must be larger than 0 and up to 359 degrees
Returns
modifyAlpha
public Image modifyAlpha(byte alpha)Parameters
alphabyte- New value for the entire alpha channel
Returns
modifyAlphaWithTranslucency
public Image modifyAlphaWithTranslucency(byte alpha)Parameters
alphabyte- New value for the entire alpha channel
Returns
modifyAlpha
public Image modifyAlpha(byte alpha, int removeColor)Parameters
alphabyte- New value for the entire alpha channel
removeColorint- pixels matching this color are made transparent (alpha channel ignored)
Returns
getGraphics
public Graphics getGraphics()Returns
getWidth
public int getWidth()Returns
getHeight
public int getHeight()Returns
drawImage
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y)Parameters
gGraphics- the graphics object
nativeGraphicsObject- the underlying native graphics which might be essential for some image types
xint- the x coordinate
yint- the y coordinate
drawImage
protected void drawImage(Graphics g, Object nativeGraphics, int x, int y, int w, int h)Parameters
gGraphics- the graphics object
nativeGraphicsObject- the underlying native graphics which might be essential for some image types
xint- the x coordinate
yint- the y coordinate
wint- the width to occupy
hint- the height to occupy
toRGB
public void toRGB(RGBImage image, int destX, int destY, int x, int y, int width, int height)Parameters
imageRGBImage- RGBImage that would receive pixel data
destXint- x location within RGBImage into which the data will be written
destYint- y location within RGBImage into which the data will be written
xint- location within the source image
yint- location within the source image
widthint- size of the image to extract from the source image
heightint- size of the image to extract from the source image
getRGB
public int[] getRGB()Returns
getRGB
public void getRGB(int[] rgbData)getRGBCached
public int[] getRGBCached()Returns
scaledWidth
public Image scaledWidth(int width)Parameters
widthint- the given new image width
Returns
scaledHeight
public Image scaledHeight(int height)Parameters
heightint- the given new image height
Returns
scaledSmallerRatio
public Image scaledSmallerRatio(int width, int height)Parameters
widthint- the given new image width
heightint- the given new image height
Returns
scaledLargerRatio
public Image scaledLargerRatio(int width, int height)Parameters
widthint- the given new image width
heightint- the given new image height
Returns
scaled
public Image scaled(int width, int height)Parameters
widthint- width for the scaling
heightint- height of the scaled image
Returns
fill
public Image fill(int width, int height)com.codename1.ui.plaf.Style#BACKGROUND_IMAGE_SCALED_FILLParameters
widthint- the width to fill
heightint- the height to fill
Returns
getImage
public Object getImage()Returns
scale
public void scale(int width, int height)Parameters
widthint- width for the scaling
heightint- height of the scaled image
isAnimation
public boolean isAnimation()Returns
animate
public boolean animate()Returns
true if the animation state changed.isOpaque
public boolean isOpaque()Returns
getImageName
public String getImageName()Returns
setImageName
public void setImageName(String imageName)Parameters
imageNameString- the imageName to set
dispose
public void dispose()rotate90Degrees
public Image rotate90Degrees(boolean maintainOpacity)Parameters
maintainOpacityboolean- whether the opacity in the image should be maintained
Returns
rotate180Degrees
public Image rotate180Degrees(boolean maintainOpacity)Parameters
maintainOpacityboolean- whether the opacity in the image should be maintained
Returns
rotate270Degrees
public Image rotate270Degrees(boolean maintainOpacity)Parameters
maintainOpacityboolean- whether the opacity in the image should be maintained
Returns
flipHorizontally
public Image flipHorizontally(boolean maintainOpacity)Parameters
maintainOpacityboolean- whether the opacity in the image should be maintained
Returns
flipVertically
public Image flipVertically(boolean maintainOpacity)Parameters
maintainOpacityboolean- whether the opacity in the image should be maintained
Returns
requiresDrawImage
public boolean requiresDrawImage()Returns
addActionListener
public void addActionListener(ActionListener l)removeActionListener
public void removeActionListener(ActionListener l)fireChangedEvent
public void fireChangedEvent()