Class DynamicImage
- All Implemented Interfaces:
ActionSource
java.lang.Object, int, int, int, int)
method.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionApplies 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.protected voidCallback invoked internally by Codename One to draw the image/frame onto the display.protected voidCallback invoked internally by Codename One to draw the image/frame onto the display.protected abstract voiddrawImageImpl(Graphics g, Object nativeGraphics, int x, int y, int w, int h) This method should be overridden by subclasses to perform the actual drawing of the image on a graphics context.fill(int width, int height) Resizes/crops the image so that its center fills the given dimensions.intReturns the height of the imagegetStyle()Gets the style for this image.intgetWidth()Returns the width of the imagebooleanNew label optimizations don't invoke drawImage and instead just pass the native image directly to the underlying renderer.voidscale(int width, int height) Scale the image to the given width and height, this is a fast algorithm that preserves translucent informationstatic voidsetIcon(Label lbl, DynamicImage img) Sets the given image as the icon for the specified label.voidSets the style to be used for drawing the image.Methods inherited from class Image
addActionListener, animate, applyMask, applyMaskAutoScale, asyncLock, createImage, createImage, createImage, createImage, createImage, createImage, createImage, createIndexed, createMask, createSVG, dispose, exifRotation, exifRotation, exifRotation, fireChangedEvent, flipHorizontally, flipVertically, getExifOrientationTag, getExifOrientationTag, getGraphics, getImage, getImageName, getRGB, getRGB, getRGBCached, getSVGDocument, isAlphaMutableImageSupported, isAnimation, isJPEG, isLocked, isOpaque, isPNG, isSVG, isSVGSupported, lock, mirror, modifyAlpha, modifyAlpha, modifyAlphaWithTranslucency, removeActionListener, rotate, rotate180Degrees, rotate270Degrees, rotate90Degrees, scaled, scaledHeight, scaledLargerRatio, scaledSmallerRatio, scaledWidth, setImageName, subImage, toRGB, unlock
-
Constructor Details
-
DynamicImage
public DynamicImage()Constructor. Creates image of default size: 250x250 pixels. -
DynamicImage
public DynamicImage(int w, int h) Constructor with width and height.
Parameters
-
w: The width of the image. -
h: The height of the image.
-
-
-
Method Details
-
setIcon
Sets the given image as the icon for the specified label. This will link the label's style with the image just before each call thejava.lang.Object, int, int, int, int)so that the image can correctly adapt to the label's style. -
getStyle
Gets the style for this image. -
setStyle
Sets the style to be used for drawing the image. The
java.lang.Object, int, int, int, int)can use any aspect of this style to customize the drawing.Parameters
s: The style.
-
getWidth
-
getHeight
-
scale
-
fill
Resizes/crops the image so that its center fills the given dimensions. This is similar to
com.codename1.ui.plaf.Style#BACKGROUND_IMAGE_SCALED_FILLParameters
-
width: the width to fill -
height: the height to fill
Returns
a new image (or the same image if dimensions happen to match) filling the width/height
-
-
applyMask
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.
Parameters
mask: mask object created by the createMask() method.
Returns
image masked based on the given object
Throws
IllegalArgumentException: if the image size doesn't match the mask size
-
requiresDrawImage
public boolean requiresDrawImage()Description copied from class:ImageNew label optimizations don't invoke drawImage and instead just pass the native image directly to the underlying renderer. This is problematic for some image types specifically timeline & FontImage and this method allows these classes to indicate that they need that legacy behavior of calling drawImage.
Returns
true if a drawImage call is a required
- Overrides:
requiresDrawImagein classImage
-
drawImageImpl
protected abstract void drawImageImpl(Graphics g, Object nativeGraphics, int x, int y, int w, int h) This method should be overridden by subclasses to perform the actual drawing of the image on a graphics context.
Parameters
-
g: The graphics context -
nativeGraphics: THe native graphics context. -
x: x-coordinate of the bounds to draw. -
y: y-coordinate of the bounds to draw. -
w: width of the bounds -
h: height of the bounds
-
-
drawImage
Callback invoked internally by Codename One to draw the image/frame onto the display. Image subclasses can override this method to perform drawing of custom image types.
Parameters
-
g: the graphics object -
nativeGraphics: the underlying native graphics which might be essential for some image types -
x: the x coordinate -
y: the y coordinate
-
-
drawImage
Callback invoked internally by Codename One to draw the image/frame onto the display. Image subclasses can override this method to perform drawing of custom image types.
Parameters
-
g: the graphics object -
nativeGraphics: the underlying native graphics which might be essential for some image types -
x: the x coordinate -
y: the y coordinate -
w: the width to occupy -
h: the height to occupy
-
-