/** * Forces the {@linkplain #image} color model to the {@linkplain ColorSpace#CS_GRAY GRAYScale * color space}. If the current color space is already of {@linkplain ColorSpace#TYPE_GRAY * type}, then this method does nothing. * * @return this {@link ImageWorker}. * @see #isColorSpaceGRAYScale * @see ColorConvertDescriptor */ public final ImageWorker forceColorSpaceGRAYScale() { if (!isColorSpaceRGB()) { final ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); forceColorModel(cm); invalidateStatistics(); } // All post conditions for this method contract. assert isColorSpaceGRAYScale(); return this; }
if (!imageWorker.isColorSpaceGRAYScale()) { if (!imageWorker.isColorSpaceRGB()) { imageWorker.forceColorSpaceRGB();
if (!imageWorker.isColorSpaceGRAYScale()) { if (!imageWorker.isColorSpaceRGB()) { imageWorker.forceColorSpaceRGB();
/** * Forces the {@linkplain #image} color model to the * {@linkplain ColorSpace#CS_GRAY GRAYScale color space}. If the current * color space is already of {@linkplain ColorSpace#TYPE_GRAY type}, then * this method does nothing. * * @return this {@link ImageWorker}. * * @see #isColorSpaceGRAYScale * @see ColorConvertDescriptor */ public final ImageWorker forceColorSpaceGRAYScale() { if (!isColorSpaceRGB()) { final ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); image = ColorConvertDescriptor.create(image, cm, getRenderingHints()); invalidateStatistics(); } // All post conditions for this method contract. assert isColorSpaceGRAYScale(); return this; }
/** * Forces the {@linkplain #image} color model to the * {@linkplain ColorSpace#CS_GRAY GRAYScale color space}. If the current * color space is already of {@linkplain ColorSpace#TYPE_GRAY type}, then * this method does nothing. * * @return this {@link ImageWorker}. * * @see #isColorSpaceGRAYScale * @see ColorConvertDescriptor */ public final ImageWorker forceColorSpaceGRAYScale() { if (!isColorSpaceRGB()) { final ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); image = ColorConvertDescriptor.create(image, cm, getRenderingHints()); invalidateStatistics(); } // All post conditions for this method contract. assert isColorSpaceGRAYScale(); return this; }