Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class ImageUtils

java.lang.Object
  extended by net.java.sip.communicator.util.ImageUtils

public class ImageUtils
extends Object

Utility methods for image manipulation.

Author:
Sebastien Mazy, Yana Stamcheva, Lubomir Marinov

Constructor Summary
ImageUtils()
           
 
Method Summary
static BufferedImage getBufferedImage(Image source)
          Returns the buffered image corresponding to the given image
static BufferedImage getBufferedImage(URL imagePath)
          Returns the buffered image corresponding to the given url image path.
static Image getBytesInImage(byte[] imageBytes)
          Loads an image from a given bytes array.
static byte[] getScaledInstanceInBytes(Image image, int width, int height)
          Returns a scaled instance of the given image.
static ImageIcon getScaledRoundedIcon(byte[] imageBytes, int width, int height)
          Creates a rounded corner scaled image.
static ImageIcon getScaledRoundedIcon(Image image, int width, int height)
          Returns a scaled rounded icon from the given image, scaled within the given width and height.
static Image getScaledRoundedImage(Image image, int width, int height)
          Creates a rounded avatar image.
static ImageIcon scaleIconWithinBounds(Image image, int width, int height)
          Scales the given image to fit in the given width and height.
static ImageIcon scaleImageWithinBounds(byte[] imageBytes, int width, int height)
          Scales the given image to fit in the given width and height.
static Image scaleImageWithinBounds(Image image, int width, int height)
          Returns a scaled image fitting within the given bounds while keeping the aspect ratio.
static byte[] toByteArray(BufferedImage image)
          Extracts bytes from image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Method Detail

scaleImageWithinBounds

public static Image scaleImageWithinBounds(Image image,
                                           int width,
                                           int height)
Returns a scaled image fitting within the given bounds while keeping the aspect ratio.

Parameters:
image - the image to scale
width - maximum width of the scaled image
height - maximum height of the scaled image
Returns:
the scaled image

scaleIconWithinBounds

public static ImageIcon scaleIconWithinBounds(Image image,
                                              int width,
                                              int height)
Scales the given image to fit in the given width and height.

Parameters:
image - the image to scale
width - the desired width
height - the desired height
Returns:
the scaled image

scaleImageWithinBounds

public static ImageIcon scaleImageWithinBounds(byte[] imageBytes,
                                               int width,
                                               int height)
Scales the given image to fit in the given width and height.

Parameters:
imageBytes - the bytes of the image to scale
width - the desired width
height - the desired height
Returns:
the scaled image

getScaledRoundedImage

public static Image getScaledRoundedImage(Image image,
                                          int width,
                                          int height)
Creates a rounded avatar image.

Parameters:
image - image of the initial avatar image.
width - the desired width
height - the desired height
Returns:
The rounded corner image.

getScaledInstanceInBytes

public static byte[] getScaledInstanceInBytes(Image image,
                                              int width,
                                              int height)
Returns a scaled instance of the given image.

Parameters:
image - the image to scale
width - the desired width
height - the desired height
Returns:
a byte array containing the scaled image

getScaledRoundedIcon

public static ImageIcon getScaledRoundedIcon(Image image,
                                             int width,
                                             int height)
Returns a scaled rounded icon from the given image, scaled within the given width and height.

Parameters:
image - the image to scale
width - the maximum width of the scaled icon
height - the maximum height of the scaled icon
Returns:
a scaled rounded icon

getScaledRoundedIcon

public static ImageIcon getScaledRoundedIcon(byte[] imageBytes,
                                             int width,
                                             int height)
Creates a rounded corner scaled image.

Parameters:
imageBytes - The bytes of the image to be scaled.
width - The maximum width of the scaled image.
height - The maximum height of the scaled image.
Returns:
The rounded corner scaled image.

getBufferedImage

public static BufferedImage getBufferedImage(URL imagePath)
Returns the buffered image corresponding to the given url image path.

Parameters:
imagePath - the path indicating, where we can find the image.
Returns:
the buffered image corresponding to the given url image path.

getBufferedImage

public static BufferedImage getBufferedImage(Image source)
Returns the buffered image corresponding to the given image

Parameters:
source - an image
Returns:
the buffered image corresponding to the given image

toByteArray

public static byte[] toByteArray(BufferedImage image)
Extracts bytes from image.

Parameters:
image - the image.
Returns:
the bytes of the image.

getBytesInImage

public static Image getBytesInImage(byte[] imageBytes)
Loads an image from a given bytes array.

Parameters:
imageBytes - The bytes array to load the image from.
Returns:
The image for the given bytes array.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.