org.gerhardb.lib.image
Class ImageUtil

java.lang.Object
  extended by org.gerhardb.lib.image.ImageUtil

public class ImageUtil
extends java.lang.Object

This is used to read images and write them back out to a file. This wraps the stream thereby keeping the Metadata.


Constructor Summary
ImageUtil()
           
 
Method Summary
static boolean hasAlpha(java.awt.Image image)
          This method returns true if the specified image has transparent pixels e661.
static void save(java.awt.image.BufferedImage inputImage, float quality, java.io.File saveAsFile, java.lang.String type)
          Deafults to jpeg if an unknown type is passed in.
static void saveJPEG(java.awt.image.BufferedImage inputImage, float quality, java.io.File saveAsFile)
           
static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
          This method returns a buffered image with the contents of an image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtil

public ImageUtil()
Method Detail

toBufferedImage

public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
This method returns a buffered image with the contents of an image. From The Java Developers Almanac 1.4 e667. Creating a Buffered Image from an Image An Image object cannot be converted to a BufferedImage object. The closest equivalent is to create a buffered image and then draw the image on the buffered image. This example defines a method that does this.


hasAlpha

public static boolean hasAlpha(java.awt.Image image)
This method returns true if the specified image has transparent pixels e661. Determining If an Image Has Transparent Pixels


saveJPEG

public static void saveJPEG(java.awt.image.BufferedImage inputImage,
                            float quality,
                            java.io.File saveAsFile)
                     throws java.io.IOException
Parameters:
image -
quality - An integer between 0 and 1. 1 specifies minimum compression and maximum quality.
saveAsFile -
Throws:
java.io.IOException

save

public static void save(java.awt.image.BufferedImage inputImage,
                        float quality,
                        java.io.File saveAsFile,
                        java.lang.String type)
                 throws java.io.IOException
Deafults to jpeg if an unknown type is passed in.

Parameters:
image -
quality - An integer between 0 and 1. 1 specifies minimum compression and maximum quality.
saveAsFile -
type - For example "jpeg".
Throws:
java.io.IOException


Copyright ? 2007 Gerhard Beck. All rights reserved. Subject to GPL.