com.sibvisions.util.type
Class ImageUtil

java.lang.Object
  extended by com.sibvisions.util.type.ImageUtil

public final class ImageUtil
extends Object

The ImageUtil provides useful image operation/manipulation methods.


Nested Class Summary
static class ImageUtil.ImageFormat
          The image formats.
 
Method Summary
static void createScaledImage(InputStream pImage, int pWidth, int pHeight, boolean pProportional, OutputStream pScaledImage, String pFormat)
          Creates a scaled image out of an InputStream.
static ImageUtil.ImageFormat getImageFormat(byte[] pData)
          Gets the image format from raw image data.
static ImageIcon getScaledIcon(Icon pIcon, int pWidth, int pHeight, boolean pProportional)
          Gets a scaled ImageIcon out of an Icon.
static ImageIcon getScaledIcon(ImageIcon pIcon, int pWidth, int pHeight, boolean pProportional)
          Gets a scaled ImageIcon out of an ImageIcon.
static Image getScaledImage(Image pImage, int pWidth, int pHeight, boolean pProportional)
          Gets a scaled Image out of an Image.
static Image getScaledImage(Image pImage, int pType, int pWidth, int pHeight, boolean pProportional)
          Gets a scaled Image out of an Image.
static Image getScaledImage(InputStream pImage, int pWidth, int pHeight, boolean pProportional)
          Gets a scaled Image out of an InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getScaledIcon

public static ImageIcon getScaledIcon(Icon pIcon,
                                      int pWidth,
                                      int pHeight,
                                      boolean pProportional)
Gets a scaled ImageIcon out of an Icon.

Parameters:
pIcon - the icon
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
Returns:
the scaled icon

getScaledIcon

public static ImageIcon getScaledIcon(ImageIcon pIcon,
                                      int pWidth,
                                      int pHeight,
                                      boolean pProportional)
Gets a scaled ImageIcon out of an ImageIcon.

Parameters:
pIcon - the image
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
Returns:
the scaled icon

getScaledImage

public static Image getScaledImage(InputStream pImage,
                                   int pWidth,
                                   int pHeight,
                                   boolean pProportional)
                            throws IOException
Gets a scaled Image out of an InputStream.

Parameters:
pImage - the image stream
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
Returns:
the scaled image
Throws:
IOException - if an error occurs during image streaming

getScaledImage

public static Image getScaledImage(Image pImage,
                                   int pWidth,
                                   int pHeight,
                                   boolean pProportional)
Gets a scaled Image out of an Image.

Parameters:
pImage - the image
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
Returns:
the scaled image

getScaledImage

public static Image getScaledImage(Image pImage,
                                   int pType,
                                   int pWidth,
                                   int pHeight,
                                   boolean pProportional)
Gets a scaled Image out of an Image.

Parameters:
pImage - the image
pType - one of the image types of BufferedImage
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
Returns:
the scaled image

createScaledImage

public static void createScaledImage(InputStream pImage,
                                     int pWidth,
                                     int pHeight,
                                     boolean pProportional,
                                     OutputStream pScaledImage,
                                     String pFormat)
                              throws IOException
Creates a scaled image out of an InputStream.

Parameters:
pImage - the image stream
pWidth - the desired image height
pHeight - the desired image height
pProportional - true for proportional scaling and false for fixed scaling
pScaledImage - the scaled image output stream
pFormat - the output format supported from image IO, e.g. png, jpg, gif
Throws:
IOException - if an error occurs during image reading or writing
See Also:
ImageIO

getImageFormat

public static ImageUtil.ImageFormat getImageFormat(byte[] pData)
Gets the image format from raw image data.

Parameters:
pData - the image data
Returns:
the detected image format


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.