Fields Summary |
---|
private static final long | serialVersionUIDThe Constant serialVersionUID. |
private static final ObjectStreamField[] | serialPersistentFieldsThe Constant serialPersistentFields. |
private static final float | MAX_XYZAccording to ICC specification (from http://www.color.org) "For the
CIEXYZ encoding, each component (X, Y, and Z) is encoded as a
u1Fixed15Number". This means that max value for this encoding is 1 +
(32767/32768) |
private static final float | MAX_SHORTThe Constant MAX_SHORT. |
private static final float | INV_MAX_SHORTThe Constant INV_MAX_SHORT. |
private static final float | SHORT2XYZ_FACTORThe Constant SHORT2XYZ_FACTOR. |
private static final float | XYZ2SHORT_FACTORThe Constant XYZ2SHORT_FACTOR. |
private ICC_Profile | profileThe profile. |
private float[] | minValuesThe min values. |
private float[] | maxValuesThe max values. |
private org.apache.harmony.awt.gl.color.ICC_Transform | toRGBTransformThe to rgb transform. |
private org.apache.harmony.awt.gl.color.ICC_Transform | fromRGBTransformThe from rgb transform. |
private org.apache.harmony.awt.gl.color.ICC_Transform | toXYZTransformThe to xyz transform. |
private org.apache.harmony.awt.gl.color.ICC_Transform | fromXYZTransformThe from xyz transform. |
private final org.apache.harmony.awt.gl.color.ColorConverter | converterThe converter. |
private final org.apache.harmony.awt.gl.color.ColorScaler | scalerThe scaler. |
private boolean | scalingDataLoadedThe scaling data loaded. |
private ICC_ColorSpace | resolvedDeserializedInstThe resolved deserialized inst. |
Methods Summary |
---|
private void | fillMinMaxValues()Fill min max values.
int n = getNumComponents();
maxValues = new float[n];
minValues = new float[n];
switch (getType()) {
case ColorSpace.TYPE_XYZ:
minValues[0] = 0;
minValues[1] = 0;
minValues[2] = 0;
maxValues[0] = MAX_XYZ;
maxValues[1] = MAX_XYZ;
maxValues[2] = MAX_XYZ;
break;
case ColorSpace.TYPE_Lab:
minValues[0] = 0;
minValues[1] = -128;
minValues[2] = -128;
maxValues[0] = 100;
maxValues[1] = 127;
maxValues[2] = 127;
break;
default:
for(int i=0; i<n; i++) {
minValues[i] = 0;
maxValues[i] = 1;
}
}
|
public float[] | fromCIEXYZ(float[] xyzvalue)Performs the transformation of a color from the CS_CIEXYZ color space
into this ColorSpace.
if (fromXYZTransform == null) {
ICC_Profile xyzProfile =
((ICC_ColorSpace) ColorSpace.getInstance(CS_CIEXYZ)).getProfile();
ICC_Profile[] profiles = {xyzProfile, getProfile()};
try {
int[] intents = {
ICC_Profile.icPerceptual,
ICC_Profile.icRelativeColorimetric};
fromXYZTransform = new ICC_Transform(profiles, intents);
} catch (CMMException e) { // No such tag, use what we can
fromXYZTransform = new ICC_Transform(profiles);
}
if (!scalingDataLoaded) {
scaler.loadScalingData(this);
scalingDataLoaded = true;
}
}
// scale xyz value to short
short[] scaledXYZValue = new short[3];
scaledXYZValue[0] = (short)(xyzvalue[0] * XYZ2SHORT_FACTOR + 0.5f);
scaledXYZValue[1] = (short)(xyzvalue[1] * XYZ2SHORT_FACTOR + 0.5f);
scaledXYZValue[2] = (short)(xyzvalue[2] * XYZ2SHORT_FACTOR + 0.5f);
short[] converted =
converter.translateColor(fromXYZTransform, scaledXYZValue, null);
float[] res = new float[getNumComponents()];
scaler.unscale(res, converted, 0);
return res;
|
public float[] | fromRGB(float[] rgbvalue)Performs the transformation of a color from the RGB color space into this
ColorSpace.
if (fromRGBTransform == null) {
ICC_Profile sRGBProfile =
((ICC_ColorSpace) ColorSpace.getInstance(CS_sRGB)).getProfile();
ICC_Profile[] profiles = {sRGBProfile, getProfile()};
fromRGBTransform = new ICC_Transform(profiles);
if (!scalingDataLoaded) {
scaler.loadScalingData(this);
scalingDataLoaded = true;
}
}
// scale rgb value to short
short[] scaledRGBValue = new short[3];
scaledRGBValue[0] = (short)(rgbvalue[0] * MAX_SHORT + 0.5f);
scaledRGBValue[1] = (short)(rgbvalue[1] * MAX_SHORT + 0.5f);
scaledRGBValue[2] = (short)(rgbvalue[2] * MAX_SHORT + 0.5f);
short[] converted =
converter.translateColor(fromRGBTransform, scaledRGBValue, null);
float[] res = new float[getNumComponents()];
scaler.unscale(res, converted, 0);
return res;
|
public float | getMaxValue(int component)Gets the maximum normalized color component value for the specified
component.
if ((component < 0) || (component > this.getNumComponents() - 1)) {
// awt.169=Component index out of range
throw new IllegalArgumentException(Messages.getString("awt.169")); //$NON-NLS-1$
}
return maxValues[component];
|
public float | getMinValue(int component)Gets the minimum normalized color component value for the specified
component.
if ((component < 0) || (component > this.getNumComponents() - 1)) {
// awt.169=Component index out of range
throw new IllegalArgumentException(Messages.getString("awt.169")); //$NON-NLS-1$
}
return minValues[component];
|
public java.awt.color.ICC_Profile | getProfile()Gets the ICC_Profile for this ICC_ColorSpace.
if (profile instanceof ICC_ProfileStub) {
profile = ((ICC_ProfileStub) profile).loadProfile();
}
return profile;
|
private void | readObject(java.io.ObjectInputStream in)Read object.
ObjectInputStream.GetField fields = in.readFields();
resolvedDeserializedInst =
new ICC_ColorSpace((ICC_Profile) fields.get("thisProfile", null)); //$NON-NLS-1$
|
java.lang.Object | readResolve()Read resolve.
return resolvedDeserializedInst;
|
public float[] | toCIEXYZ(float[] colorvalue)Performs the transformation of a color from this ColorSpace into the
CS_CIEXYZ color space.
if (toXYZTransform == null) {
ICC_Profile xyzProfile =
((ICC_ColorSpace) ColorSpace.getInstance(CS_CIEXYZ)).getProfile();
ICC_Profile[] profiles = {getProfile(), xyzProfile};
try {
int[] intents = {
ICC_Profile.icRelativeColorimetric,
ICC_Profile.icPerceptual};
toXYZTransform = new ICC_Transform(profiles, intents);
} catch (CMMException e) { // No such tag, use what we can
toXYZTransform = new ICC_Transform(profiles);
}
if (!scalingDataLoaded) {
scaler.loadScalingData(this);
scalingDataLoaded = true;
}
}
short[] data = new short[getNumComponents()];
scaler.scale(colorvalue, data, 0);
short[] converted =
converter.translateColor(toXYZTransform, data, null);
// unscale to XYZ
float[] res = new float[3];
res[0] = ((converted[0] & 0xFFFF)) * SHORT2XYZ_FACTOR;
res[1] = ((converted[1] & 0xFFFF)) * SHORT2XYZ_FACTOR;
res[2] = ((converted[2] & 0xFFFF)) * SHORT2XYZ_FACTOR;
return res;
|
public float[] | toRGB(float[] colorvalue)Performs the transformation of a color from this ColorSpace into the RGB
color space.
if (toRGBTransform == null) {
ICC_Profile sRGBProfile =
((ICC_ColorSpace) ColorSpace.getInstance(CS_sRGB)).getProfile();
ICC_Profile[] profiles = {getProfile(), sRGBProfile};
toRGBTransform = new ICC_Transform(profiles);
if (!scalingDataLoaded) {
scaler.loadScalingData(this);
scalingDataLoaded = true;
}
}
short[] data = new short[getNumComponents()];
scaler.scale(colorvalue, data, 0);
short[] converted =
converter.translateColor(toRGBTransform, data, null);
// unscale to sRGB
float[] res = new float[3];
res[0] = ((converted[0] & 0xFFFF)) * INV_MAX_SHORT;
res[1] = ((converted[1] & 0xFFFF)) * INV_MAX_SHORT;
res[2] = ((converted[2] & 0xFFFF)) * INV_MAX_SHORT;
return res;
|
private void | writeObject(java.io.ObjectOutputStream out)Write object.
ObjectOutputStream.PutField fields = out.putFields();
fields.put("thisProfile", profile); //$NON-NLS-1$
fields.put("minVal", null); //$NON-NLS-1$
fields.put("maxVal", null); //$NON-NLS-1$
fields.put("diffMinMax", null); //$NON-NLS-1$
fields.put("invDiffMinMax", null); //$NON-NLS-1$
fields.put("needScaleInit", true); //$NON-NLS-1$
out.writeFields();
|