code: public static BufferedImage getIndexedImage(BufferedImage pImage, int pNumberOfColors, int pHints) {
          return getIndexedImage(pImage, pNumberOfColors, null, pHints);
      }
docs: Converts the input image (must be  {@code TYPE_INT_RGB} or
  {@code TYPE_INT_ARGB}) to an indexed image. Generating an adaptive
  palette with the given number of colors.
  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 pNumberOfColors the number of colors for the image
  @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}.
  @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