Class RgbToCmykColorConverter
java.lang.Object
com.itextpdf.pdfoptimizer.handlers.util.pixel.RgbToCmykColorConverter
- All Implemented Interfaces:
-
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 Summary
Modifier and TypeMethodDescriptiondouble[]convertColor(double[] rgbComponents) Performs a conversion of the provided array representing rgb color components to the array representing cmyk color component.static RgbToCmykColorConverterReturns an instance of rgb to cmyk converter.com.itextpdf.kernel.pdf.PdfNameReturns original color space of the color.intReturn number of components representing the original color space.com.itextpdf.kernel.pdf.PdfNameReturns target color space of the color.intReturn number of components representing the target color space.
-
Method Details
-
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:
-
convertColorin interfaceColorConverter - 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:ColorConverterReturns original color space of the color.- Specified by:
-
getSourceColorspacein interfaceColorConverter - Returns:
- original color space
-
getSourceNumberOfComponents
public int getSourceNumberOfComponents()Description copied from interface:ColorConverterReturn number of components representing the original color space.- Specified by:
-
getSourceNumberOfComponentsin interfaceColorConverter - Returns:
- number of components of the original color space
-
getTargetColorspace
public com.itextpdf.kernel.pdf.PdfName getTargetColorspace()Description copied from interface:ColorConverterReturns target color space of the color.- Specified by:
-
getTargetColorspacein interfaceColorConverter - Returns:
- target color space
-
getTargetNumberOfComponents
public int getTargetNumberOfComponents()Description copied from interface:ColorConverterReturn number of components representing the target color space.- Specified by:
-
getTargetNumberOfComponentsin interfaceColorConverter - Returns:
- number of components of the target color space
-