docs: public static BufferedImage getIndexedImage(BufferedImage pImage, IndexColorModel pColors, Color pMatte, int pHints) {
          // TODO: Consider:
          /*
          if (pImage.getType() == BufferedImage.TYPE_BYTE_INDEXED
              || pImage.getType() == BufferedImage.TYPE_BYTE_BINARY) {
              pImage = ImageUtil.toBufferedImage(pImage, BufferedImage.TYPE_INT_ARGB);
          }
          */
  
          // Get dimensions
          final int width = pImage.getWidth();
          final int height = pImage.getHeight();
  
          // Support transparency?
          boolean transparency = isTransparent(pHints) && (pImage.getColorModel().getTransparency() != Transparency.OPAQUE) && (pColors.getTransparency() != Transparency.OPAQUE);
  
          // Create image with solid background
          BufferedImage solid = pImage;
  
          if (pMatte != null) { // transparency doesn't really matter
              solid = createSolid(pImage, pMatte);
          }
  
          BufferedImage indexed;
  
          // Support TYPE_BYTE_BINARY, but only for 2 bit images, as the default
          // dither does not work with TYPE_BYTE_BINARY it seems...
          if (pColors.getMapSize() > 2) {
              indexed = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, pColors);
          }
          else {
              indexed = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY, pColors);
          }
  
          // Apply dither if requested
          switch (pHints & DITHER_MASK) {
              case DITHER_DIFFUSION:
              case DITHER_DIFFUSION_ALTSCANS:
                  // Create a DiffusionDither to apply dither to indexed
                  DiffusionDither dither = new DiffusionDither(pColors);
  
                  if ((pHints & DITHER_MASK) == DITHER_DIFFUSION_ALTSCANS) {
                      dither.setAlternateScans(true);
                  }
  
                  dither.filter(solid, indexed);
  
                  break;
              case DITHER_NONE:
                  // Just copy pixels, without dither
                  // NOTE: This seems to be slower than the method below, using
                  // Graphics2D.drawImage, and VALUE_DITHER_DISABLE,
                  // however you possibly end up getting a dithered image anyway,
                  // therefore, do it slower and produce correct result. :-)
                  CopyDither copy = new CopyDither(pColors);
                  copy.filter(solid, indexed);
  
                  break;
              case DITHER_DEFAULT:
                  // This is the default
              default:
                  // Render image data onto indexed image, using default
                  // (probably we get dither, but it depends on the GFX engine).
                  Graphics2D g2d = indexed.createGraphics();
                  try {
                      RenderingHints hints = new RenderingHints(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
  
                      g2d.setRenderingHints(hints);
                      g2d.drawImage(solid, 0, 0, null);
                  }
                  finally {
                      g2d.dispose();
                  }
  
                  break;
          }
  
          // Transparency support, this approach seems lame, but it's the only
          // solution I've found until now (that actually works).
          if (transparency) {
              // Re-apply the alpha-channel of the original image
              applyAlpha(indexed, pImage);
          }
  
          // Return the indexed BufferedImage
          return indexed;
      }