org.qtunes.core.util
Class ImageScaler

java.lang.Object
  extended by org.qtunes.core.util.ImageScaler

public class ImageScaler
extends java.lang.Object

Utility class to scale an image to no larger than a specified size. Will cache images based on the checksum of their bytes, so that identical requests don't process the image more than once.


Method Summary
static ImageScaler getInstance()
           
 java.nio.ByteBuffer getScaledImage(java.nio.ByteBuffer in, int maxwidth, int maxheight, java.lang.String format)
          Return a ByteBuffer containing rendered image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ImageScaler getInstance()

getScaledImage

public java.nio.ByteBuffer getScaledImage(java.nio.ByteBuffer in,
                                          int maxwidth,
                                          int maxheight,
                                          java.lang.String format)
                                   throws java.io.IOException
Return a ByteBuffer containing rendered image. The image will have a maximum dimension of maxwidth x maxheight - if the image supplied in "in" has to be scaled to meet that, the returned image will be in the requested format, otherwise the original image is returned. If the image can't be parsed or is null, this method returns null

Parameters:
in - a ByteBuffer containing a rendered Image, or null
maxwidth - the maximum width in pixels
maxheight - the maximum width in pixels
format - if the image has to be scaled, what format to create the saved image as
Returns:
a ByteBuffer containing a bitmap image no larger than the requestest size, or null
Throws:
java.io.IOException