/**
* Converts the {@code Image} to a {@code BufferedImage} of the given type.
* The new image will have the same {@code ColorModel}, {@code Raster} and
* properties as the original image, if possible.
* <p/>
* If the image is already a {@code BufferedImage} of the given type, it
* is simply returned and no conversion takes place.
*
* @param pOriginal the image to convert.
* @param pType the type of buffered image
*
* @return a {@code BufferedImage}
*
* @throws IllegalArgumentException if {@code pOriginal == null}
* or if {@code pType} is not a valid type for {@code BufferedImage}
*
* @see java.awt.image.BufferedImage#getType()
*/publicstatic BufferedImage toBuffered(Image pOriginal, int pType) {
returntoBuffered(pOriginal, pType, null);
}

/**
* Creates an indexed version of the given image (a {@code BufferedImage}
* with an {@code IndexColorModel}.
* The resulting image will have a maximum of 256 different colors.
* Transparent parts of the original will be replaced with solid black.
* Default (possibly HW accelerated) dither will be used.
*
* @param pImage the image to convert
*
* @return an indexed version of the given image
*/publicstatic BufferedImage createIndexed(Image pImage) {
return IndexImage.getIndexedImage(toBuffered(pImage), 256, Color.black, IndexImage.DITHER_DEFAULT);
}