public InverseColorMapOp( final IndexColorModel destCM, final int quantizationColors, final int alphaThreshold) { this.rasterOp = new InverseColorMapRasterOp(destCM, quantizationColors, alphaThreshold); this.icm = destCM; this.alphaThreshold = alphaThreshold; hasAlpha = icm.hasAlpha(); transparencyIndex = icm.getTransparentPixel(); }
colorMap.getRGBs(rgb); int components = colorMap.hasAlpha() ? 4 : 3; byte[] cmap = new byte[rgb.length * components]; for (int i = 0; i < rgb.length; i++) {
/** * Looks for the specified color in the color model * * @param bgColor The color to be searched * @param icm The color model to be searched into * @return The index of the color in the color model, or -1 if not found */ public static int findColorIndex(Color bgColor, IndexColorModel icm) { if (bgColor == null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "bgColor"))); if (icm == null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "icm"))); final int r = bgColor.getRed(); final int g = bgColor.getGreen(); final int b = bgColor.getBlue(); final int a = bgColor.getAlpha(); final int size = icm.getMapSize(); for (int i = 0; i < size; i++) { if (r == icm.getRed(i) && g == icm.getGreen(i) && b == icm.getBlue(i) && (a == icm.getAlpha(i) || !icm.hasAlpha())) return i; } return -1; }
this.icm = destCM; this.alphaThreshold = alphaThreshold; hasAlpha = icm.hasAlpha(); transparencyIndex = icm.getTransparentPixel(); final int mapSize = icm.getMapSize();
static TGAHeader from(final RenderedImage image, final ImageWriteParam param) { notNull(image, "image"); ColorModel colorModel = image.getColorModel(); IndexColorModel colorMap = colorModel instanceof IndexColorModel ? (IndexColorModel) colorModel : null; TGAHeader header = new TGAHeader(); header.colorMapType = colorMap != null ? 1 : 0; header.imageType = getImageType(colorModel, param); header.colorMapStart = 0; header.colorMapSize = colorMap != null ? colorMap.getMapSize() : 0; header.colorMapDepth = colorMap != null ? (colorMap.hasAlpha() ? 32 : 24) : 0; header.x = 0; header.y = 0; header.width = image.getWidth(); // TODO: Param source region/subsampling might affect this header.height = image.getHeight(); // // TODO: Param source region/subsampling might affect this header.pixelDepth = colorModel.getPixelSize() == 15 ? 16 : colorModel.getPixelSize(); header.origin = TGA.ORIGIN_UPPER_LEFT; // TODO: Allow parameter to control this? header.attributeBits = colorModel.hasAlpha() ? 8 : 0; // TODO: FixMe header.identification = null; header.colorMap = colorMap; return header; }
public MutableIndexColorModel(final IndexColorModel base) { super(base.getPixelSize(), base.getComponentSize(), base.getColorSpace(), base.hasAlpha(), base.isAlphaPremultiplied(), base.getTransparency(), base.getTransferType()); this.rgbs = getRGBs(base); }
if (!icm.hasAlpha()) {
int index = ColorUtilities.getColorIndex(icm, backgroundColor, -1); Color color; if (icm.hasAlpha()) { color = new Color(icm.getRed(index), icm.getGreen(index), icm.getBlue(index)); } else {
&& optimizeGray && noData == null; final boolean alpha = (icm.hasAlpha() || noData != null) && !omitAlphaOnExpand;
public InverseColorMapOp(final IndexColorModel destCM, final int quantizationColors, final int alphaThreshold) { this.rasterOp = new InverseColorMapRasterOp(destCM, quantizationColors, alphaThreshold); this.icm = destCM; this.alphaThreshold = alphaThreshold; hasAlpha = icm.hasAlpha(); transparencyIndex = icm.getTransparentPixel(); }
public InverseColorMapOp(final IndexColorModel destCM, final int quantizationColors, final int alphaThreshold) { this.rasterOp = new InverseColorMapRasterOp(destCM, quantizationColors, alphaThreshold); this.icm = destCM; this.alphaThreshold = alphaThreshold; hasAlpha = icm.hasAlpha(); transparencyIndex = icm.getTransparentPixel(); }
/** * Looks for the specified color in the color model * @param bgColor The color to be searched * @param icm The color model to be searched into * @return The index of the color in the color model, or -1 if not found */ public static int findColorIndex(Color bgColor, IndexColorModel icm) { if(bgColor== null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1,"bgColor"))); if(icm== null) throw new NullPointerException((Errors.format(ErrorKeys.NULL_ARGUMENT_$1,"icm"))); final int r = bgColor.getRed(); final int g = bgColor.getGreen(); final int b = bgColor.getBlue(); final int a = bgColor.getAlpha(); final int size = icm.getMapSize(); for(int i = 0; i < size; i++) { if(r == icm.getRed(i) && g == icm.getGreen(i) && b == icm.getBlue(i) && (a == icm.getAlpha(i) || !icm.hasAlpha())) return i; } return -1; }
this.icm = destCM; this.alphaThreshold = alphaThreshold; hasAlpha = icm.hasAlpha(); transparencyIndex = icm.getTransparentPixel(); final int mapSize = icm.getMapSize();
if (i.hasAlpha() && t >= 0 && t < indexed.length) { if (debug) System.err.println("i.getTransparentPixel: " + i.getTransparentPixel());
public static LookupTableJAI createColorLookupTable(IndexColorModel icm) { int numBands = icm.hasAlpha() ? 4 : 3; byte[][] data = new byte[numBands][icm.getMapSize()]; icm.getReds(data[0]); icm.getGreens(data[1]); icm.getBlues(data[2]); if (numBands == 4) { icm.getAlphas(data[3]); } return new LookupTableJAI(data); }
public MutableIndexColorModel(final IndexColorModel base) { super(base.getPixelSize(), base.getComponentSize(), base.getColorSpace(), base.hasAlpha(), base.isAlphaPremultiplied(), base.getTransparency(), base.getTransferType()); this.rgbs = getRGBs(base); }
if (!icm.hasAlpha()) {
if (!model.hasAlpha()) {
if (!icm.hasAlpha()) {
final SampleModel sm = image.getSampleModel(); final int datatype = sm.getDataType(); final boolean alpha = icm.hasAlpha();