com.vwp.awt.image
Class ImageUtils

java.lang.Object
  extended by com.vwp.awt.image.ImageUtils

public class ImageUtils
extends Object

This class contains a collection of useful functions related to image manipulation and handling. Some of them are useful especially together with Java 3D


Constructor Summary
ImageUtils()
          Main constructor
 
Method Summary
 BufferedImage createBufferedImage(byte[] b, double scalingFactor)
          Creates a BufferedImage out of a picture (.gif, .jpg, ...)
 BufferedImage createBufferedImage(byte[] b, double scalingFactor, boolean textureScaling)
          Creates a BufferedImage out of a picture (.gif, .jpg, ...)
 BufferedImage createBufferedImage(byte[] b, double scalingFactor, boolean textureScaling, Insets cropTexture)
          Creates a BufferedImage out of a picture (.gif, .jpg, ...)
 int getClosestPowerOf2(int value)
          Evaluates a value which is a power of two and nearest to the given value
 BufferedImage scaleBufferedImage(BufferedImage inBImg, int w, int h)
          Scales a BufferedImage to a new size using a smooth scaling algorithm (Image.SCALE_SMOOTH)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtils

public ImageUtils()
Main constructor

Method Detail

createBufferedImage

public BufferedImage createBufferedImage(byte[] b,
                                         double scalingFactor)
Creates a BufferedImage out of a picture (.gif, .jpg, ...)

Parameters:
b - the loaded picture file inside a byte-array
scalingFactor - factor which has to be used to prescale the image
Returns:
the BufferedImage created out of the picture

createBufferedImage

public BufferedImage createBufferedImage(byte[] b,
                                         double scalingFactor,
                                         boolean textureScaling)
Creates a BufferedImage out of a picture (.gif, .jpg, ...)

Parameters:
b - the loaded picture file inside a byte-array
scalingFactor - factor which has to be used to prescale the image
Returns:
the BufferedImage created out of the picture

createBufferedImage

public BufferedImage createBufferedImage(byte[] b,
                                         double scalingFactor,
                                         boolean textureScaling,
                                         Insets cropTexture)
Creates a BufferedImage out of a picture (.gif, .jpg, ...) This method bases on a method from the original com.sun.j3d.utils.image.TextureLoader

Parameters:
b - the loaded picture file inside a byte-array
scalingFactor - factor which has to be used to prescale the image
textureScaling - scale to a size which fits to the J3D texture properties (width and height have to be a value equal to a power of two
Returns:
the BufferedImage created out of the picture

getClosestPowerOf2

public int getClosestPowerOf2(int value)
Evaluates a value which is a power of two and nearest to the given value

Parameters:
value - - input value to which the power of two value has to be searched
Returns:
the nearest power of two value

scaleBufferedImage

public BufferedImage scaleBufferedImage(BufferedImage inBImg,
                                        int w,
                                        int h)
Scales a BufferedImage to a new size using a smooth scaling algorithm (Image.SCALE_SMOOTH)

Parameters:
inBImg - input BufferedImage which has to be scaled
w - new width of the image
h - nwe height of the image
Returns:
the new, scaled BufferedImage