Class CMYKColorSpace
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
Fields inherited from class java.awt.color.ColorSpace
CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC, CS_sRGB, TYPE_2CLR, TYPE_3CLR, TYPE_4CLR, TYPE_5CLR, TYPE_6CLR, TYPE_7CLR, TYPE_8CLR, TYPE_9CLR, TYPE_ACLR, TYPE_BCLR, TYPE_CCLR, TYPE_CMY, TYPE_CMYK, TYPE_DCLR, TYPE_ECLR, TYPE_FCLR, TYPE_GRAY, TYPE_HLS, TYPE_HSV, TYPE_Lab, TYPE_Luv, TYPE_RGB, TYPE_XYZ, TYPE_YCbCr, TYPE_Yxy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat[]
fromCIEXYZ
(float[] p_colorvalue) float[]
fromRGB
(float[] p_rgbvalue) float[]
normalize
(float[] p_colors) Normalize ensures all color values returned are between 0 and 1.float[]
toCIEXYZ
(float[] p_colorvalue) float[]
toRGB
(float[] p_colorvalue) Methods inherited from class java.awt.color.ColorSpace
getInstance, getMaxValue, getMinValue, getName, getNumComponents, getType, isCS_sRGB
-
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 classColorSpace
- 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 classColorSpace
- 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 classColorSpace
- 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 classColorSpace
- 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 ofinvalid reference
float
- Returns:
- p_colors, with any values greater than 1 set to 1, and less than 0 set to 0.
-