org.apache.shindig.gadgets.rewrite.image
Class ImageUtils

java.lang.Object
  extended by org.apache.shindig.gadgets.rewrite.image.ImageUtils

public final class ImageUtils
extends Object

Utility functions for image processing and introspection.


Method Summary
static BufferedImage depalettize(BufferedImage img, int maxBytes)
          Convert an image to a direct color map
static BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality, int imageType)
          Convenience method that returns a scaled instance of the provided BufferedImage.
static boolean isOpaque(BufferedImage img)
          Check if an image is completely opaque
static BufferedImage palettize(BufferedImage img, int maxEntries)
          Convert an image to a palletized one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

palettize

public static BufferedImage palettize(BufferedImage img,
                                      int maxEntries)
Convert an image to a palletized one. Will not create a palette above a fixed number of entries


depalettize

public static BufferedImage depalettize(BufferedImage img,
                                        int maxBytes)
Convert an image to a direct color map


isOpaque

public static boolean isOpaque(BufferedImage img)
Check if an image is completely opaque


getScaledInstance

public static BufferedImage getScaledInstance(BufferedImage img,
                                              int targetWidth,
                                              int targetHeight,
                                              Object hint,
                                              boolean higherQuality,
                                              int imageType)
Convenience method that returns a scaled instance of the provided BufferedImage. NOTE: Adapted from code at http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html

Parameters:
img - the original image to be scaled
targetWidth - the desired width of the scaled instance, in pixels
targetHeight - the desired height of the scaled instance, in pixels
hint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)
higherQuality - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, where targetWidth or targetHeight is smaller than the original dimensions, and generally only when the BILINEAR hint is specified)
Returns:
a scaled version of the original BufferedImage


Copyright © 2007-2012. All Rights Reserved.