Class ProfileRed

  • All Implemented Interfaces:
    java.awt.image.RenderedImage, CachableRed

    public class ProfileRed
    extends AbstractRed
    This implementation of rendered image forces a color profile on its source
    Version:
    $Id: ProfileRed.java 1808888 2017-09-19 14:22:11Z ssteiner $
    • Field Detail

      • sRGBCS

        private static final java.awt.color.ColorSpace sRGBCS
      • sRGBCM

        private static final java.awt.image.ColorModel sRGBCM
      • colorSpace

        private org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent colorSpace
    • Constructor Detail

      • ProfileRed

        public ProfileRed​(CachableRed src,
                          org.apache.xmlgraphics.java2d.color.ICCColorSpaceWithIntent colorSpace)
        Parameters:
        src - Images on which the input ColorSpace should be forced
        colorSpace - colorSpace that should be forced on the source
    • Method Detail

      • copyData

        public java.awt.image.WritableRaster copyData​(java.awt.image.WritableRaster argbWR)
        This method will turn the input image in an sRGB image as follows. If there is no colorSpace defined, then the input image is simply converted to singlePixelPacked sRGB if needed. If there is a colorSpace defined, the the image data is 'interpreted' as being in that space, instead of that of the image's colorSpace. Here is how the input image is processed: a. It is converted to using a ComponentColorModel b. Its data is extracted, ignoring it's ColorSpace c. A new ComponentColorModel is built for the replacing colorSpace Note that if the number of components in the input image and the number of components in the replacing ColorSpace do not match, it is not possible to apply the conversion. d. A new BufferedImage is built, using the new ComponentColorModel and the data from the original image converted to the ComponentColorModel built in a. The alpha channel is excluded from that new BufferedImage. e. The BufferedImage created in d. is converted to sRGB using ColorConvertOp f. The alpha channel information is integrated back into the image. IMPORTANT NOTE: The code uses a BandedSampleModel in c.) and d.) and discard the alpha channel during the color conversions (it is restored in f.)), because of bugs in the interleaved model with alpha. The BandedSampleModel did not cause any bug as of JDK 1.3.