public class BufferedImage extends ResourceImage
BufferedImage
represents a mutable image backed by a pixel buffer.
The constructor of this class allows to create an image with given dimensions and format.
ResourceImage.OutputFormat
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
Format |
getFormat()
Gets the format of this image.
|
GraphicsContext |
getGraphicsContext()
Gets the
GraphicsContext associated with this image, which may be used in order to draw on the image. |
canLoadImage, close, isClosed, loadImage, loadImage, loadImage, loadImage
canGetImage, getHeight, getImage, getSNIContext, getWidth, isTransparent, readPixel, readPixels
public BufferedImage(int width, int height)
Equivalent to calling BufferedImage(int, int, Format)
with Format.DISPLAY
as parameter.
The output format of the new image matches the pixel organization (layout, depth, etc.) of the default display.
width
- the width of the new image, in pixels.height
- the height of the new image, in pixels.IllegalArgumentException
- if either width
or height
is 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.public BufferedImage(int width, int height, Format 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
MicroUIException
is 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.
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.IllegalArgumentException
- if either width
or height
is 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.public Format getFormat()
public GraphicsContext getGraphicsContext()
GraphicsContext
associated with this image, which may be used in order to draw on the image.
This method always returns the same GraphicsContext
instance for a specific image. The graphics context
has the same dimensions as the image, which allows to modify every pixel of the image.
MicroUIException
- if this image has been closed (see ResourceImage.close()
).