Class BufferedImage
- java.lang.Object
-
- ej.microui.display.Image
-
- ej.microui.display.ResourceImage
-
- ej.microui.display.BufferedImage
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class BufferedImage extends ResourceImage
ABufferedImagerepresents a mutable image backed by a pixel buffer.The constructor of this class allows to create an image with given dimensions and format.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ej.microui.display.ResourceImage
ResourceImage.OutputFormat
-
-
Constructor Summary
Constructors Constructor Description BufferedImage(int width, int height)Creates a buffered image with the same format as the display.BufferedImage(int width, int height, Format format)Creates a buffered image specifying its format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FormatgetFormat()Gets the format of this image.GraphicsContextgetGraphicsContext()Gets theGraphicsContextassociated with this image, which may be used in order to draw on the image.-
Methods inherited from class ej.microui.display.ResourceImage
canLoadImage, close, isClosed, loadImage, loadImage, loadImage, loadImage
-
Methods inherited from class ej.microui.display.Image
canGetImage, getHeight, getImage, getWidth, isTransparent, readPixel, readPixels
-
-
-
-
Constructor Detail
-
BufferedImage
public BufferedImage(int width, int height)Creates a buffered image with the same format as the display.Equivalent to calling
BufferedImage(int, int, Format)withFormat.DISPLAYas parameter.The output format of the new image matches the pixel organization (layout, depth, etc.) of the default display.
- Parameters:
width- the width of the new image, in pixels.height- the height of the new image, in pixels.- Throws:
IllegalArgumentException- if eitherwidthorheightis negative or zero.MicroUIException- if the image could not be created.MicroUIException- if MicroUI is not started.SecurityException- if a security manager exists and does not allow the caller to create an image.
-
BufferedImage
public BufferedImage(int width, int height, Format format)Creates a buffered image specifying its format.The new image is initialized with unspecified data.
Creating images is not supported by every MicroUI implementation. If the MicroUI implementation does not support the allocation of memory in order to store the image buffer or if the format is not supported, a
MicroUIExceptionis thrown.An image with a custom format can be based on pixels (as the standard formats) but can also be based on anything else. For instance, it can save the list of drawings and replay them when the image is drawn.
- Parameters:
width- the width of the new image, in pixels.height- the height of the new image, in pixels.format- the format of the new image.- Throws:
IllegalArgumentException- if eitherwidthorheightis negative or zero or is greater than implementation limit.MicroUIException- if there is not enough room to allocate the buffer.MicroUIException- if the format is not supported.MicroUIException- if MicroUI is not started.SecurityException- if a security manager exists and does not allow the caller to create an image.
-
-
Method Detail
-
getGraphicsContext
public GraphicsContext getGraphicsContext()
Gets theGraphicsContextassociated with this image, which may be used in order to draw on the image.This method always returns the same
GraphicsContextinstance for a specific image. The graphics context has the same dimensions as the image, which allows to modify every pixel of the image.- Returns:
- the image's graphics context.
- Throws:
MicroUIException- if this image has been closed (seeResourceImage.close()).
-
getFormat
public Format getFormat()
Gets the format of this image.- Returns:
- the format of this image.
-
-