/** * Converts the input image (must be {@code TYPE_INT_RGB} or * {@code TYPE_INT_ARGB}) to an indexed image. Generating an adaptive * palette (8 bit) from the color data in the image, and uses default * dither. * <p/> * The image returned is a new image, the input image is not modified. * * @param pImage the BufferedImage to index and get color information from. * @return the indexed BufferedImage. The image will be of type * {@code BufferedImage.TYPE_BYTE_INDEXED}, and use an * {@code IndexColorModel}. * @see BufferedImage#TYPE_BYTE_INDEXED * @see IndexColorModel */ public static BufferedImage getIndexedImage(BufferedImage pImage) { return getIndexedImage(pImage, 256, DITHER_DEFAULT); }
/** * 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 */ public static BufferedImage getIndexedImage(BufferedImage pImage, int pNumberOfColors, int pHints) { return getIndexedImage(pImage, pNumberOfColors, null, pHints); }
/** * Converts the input image (must be {@code TYPE_INT_RGB} or * {@code TYPE_INT_ARGB}) to an indexed image. Using the supplied * {@code IndexColorModel}'s palette. * 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 pColors an {@code IndexColorModel} containing the color information * @param pHints RenderingHints 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 */ public static BufferedImage getIndexedImage(BufferedImage pImage, IndexColorModel pColors, int pHints) { return getIndexedImage(pImage, pColors, null, 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 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 */ public static BufferedImage getIndexedImage(BufferedImage pImage, Image pPalette, int pHints) { return getIndexedImage(pImage, pPalette, null, pHints); }
/** * 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 */ public static BufferedImage createIndexed(Image pImage) { return IndexImage.getIndexedImage(toBuffered(pImage), 256, Color.black, IndexImage.DITHER_DEFAULT); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors number of colors in the resulting image * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, int pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors the {@code IndexColorModel} to be used in the resulting * image. * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, IndexColorModel pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }
return getIndexedImage(pImage, getIndexColorModel(pPalette, 256, pHints), pMatte, pHints);
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors an {@code Image} used to get colors from. If the image is * has an {@code IndexColorModel}, it will be uesd, otherwise an * {@code IndexColorModel} is created from the image. * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, Image pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), IndexImage.getIndexColorModel(pColors, 255, pHints), pMatte, pHints); }
indexed = getIndexedImage(image, MonochromeColorModel.getInstance(), background, hints); colors = MonochromeColorModel.getInstance(); indexed = getIndexedImage(image, colors = getIndexColorModel(image, numColors, hints), background, hints); indexed = getIndexedImage(ImageUtil.toBuffered(image, BufferedImage.TYPE_INT_ARGB), colors = getIndexColorModel(paletteImg, numColors, hints), background, hints); indexed = getIndexedImage(image, colors = getIndexColorModel(image, numColors, hints), background, hints); getIndexedImage(image, colors, background, hints); getIndexedImage(image, colors, background, hints); time += (System.currentTimeMillis() - start); System.out.print('.');
pHints = (pHints & ~DITHER_MASK) | DITHER_NONE; return getIndexedImage(pImage, icm, pMatte, pHints);
/** * Converts the input image (must be {@code TYPE_INT_RGB} or * {@code TYPE_INT_ARGB}) to an indexed image. Generating an adaptive * pallete (8 bit) from the color data in the image, and uses default * dither. * <p/> * The image returned is a new image, the input image is not modified. * * @param pImage the BufferedImage to index and get color information from. * @return the indexed BufferedImage. The image will be of type * {@code BufferedImage.TYPE_BYTE_INDEXED}, and use an * {@code IndexColorModel}. * @see BufferedImage#TYPE_BYTE_INDEXED * @see IndexColorModel */ public static BufferedImage getIndexedImage(BufferedImage pImage) { return getIndexedImage(pImage, 256, DITHER_DEFAULT); }
/** * Converts the input image (must be {@code TYPE_INT_RGB} or * {@code TYPE_INT_ARGB}) to an indexed image. Generating an adaptive * palette (8 bit) from the color data in the image, and uses default * dither. * <p/> * The image returned is a new image, the input image is not modified. * * @param pImage the BufferedImage to index and get color information from. * @return the indexed BufferedImage. The image will be of type * {@code BufferedImage.TYPE_BYTE_INDEXED}, and use an * {@code IndexColorModel}. * @see BufferedImage#TYPE_BYTE_INDEXED * @see IndexColorModel */ public static BufferedImage getIndexedImage(BufferedImage pImage) { return getIndexedImage(pImage, 256, DITHER_DEFAULT); }
/** * Converts the input image (must be {@code TYPE_INT_RGB} or * {@code TYPE_INT_ARGB}) to an indexed image. Generating an adaptive * pallete 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 mHints 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 */ public static BufferedImage getIndexedImage(BufferedImage pImage, int pNumberOfColors, int pHints) { return getIndexedImage(pImage, pNumberOfColors, null, pHints); }
/** * 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 */ public static BufferedImage createIndexed(Image pImage) { return IndexImage.getIndexedImage(toBuffered(pImage), 256, Color.black, IndexImage.DITHER_DEFAULT); }
/** * 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 */ public static BufferedImage createIndexed(Image pImage) { return IndexImage.getIndexedImage(toBuffered(pImage), 256, Color.black, IndexImage.DITHER_DEFAULT); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors the {@code IndexColorModel} to be used in the resulting * image. * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, IndexColorModel pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors the {@code IndexColorModel} to be used in the resulting * image. * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, IndexColorModel pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors number of colors in the resulting image * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, int pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }
/** * Creates an indexed version of the given image (a {@code BufferedImage} * with an {@code IndexColorModel}. * * @param pImage the image to convert * @param pColors number of colors in the resulting image * @param pMatte color to replace transparent parts of the original. * @param pHints hints controlling dither, transparency and color selection * * @return an indexed version of the given image * * @see #COLOR_SELECTION_DEFAULT * @see #COLOR_SELECTION_FAST * @see #COLOR_SELECTION_QUALITY * @see #DITHER_NONE * @see #DITHER_DEFAULT * @see #DITHER_DIFFUSION * @see #DITHER_DIFFUSION_ALTSCANS * @see #TRANSPARENCY_DEFAULT * @see #TRANSPARENCY_OPAQUE * @see #TRANSPARENCY_BITMASK * @see #TRANSPARENCY_TRANSLUCENT */ public static BufferedImage createIndexed(Image pImage, int pColors, Color pMatte, int pHints) { return IndexImage.getIndexedImage(toBuffered(pImage), pColors, pMatte, pHints); }