Package net.sourceforge.jiu.gui.awt
Class ImageCreator
java.lang.Object
net.sourceforge.jiu.gui.awt.ImageCreator
A class to create
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.- Author:
- Marco Schmidt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default transparency value to be used: full opacity.private static Frame -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RGB24ImageconvertImageToRGB24Image(Image image) Creates anRGB24Imagefrom the argument AWT image instance.static BufferedImagestatic BufferedImageConvert a JIURGB24Imageto aBufferedImagewith the given alpha value (useRGBA.DEFAULT_ALPHAas default).static ImageconvertToAwtImage(BilevelImage image, int alpha) Convert a BilevelImage object to an AWT image object.static ImageconvertToAwtImage(Gray16Image image, int alpha) Creates an AWT Image object from a Gray16Image object and an alpha value.static ImageconvertToAwtImage(Gray8Image image, int alpha) Creates an AWT Image object from a Gray8Image object and an alpha value.static ImageconvertToAwtImage(Paletted8Image image, int alpha) static ImageconvertToAwtImage(PixelImage image, int alpha) Creates an instance ofImagefrom an instance ofRGB24Image.static ImageconvertToAwtImage(RGB24Image image, int alpha) static ImageconvertToAwtImage(RGB48Image image, int alpha) static ImagecreateImage(int[] pixels, int width, int height) Creates aImageobject from a pixel array.
-
Field Details
-
DEFAULT_ALPHA
public static final int DEFAULT_ALPHAThe default transparency value to be used: full opacity.- See Also:
-
frame
-
-
Constructor Details
-
ImageCreator
private ImageCreator()
-
-
Method Details
-
createImage
Creates aImageobject from a pixel array. Internally, aFrameobject is used to call itsComponent.createImage(java.awt.image.ImageProducer)method with aMemoryImageSourceobject.- Parameters:
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 created
-
convertToAwtBufferedImage
-
convertToAwtBufferedImage
Convert a JIURGB24Imageto aBufferedImagewith the given alpha value (useRGBA.DEFAULT_ALPHAas default).- Parameters:
image- JIU image to be converted- Returns:
- a new BufferedImage
- Since:
- 0.14.2
-
convertToAwtImage
Creates an instance ofImagefrom an instance ofRGB24Image. This will requireimage.getWidth() * image.getHeight() * 4bytes of free memory. This method checks the type of the argument image via instanceof and the calls the right convertToAwtImage method of this class.- Parameters:
image- the RGB24Image to be convertedalpha- alpha value to be used with each pixel- Returns:
- newly-created AWT image instance
-
convertToAwtImage
Convert a BilevelImage object to an AWT image object.- Parameters:
image- the image to be convertedalpha- the transparency value to be written to each pixel in the resulting image- Returns:
- newly-created AWT image
-
convertToAwtImage
Creates an AWT Image object from a Gray16Image object and an alpha value. This is done by allocating a new int array with image.getWidth() times image.getHeight() elements, copying the data to those ints (using transparency information from the top eight bits of the alpha argument) and calling Toolkit.createImage with a MemoryImageSource of those int[] pixels.- Parameters:
image- the grayscale image to be convertedalpha- the alpha value, bits must only be set in the top eight bits- Returns:
- AWT image created from the argument input image
-
convertToAwtImage
Creates an AWT Image object from a Gray8Image object and an alpha value. This is done by allocating a new int array with image.getWidth() times image.getHeight() elements, copying the data to those ints (using transparency information from the top eight bits of the alpha argument) and calling Toolkit.createImage with a MemoryImageSource of those int[] pixels.- Parameters:
image- the grayscale image to be convertedalpha- the alpha value, bits must only be set in the top eight bits- Returns:
- AWT image created from the argument input image
-
convertToAwtImage
-
convertToAwtImage
-
convertToAwtImage
-
convertImageToRGB24Image
Creates anRGB24Imagefrom the argument AWT image instance.- Parameters:
image- AWT image object to be converted to aRGB24Image- Returns:
- a
RGB24Imageobject holding the image data from the argument image
-