Class CMYKColorSpace

java.lang.Object
java.awt.color.ColorSpace
org.loboevolution.pdfview.colorspace.CMYKColorSpace
All Implemented Interfaces:
Serializable

public class CMYKColorSpace extends ColorSpace
A ColorSpace for the CMYK color space.

Take from net.sf.jcgm.core.CMYKColorSpace.java

Author XOND

Version:
$Id: CMYKColorSpace.java,v 1.2 2011-01-06 12:12:21 xond Exp $
See Also:
  • Constructor Details

    • CMYKColorSpace

      public CMYKColorSpace()
      Create a new CMYKColorSpace Instance.
  • Method Details

    • fromCIEXYZ

      public float[] fromCIEXYZ(float[] p_colorvalue)

      Converts to CMYK from CIEXYZ. We cheat here, using the RGB colorspace to do the math for us. The toCIEXYZ function has a description of how this is supposed to work, which may be implemented in the future.

      Specified by:
      fromCIEXYZ in class ColorSpace
      See Also:
    • fromRGB

      public float[] fromRGB(float[] p_rgbvalue)

      Converts a given RGB to CMYK. RGB doesn't really use black, so K will always be 0. On printers, the black should actually look dark brown. RGB (an additive space) is simply the backwards from CMY (a subtractive space), so all we do is:

      C = 1-R M = 1-G Y = 1-B

      Specified by:
      fromRGB in class ColorSpace
      See Also:
    • toCIEXYZ

      public float[] toCIEXYZ(float[] p_colorvalue)

      Converts the CMYK color to CIEXYZ. Because CIEXYZ is 3-component, we cheat, converting to RGB and then using the RGB colorspace function to do the conversion. Details on this colorspace are available on wikipedia:

      ...

      There is also an "ideal relationship" to CMYK, which might be implemented in the future (don't recall the reference we got this from, probably color.org):

      C = (C' - K)/(1 - K) M = (M' - K)/(1 - K) Y = (Y' - K)/(1 - K) K = Min(C', M', Y')

      X 41.2453 35.7580 18.0423 | 1-C' Y = 21.2671 71.5160 07.2169 | 1-M' Z 01.9334 11.9193 95.0227 | 1-Y'

      Specified by:
      toCIEXYZ in class ColorSpace
      See Also:
    • toRGB

      public float[] toRGB(float[] p_colorvalue)

      Converts CMYK colors to RGB. Note that converting back will be lossy. The formula for this is:

      K = 1 - K (go to additive) R = K * (1 - C) G = K * (1 - M) B = K * (1 - Y)

      Specified by:
      toRGB in class ColorSpace
      See Also:
    • normalize

      public float[] normalize(float[] p_colors)
      Normalize ensures all color values returned are between 0 and 1.
      Parameters:
      p_colors - an array of
      invalid reference
      float
      objects.
      Returns:
      p_colors, with any values greater than 1 set to 1, and less than 0 set to 0.