1:
37:
38:
39: package ;
40:
41: import ;
42:
43:
49: public abstract class ColorSpace implements Serializable
50: {
51:
54: private static final long serialVersionUID = -409452704308689724L;
55:
56: public static final int TYPE_XYZ = 0;
57: public static final int TYPE_Lab = 1;
58: public static final int TYPE_Luv = 2;
59: public static final int TYPE_YCbCr = 3;
60: public static final int TYPE_Yxy = 4;
61: public static final int TYPE_RGB = 5;
62: public static final int TYPE_GRAY = 6;
63: public static final int TYPE_HSV = 7;
64: public static final int TYPE_HLS = 8;
65: public static final int TYPE_CMYK = 9;
66:
67: public static final int TYPE_CMY = 11;
68: public static final int TYPE_2CLR = 12;
69: public static final int TYPE_3CLR = 13;
70: public static final int TYPE_4CLR = 14;
71: public static final int TYPE_5CLR = 15;
72: public static final int TYPE_6CLR = 16;
73: public static final int TYPE_7CLR = 17;
74: public static final int TYPE_8CLR = 18;
75: public static final int TYPE_9CLR = 19;
76: public static final int TYPE_ACLR = 20;
77: public static final int TYPE_BCLR = 21;
78: public static final int TYPE_CCLR = 22;
79: public static final int TYPE_DCLR = 23;
80: public static final int TYPE_ECLR = 24;
81: public static final int TYPE_FCLR = 25;
82:
83: public static final int CS_sRGB = 1000;
84: public static final int CS_LINEAR_RGB = 1004;
85: public static final int CS_CIEXYZ = 1001;
86: public static final int CS_PYCC = 1002;
87: public static final int CS_GRAY = 1003;
88:
89: private static final int CS_BASE = CS_sRGB;
90: private static final int CS_END = CS_LINEAR_RGB + 1;
91: private static final int CS_COUNT = CS_END - CS_BASE;
92:
93:
94: private static final ColorSpace[] INSTANCES = new ColorSpace[CS_COUNT];
95:
96:
99:
100: final int type;
101:
102:
105:
106: final int numComponents;
107:
108: protected ColorSpace(int type, int numcomponents)
109: {
110: this.type = type;
111: numComponents = numcomponents;
112: }
113:
114: public static ColorSpace getInstance(int colorspace)
115: {
116: if ((colorspace >= CS_BASE) && (colorspace < CS_END))
117: {
118: int instanceIndex = colorspace - CS_BASE;
119: if (INSTANCES[instanceIndex] == null)
120: {
121: ICC_Profile profile = new ICC_Profile(colorspace);
122: INSTANCES[instanceIndex] = new ICC_ColorSpace(profile);
123: }
124: return INSTANCES[instanceIndex];
125: }
126: throw new IllegalArgumentException("unknown/unsupported colorspace");
127: }
128:
129: public boolean isCS_sRGB()
130: {
131: return type == CS_sRGB;
132: }
133:
134:
141: public abstract float[] toRGB(float[] colorvalue);
142:
143: public abstract float[] fromRGB(float[] rgbvalue);
144:
145: public abstract float[] toCIEXYZ(float[] colorvalue);
146:
147: public abstract float[] fromCIEXYZ(float[] colorvalue);
148:
149: public int getType()
150: {
151: return type;
152: }
153:
154: public int getNumComponents()
155: {
156: return numComponents;
157: }
158:
159: public String getName(int idx)
160: {
161: return "type " + type;
162: }
163:
164:
167: public float getMinValue(int idx)
168: {
169: if (idx < 0 || idx >= numComponents)
170: throw new IllegalArgumentException();
171: return 0;
172: }
173:
174:
177: public float getMaxValue(int idx)
178: {
179: if (idx < 0 || idx >= numComponents)
180: throw new IllegalArgumentException();
181: return 1;
182: }
183: }