edu.stanford.hci.r3.util.graphics
Class JAIUtils

java.lang.Object
  extended by edu.stanford.hci.r3.util.graphics.JAIUtils

public class JAIUtils
extends java.lang.Object

This software is distributed under the BSD License.


Constructor Summary
JAIUtils()
           
 
Method Summary
static TiledImage createWritableBuffer(int width, int height)
          Creates an alpha channel to write translucent images to.
static TiledImage createWritableBufferWithoutAlpha(int width, int height)
          Even without an alpha channel, you can do alpha compositing! However, it won't work well if you want a transparent background for PNGs.
static PlanarImage createZeroImage(int width, int height, int numBands)
          Create a black image with the given width, height, and color depth (use 3 for an RGB image, 4 for RGBA).
static PlanarImage readJPEG(java.io.File jpegFile)
           
static PlanarImage scaleImage(PlanarImage src, InterpolationQuality interpQuality, float scaleFactorX, float scaleFactorY)
          performs a JAI scaling of the PlanarImage with appropriate scale factors
static PlanarImage scaleImageIteratively(PlanarImage src, float scaleFactorX, float scaleFactorY)
           
static PlanarImage scaleImageIteratively(PlanarImage src, InterpolationQuality interpQuality, float scaleFactorX, float scaleFactorY)
          Higher quality, but slower implementation...
static PlanarImage scaleImageToFit(PlanarImage src, int width, int height)
          scale the image to best fit into a rectangle of size width x height defaults to good (but slower) scaling
static PlanarImage scaleImageToSize(PlanarImage src, int targetWidth, int targetHeight, InterpolationQuality quality, boolean maintainAspectRatio)
          the targets are hints...
static void writeImageToJPEG(PlanarImage img, java.io.File path)
          Writes a PlanarImage to a file, specified by the String (absolute path)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAIUtils

public JAIUtils()
Method Detail

createWritableBuffer

public static TiledImage createWritableBuffer(int width,
                                              int height)
Creates an alpha channel to write translucent images to.

Parameters:
width -
height -
Returns:
a buffer that you can get a Graphics2D context from, and write to!

createWritableBufferWithoutAlpha

public static TiledImage createWritableBufferWithoutAlpha(int width,
                                                          int height)
Even without an alpha channel, you can do alpha compositing! However, it won't work well if you want a transparent background for PNGs.

Parameters:
width -
height -
Returns:

createZeroImage

public static PlanarImage createZeroImage(int width,
                                          int height,
                                          int numBands)
Create a black image with the given width, height, and color depth (use 3 for an RGB image, 4 for RGBA).

Parameters:
width -
height -
numBands -
Returns:

readJPEG

public static PlanarImage readJPEG(java.io.File jpegFile)
Parameters:
jpegFile -
Returns:
a PlanarImage read from a File object.

scaleImage

public static PlanarImage scaleImage(PlanarImage src,
                                     InterpolationQuality interpQuality,
                                     float scaleFactorX,
                                     float scaleFactorY)
performs a JAI scaling of the PlanarImage with appropriate scale factors

Parameters:
src -
interpQuality -
scaleFactorX -
scaleFactorY -
Returns:

scaleImageIteratively

public static PlanarImage scaleImageIteratively(PlanarImage src,
                                                float scaleFactorX,
                                                float scaleFactorY)

scaleImageIteratively

public static PlanarImage scaleImageIteratively(PlanarImage src,
                                                InterpolationQuality interpQuality,
                                                float scaleFactorX,
                                                float scaleFactorY)
Higher quality, but slower implementation...

Parameters:
src -
interpQuality -
scaleFactorX -
scaleFactorY -
Returns:

scaleImageToFit

public static PlanarImage scaleImageToFit(PlanarImage src,
                                          int width,
                                          int height)
scale the image to best fit into a rectangle of size width x height defaults to good (but slower) scaling

Parameters:
src -
width -
height -
Returns:

scaleImageToSize

public static PlanarImage scaleImageToSize(PlanarImage src,
                                           int targetWidth,
                                           int targetHeight,
                                           InterpolationQuality quality,
                                           boolean maintainAspectRatio)
the targets are hints... to tell us what box the src should fit within

Parameters:
src -
targetWidth -
targetHeight -
quality -
maintainAspectRatio -
Returns:

writeImageToJPEG

public static void writeImageToJPEG(PlanarImage img,
                                    java.io.File path)
Writes a PlanarImage to a file, specified by the String (absolute path)

Parameters:
img -
quality - [0 to 100]
path -

Copyright 2006 Stanford University