jwo.utils.gui
Class JPGHandler

java.lang.Object
  extended by jwo.utils.gui.JPGHandler
All Implemented Interfaces:
ImageHandler

public class JPGHandler
extends Object
implements ImageHandler

Saves images in JPEG format. This is largely a wrapper around the standard Java JPEG image saving functionality. Implements the ImageHandler interface so it can be substituted with other formats.

Version:
2.3, 10th August, 2004.
Author:
Jo Wood.

Constructor Summary
JPGHandler()
          Initialises the image handler.
 
Method Summary
 boolean saveImage(String fileName, byte[] imageArray, int imgWidth, int imgHeight)
          Saves the given array of 24 bit colours as a file with the given name and dimensions.
 boolean saveImage(String fileName, Image image)
          Saves the given image as a JPEG file with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPGHandler

public JPGHandler()
Initialises the image handler.

Method Detail

saveImage

public boolean saveImage(String fileName,
                         Image image)
Saves the given image as a JPEG file with the given name.

Specified by:
saveImage in interface ImageHandler
Parameters:
fileName - Name of file to save.
image - Image to save.
Returns:
True if saved correctly, or false if problems saving.

saveImage

public boolean saveImage(String fileName,
                         byte[] imageArray,
                         int imgWidth,
                         int imgHeight)
Saves the given array of 24 bit colours as a file with the given name and dimensions.

Specified by:
saveImage in interface ImageHandler
Parameters:
fileName - Name of image file to save.
imageArray - BGR colours stored in byte array (3 bytes per colour).
imgWidth - Width of image to save.
imgHeight - Height of image to save.
Returns:
True if saved correctly, or false if problems saving.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009