Class RgbToCmykColorConverter

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

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

    • getInstance

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

      public double[] convertColor (double[] rgbComponents)
      Performs a conversion of the provided array representing rgb color components to the array representing cmyk color component. It is expected that the array passed as an argument contains three components and each is a double value from the range [0., 1.]. The values are considered as intensity of red, green and blue color components respectively. The returned value should be an array with length 4 where each component is a double value from the range [0., 1.]. The values should be considered as representations of cyan, magenta, yellow and black 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:
      rgbComponents - is an array representing red, green and blue color components as double values from the range [0., 1.]. Validation is not performed
      Returns:
      an array representing cyan, magenta, yellow and black 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