Class CmykToRgbColorConverter

java.lang.Object
com.itextpdf.pdfoptimizer.handlers.util.pixel.CmykToRgbColorConverter
All Implemented Interfaces:
ColorConverter

public final class CmykToRgbColorConverter extends Object implements ColorConverter
Class representing logic for converting cmyk color to rgb color. It implements singleton pattern therefore the instance can be accessed via getInstance() call.
  • Method Details

    • getInstance

      public static CmykToRgbColorConverter getInstance()
      Returns an instance of cmyk to rgb converter.
      Returns:
      the instance
    • convertColor

      public double[] convertColor (double[] cmykComponents)
      Performs a conversion of the provided array representing cmyk color components to the array representing rgb color component. It is expected that the array passed as an argument contains four components and each is a double value from the range [0., 1.]. The values are considered as cyan, magenta, yellow and black components respectively. The returned value should be an array with length 3 where each component is a double value from the range [0., 1.]. The values should be considered as intensity of red, green and blue color components respectively.

      Note that no validation of the values is done for the better performance. When invalid argument is passed method may return invalid array of even throw runtime exception.

      Specified by:
      convertColor in interface ColorConverter
      Parameters:
      cmykComponents - is an array representing cyan, magenta, yellow and black as double values from the range [0., 1.]. Validation is not performed
      Returns:
      an array representing red, green and blue components as double values from the range [0., 1.]. If the passed argument is not in expected format then returned value may be unpredictable.
    • getSourceColorspace

      public com.itextpdf.kernel.pdf.PdfName getSourceColorspace()
      Description copied from interface: ColorConverter
      Returns original color space of the color.
      Specified by:
      getSourceColorspace in interface ColorConverter
      Returns:
      original color space
    • getSourceNumberOfComponents

      public int getSourceNumberOfComponents()
      Description copied from interface: ColorConverter
      Return number of components representing the original color space.
      Specified by:
      getSourceNumberOfComponents in interface ColorConverter
      Returns:
      number of components of the original color space
    • getTargetColorspace

      public com.itextpdf.kernel.pdf.PdfName getTargetColorspace()
      Description copied from interface: ColorConverter
      Returns target color space of the color.
      Specified by:
      getTargetColorspace in interface ColorConverter
      Returns:
      target color space
    • getTargetNumberOfComponents

      public int getTargetNumberOfComponents()
      Description copied from interface: ColorConverter
      Return number of components representing the target color space.
      Specified by:
      getTargetNumberOfComponents in interface ColorConverter
      Returns:
      number of components of the target color space