public class ImageCreator
extends java.lang.Object
Image
objects from various JIU image data types
and vice versa.
java.awt.Image objects can be used with the AWT and Swing GUI environments.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ALPHA
The default transparency value to be used: full opacity.
|
private static java.awt.Frame |
frame |
Modifier | Constructor and Description |
---|---|
private |
ImageCreator() |
Modifier and Type | Method and Description |
---|---|
static RGB24Image |
convertImageToRGB24Image(java.awt.Image image)
Creates an
RGB24Image from the argument AWT image instance. |
static java.awt.image.BufferedImage |
convertToAwtBufferedImage(PixelImage image) |
static java.awt.image.BufferedImage |
convertToAwtBufferedImage(RGB24Image image)
Convert a JIU
RGB24Image to a BufferedImage with the
given alpha value (use RGBA.DEFAULT_ALPHA as default). |
static java.awt.Image |
convertToAwtImage(BilevelImage image,
int alpha)
Convert a BilevelImage object to an AWT image object.
|
static java.awt.Image |
convertToAwtImage(Gray16Image image,
int alpha)
Creates an AWT Image object from a Gray16Image object and an alpha value.
|
static java.awt.Image |
convertToAwtImage(Gray8Image image,
int alpha)
Creates an AWT Image object from a Gray8Image object and an alpha value.
|
static java.awt.Image |
convertToAwtImage(Paletted8Image image,
int alpha) |
static java.awt.Image |
convertToAwtImage(PixelImage image,
int alpha)
Creates an instance of
Image from an instance of
RGB24Image . |
static java.awt.Image |
convertToAwtImage(RGB24Image image,
int alpha) |
static java.awt.Image |
convertToAwtImage(RGB48Image image,
int alpha) |
static java.awt.Image |
createImage(int[] pixels,
int width,
int height)
Creates a
Image object from a pixel array. |
public static final int DEFAULT_ALPHA
private static java.awt.Frame frame
public static java.awt.Image createImage(int[] pixels, int width, int height)
Image
object from a pixel array.
Internally, a Frame
object is used to call its
Component.createImage(java.awt.image.ImageProducer)
method
with a MemoryImageSource
object.pixels
- the image pixel data in the typical RGBA 32-bit format, one int per pixelwidth
- the horizontal resolution in pixels of the image to be createdheight
- the vertical resolution in pixels of the image to be createdpublic static java.awt.image.BufferedImage convertToAwtBufferedImage(PixelImage image)
public static java.awt.image.BufferedImage convertToAwtBufferedImage(RGB24Image image)
RGB24Image
to a BufferedImage
with the
given alpha value (use RGBA.DEFAULT_ALPHA
as default).image
- JIU image to be convertedpublic static java.awt.Image convertToAwtImage(PixelImage image, int alpha)
Image
from an instance of
RGB24Image
.
This will require image.getWidth() * image.getHeight() * 4
bytes of free memory.
This method checks the type of the argument image via instanceof
and the calls the right convertToAwtImage method of this class.image
- the RGB24Image to be convertedalpha
- alpha value to be used with each pixelpublic static java.awt.Image convertToAwtImage(BilevelImage image, int alpha)
image
- the image to be convertedalpha
- the transparency value to be written to each
pixel in the resulting imagepublic static java.awt.Image convertToAwtImage(Gray16Image image, int alpha)
image
- the grayscale image to be convertedalpha
- the alpha value, bits must only be set in the top eight bitspublic static java.awt.Image convertToAwtImage(Gray8Image image, int alpha)
image
- the grayscale image to be convertedalpha
- the alpha value, bits must only be set in the top eight bitspublic static java.awt.Image convertToAwtImage(Paletted8Image image, int alpha)
public static java.awt.Image convertToAwtImage(RGB24Image image, int alpha)
public static java.awt.Image convertToAwtImage(RGB48Image image, int alpha)
public static RGB24Image convertImageToRGB24Image(java.awt.Image image)
RGB24Image
from the argument AWT image instance.image
- AWT image object to be converted to a RGB24Image
RGB24Image
object holding the image data from the argument image