docs: public static IndexColorModel getIndexColorModel(Image pImage, int pNumberOfColors, int pHints) throws ImageConversionException {
          IndexColorModel icm = null;
          RenderedImage image = null;
  
          if (pImage instanceof RenderedImage) {
              image = (RenderedImage) pImage;
              ColorModel cm = image.getColorModel();
  
              if (cm instanceof IndexColorModel) {
                  // Test if we have right number of colors
                  if (((IndexColorModel) cm).getMapSize() <= pNumberOfColors) {
                      //System.out.println("IndexColorModel from BufferedImage");
                      icm = (IndexColorModel) cm;// Done
                  }
              }
  
              // Else create from buffered image, hard way, see below
          }
          else {
              // Create from image using BufferedImageFactory
              BufferedImageFactory factory = new BufferedImageFactory(pImage);
              ColorModel cm = factory.getColorModel();
  
              if ((cm instanceof IndexColorModel) && ((IndexColorModel) cm).getMapSize() <= pNumberOfColors) {
                  //System.out.println("IndexColorModel from Image");
                  icm = (IndexColorModel) cm;// Done
              }
              else {
                  // Else create from (buffered) image, hard way
                  image = factory.getBufferedImage();
              }
          }
  
          // We now have at least a buffered image, create model from it
          if (icm == null) {
              icm = createIndexColorModel(ImageUtil.toBuffered(image), pNumberOfColors, pHints);
          }
          else if (!(icm instanceof InverseColorMapIndexColorModel)) {
              // If possible, use faster code
              icm = new InverseColorMapIndexColorModel(icm);
          }
          
          return icm;
      }