|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jiu.gui.awt.ToolkitLoader
This class loads an instance of Image
using
Toolkit
's built-in loading capabilities and
converts it to RGB24Image
using
ImageCreator
.
Supported file formats are JPEG and GIF. PNG is supported since Java 1.3. I have heard that XBM are supposedly loaded as well. I don't know that format and haven't tested this functionality.
In addition, this class can also use JIU's built-in codecs from this class.
Toolkit
class:
RGB24Image rgbImage = ToolkitLoader.loadAsRgb24Image("flower.jpg");This will only load images from files in formats that are supported by Toolkit - normally, that only includes JPEG, GIF and since Java 1.3 PNG. A potential problem of this approach is that Toolkit always delivers RGB data, even if the image file only contains a black and white image. In order to get an image object of the "real" type, try JIU's
AutoDetectColorType
with
rgbImage
(if you follow the link you will get a usage example
for that class as well).
System.exit(0);
.
Method Summary | |
static Image |
load(String fileName)
Loads an image from a file using the AWT's built-in loader. |
static RGB24Image |
loadAsRgb24Image(String fileName)
Loads an image from a file using the AWT's built-in loader and converts the image to a RGB24Image
object.
|
static PixelImage |
loadViaToolkitOrCodecs(String fileName)
Attempts to load an image from a file given by its name, using both the JIU codecs and the image loading functionality in java.awt.Toolkit. |
static PixelImage |
loadViaToolkitOrCodecs(String fileName,
boolean preferToolkit,
Vector progressListeners)
Attempts to load an image from a file given by its name, using both the JIU codecs and the image loading functionality in java.awt.Toolkit. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Image load(String fileName)
Image
object.
This method does nothing more than call Toolkit.getImage(String)
,
wait for it using a MediaTracker
and return
the resulting image.
fileName
- name of the image file
public static RGB24Image loadAsRgb24Image(String fileName)
RGB24Image
object.
First calls load(java.lang.String)
with the filename, then converts
the loaded image using ImageCreator.convertImageToRGB24Image(java.awt.Image)
.
fileName
- name of the file from which the image is to be loaded
RGB24Image
public static PixelImage loadViaToolkitOrCodecs(String fileName)
loadViaToolkitOrCodecs(fileName, false);
.
fileName
- name of the image file
null
on failurepublic static PixelImage loadViaToolkitOrCodecs(String fileName, boolean preferToolkit, Vector progressListeners)
loadAsRgb24Image(java.lang.String)
from this class for Toolkit loading
and ImageLoader
for JIU's codecs.
fileName
- name of the image file
null
on failure
|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |