public static BufferedImage getIndexedImage(BufferedImage pImage, Image pPalette, Color pMatte, int pHints)
            throws ImageConversionException {
        return getIndexedImage(pImage, getIndexColorModel(pPalette, 256, pHints), pMatte, pHints);
    }
public static BufferedImage getIndexedImage ( BufferedImage pImage , Image pPalette , Color pMatte , int pHints ) throws ImageConversionException { return getIndexedImage ( pImage , getIndexColorModel ( pPalette , 256 , pHints ) , pMatte , pHints ) ; }
Converts the input image (must be {@code TYPE_INT_RGB} or
{@code TYPE_INT_ARGB}) to an indexed image. If the palette image
uses an {@code IndexColorModel}, this will be used. Otherwise, generating an
adaptive palette (8 bit) from the given palette image.
Dithering, transparency and color selection is controlled with the
{@code pHints}parameter.
<p/>
The image returned is a new image, the input image is not modified.

@param pImage   the BufferedImage to index
@param pPalette the Image to read color information from
@param pMatte   the background color, used where the original image was
transparent
@param pHints   hints that control output quality and speed.
@return the indexed BufferedImage. The image will be of type
{@code BufferedImage.TYPE_BYTE_INDEXED} or
{@code BufferedImage.TYPE_BYTE_BINARY}, and use an
{@code IndexColorModel}.
@throws ImageConversionException if an exception occurred during color
model extraction.
@see #DITHER_DIFFUSION
@see #DITHER_NONE
@see #COLOR_SELECTION_FAST
@see #COLOR_SELECTION_QUALITY
@see #TRANSPARENCY_OPAQUE
@see #TRANSPARENCY_BITMASK
@see BufferedImage#TYPE_BYTE_INDEXED
@see BufferedImage#TYPE_BYTE_BINARY
@see IndexColorModel