BandSelectDescriptor.create( image, new int[] {image.getSampleModel().getNumBands() - 1}, null); alpha = MultiplyConstDescriptor.create(alpha, new double[] {alphaThreshold}, null); image = BandSelectDescriptor.create(image, new int[] {0, 1, 2}, null);
public static PlanarImage createColoredMaskImage(RenderedImage maskImage, Color color, double opacity) { RenderingHints hints = createDefaultRenderingHints(maskImage, null); RenderedImage alphaImage = MultiplyConstDescriptor.create(maskImage, new double[]{opacity}, hints); return createColoredMaskImage(color, alphaImage, hints); }
/** * Takes one rendered or renderable image and an array of double constants, and multiplies * every pixel of the same band of the source by the constant from the corresponding array * entry. See JAI {@link MultiplyConstDescriptor} for details. * * @param inValues * The constants to be multiplied. * @return this {@link ImageWorker}. * * @see MultiplyConstDescriptor */ public final ImageWorker multiplyConst(double[] inValues) { image = MultiplyConstDescriptor.create(image, inValues, getRenderingHints()); invalidateStatistics(); return this; }
/** * Takes one rendered or renderable image and an array of double constants, and multiplies * every pixel of the same band of the source by the constant from the corresponding array * entry. See JAI {@link MultiplyConstDescriptor} for details. * * @param inValues * The constants to be multiplied. * @return this {@link ImageWorker}. * * @see MultiplyConstDescriptor */ public final ImageWorker multiplyConst(double[] inValues) { image = MultiplyConstDescriptor.create(image, inValues, getRenderingHints()); invalidateStatistics(); return this; }
public ColorReduction(RenderedImage image, RenderingHints hints, int numColors, int alpaThreshold, int subsx, int subsy) { super(image, new ImageLayout(image), null, false); this.numColors = numColors; this.alphaThreshold = alpaThreshold; if (image.getColorModel().hasAlpha()) { RenderedImage alpha = BandSelectDescriptor.create(image, new int[] { image.getSampleModel().getNumBands() - 1 }, null); alpha = MultiplyConstDescriptor.create(alpha, new double[] { alphaThreshold }, null); image = BandSelectDescriptor.create(image, new int[] { 0, 1, 2 }, null); final ImageLayout layout = new ImageLayout(); layout.setColorModel(new ComponentColorModel(ColorSpace .getInstance(ColorSpace.CS_sRGB), true, false, Transparency.BITMASK, DataBuffer.TYPE_BYTE)); image = BandMergeDescriptor.create(image, alpha, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)) .getNewRendering(); this.setSource(image, 0); } // force palette computation this.paletteBuilder = new CustomPaletteBuilder(image, this.numColors,subsx, subsy, 1); this.hints=hints; }