org.meshcms.util
Class ImageLoader

java.lang.Object
  extended byorg.meshcms.util.ImageLoader
All Implemented Interfaces:
java.awt.image.ImageConsumer

public class ImageLoader
extends java.lang.Object
implements java.awt.image.ImageConsumer

Loads an image from a file without using the javax.imageio package. That package creates some performance problems with JPEG files that contain color profile information. This class works fine in a headless environment.


Field Summary
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
ImageLoader(java.lang.String imageFilePath)
          Creates an image loader for the given file path.
 
Method Summary
 boolean check()
          Checks if the images has loaded.
 int getHeight()
          Returns the height of the image.
 java.awt.Image getImage()
          Returns a new image.
 int[] getPixels()
          Returns the image as an array of ARGB pixels.
 int getWidth()
          Returns the width of the image.
 void imageComplete(int status)
           
 void setColorModel(java.awt.image.ColorModel model)
           
 void setDimensions(int width, int height)
           
 void setHints(int hintflags)
           
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)
           
 void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)
           
 void setProperties(java.util.Hashtable props)
           
 void waitForImage()
          Waits until the image has been loaded completely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageLoader

public ImageLoader(java.lang.String imageFilePath)
Creates an image loader for the given file path.

Parameters:
imageFilePath - the image file path
Method Detail

check

public boolean check()
Checks if the images has loaded.

Returns:
true if the image has been loaded completely.

getWidth

public int getWidth()
Returns the width of the image.


getHeight

public int getHeight()
Returns the height of the image.


setDimensions

public void setDimensions(int width,
                          int height)
Specified by:
setDimensions in interface java.awt.image.ImageConsumer

setProperties

public void setProperties(java.util.Hashtable props)
Specified by:
setProperties in interface java.awt.image.ImageConsumer

setColorModel

public void setColorModel(java.awt.image.ColorModel model)
Specified by:
setColorModel in interface java.awt.image.ImageConsumer

setHints

public void setHints(int hintflags)
Specified by:
setHints in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      byte[] pixels,
                      int off,
                      int scansize)
Specified by:
setPixels in interface java.awt.image.ImageConsumer

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      java.awt.image.ColorModel model,
                      int[] pixels,
                      int off,
                      int scansize)
Specified by:
setPixels in interface java.awt.image.ImageConsumer

imageComplete

public void imageComplete(int status)
Specified by:
imageComplete in interface java.awt.image.ImageConsumer

getImage

public java.awt.Image getImage()
Returns a new image.

Returns:
the image.

getPixels

public int[] getPixels()
Returns the image as an array of ARGB pixels.

Returns:
an array of pixels

waitForImage

public void waitForImage()
Waits until the image has been loaded completely.