125 126 thisProfile = profile; 127 setMinMax(); 128 } 129 130 /** 131 * Returns the ICC_Profile for this ICC_ColorSpace. 132 * @return the ICC_Profile for this ICC_ColorSpace. 133 */ 134 public ICC_Profile getProfile() { 135 return thisProfile; 136 } 137 138 /** 139 * Transforms a color value assumed to be in this ColorSpace 140 * into a value in the default CS_sRGB color space. 141 * <p> 142 * This method transforms color values using algorithms designed 143 * to produce the best perceptual match between input and output 144 * colors. In order to do colorimetric conversion of color values, 145 * you should use the <code>toCIEXYZ</code> 146 * method of this color space to first convert from the input 147 * color space to the CS_CIEXYZ color space, and then use the 148 * <code>fromCIEXYZ</code> method of the CS_sRGB color space to 149 * convert from CS_CIEXYZ to the output color space. 150 * See {@link #toCIEXYZ(float[]) toCIEXYZ} and 151 * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information. 152 * 153 * @param colorvalue a float array with length of at least the number 154 * of components in this ColorSpace. 155 * @return a float array of length 3. 156 * @throws ArrayIndexOutOfBoundsException if array length is not 157 * at least the number of components in this ColorSpace. 158 */ 159 public float[] toRGB (float[] colorvalue) { 160 161 if (this2srgb == null) { 162 ColorTransform[] transformList = new ColorTransform [2]; 163 ICC_ColorSpace srgbCS = 164 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB); 165 PCMM mdl = CMSManager.getModule(); 166 transformList[0] = mdl.createTransform( 167 thisProfile, ColorTransform.Any, ColorTransform.In); 168 transformList[1] = mdl.createTransform( 177 short tmp[] = new short[nc]; 178 for (int i = 0; i < nc; i++) { 179 tmp[i] = (short) 180 ((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f); 181 } 182 tmp = this2srgb.colorConvert(tmp, null); 183 float[] result = new float [3]; 184 for (int i = 0; i < 3; i++) { 185 result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f; 186 } 187 return result; 188 } 189 190 /** 191 * Transforms a color value assumed to be in the default CS_sRGB 192 * color space into this ColorSpace. 193 * <p> 194 * This method transforms color values using algorithms designed 195 * to produce the best perceptual match between input and output 196 * colors. In order to do colorimetric conversion of color values, 197 * you should use the <code>toCIEXYZ</code> 198 * method of the CS_sRGB color space to first convert from the input 199 * color space to the CS_CIEXYZ color space, and then use the 200 * <code>fromCIEXYZ</code> method of this color space to 201 * convert from CS_CIEXYZ to the output color space. 202 * See {@link #toCIEXYZ(float[]) toCIEXYZ} and 203 * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information. 204 * 205 * @param rgbvalue a float array with length of at least 3. 206 * @return a float array with length equal to the number of 207 * components in this ColorSpace. 208 * @throws ArrayIndexOutOfBoundsException if array length is not 209 * at least 3. 210 */ 211 public float[] fromRGB(float[] rgbvalue) { 212 213 if (srgb2this == null) { 214 ColorTransform[] transformList = new ColorTransform [2]; 215 ICC_ColorSpace srgbCS = 216 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB); 217 PCMM mdl = CMSManager.getModule(); 218 transformList[0] = mdl.createTransform( 219 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.In); 220 transformList[1] = mdl.createTransform( | 125 126 thisProfile = profile; 127 setMinMax(); 128 } 129 130 /** 131 * Returns the ICC_Profile for this ICC_ColorSpace. 132 * @return the ICC_Profile for this ICC_ColorSpace. 133 */ 134 public ICC_Profile getProfile() { 135 return thisProfile; 136 } 137 138 /** 139 * Transforms a color value assumed to be in this ColorSpace 140 * into a value in the default CS_sRGB color space. 141 * <p> 142 * This method transforms color values using algorithms designed 143 * to produce the best perceptual match between input and output 144 * colors. In order to do colorimetric conversion of color values, 145 * you should use the {@code toCIEXYZ} 146 * method of this color space to first convert from the input 147 * color space to the CS_CIEXYZ color space, and then use the 148 * {@code fromCIEXYZ} method of the CS_sRGB color space to 149 * convert from CS_CIEXYZ to the output color space. 150 * See {@link #toCIEXYZ(float[]) toCIEXYZ} and 151 * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information. 152 * 153 * @param colorvalue a float array with length of at least the number 154 * of components in this ColorSpace. 155 * @return a float array of length 3. 156 * @throws ArrayIndexOutOfBoundsException if array length is not 157 * at least the number of components in this ColorSpace. 158 */ 159 public float[] toRGB (float[] colorvalue) { 160 161 if (this2srgb == null) { 162 ColorTransform[] transformList = new ColorTransform [2]; 163 ICC_ColorSpace srgbCS = 164 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB); 165 PCMM mdl = CMSManager.getModule(); 166 transformList[0] = mdl.createTransform( 167 thisProfile, ColorTransform.Any, ColorTransform.In); 168 transformList[1] = mdl.createTransform( 177 short tmp[] = new short[nc]; 178 for (int i = 0; i < nc; i++) { 179 tmp[i] = (short) 180 ((colorvalue[i] - minVal[i]) * invDiffMinMax[i] + 0.5f); 181 } 182 tmp = this2srgb.colorConvert(tmp, null); 183 float[] result = new float [3]; 184 for (int i = 0; i < 3; i++) { 185 result[i] = ((float) (tmp[i] & 0xffff)) / 65535.0f; 186 } 187 return result; 188 } 189 190 /** 191 * Transforms a color value assumed to be in the default CS_sRGB 192 * color space into this ColorSpace. 193 * <p> 194 * This method transforms color values using algorithms designed 195 * to produce the best perceptual match between input and output 196 * colors. In order to do colorimetric conversion of color values, 197 * you should use the {@code toCIEXYZ} 198 * method of the CS_sRGB color space to first convert from the input 199 * color space to the CS_CIEXYZ color space, and then use the 200 * {@code fromCIEXYZ} method of this color space to 201 * convert from CS_CIEXYZ to the output color space. 202 * See {@link #toCIEXYZ(float[]) toCIEXYZ} and 203 * {@link #fromCIEXYZ(float[]) fromCIEXYZ} for further information. 204 * 205 * @param rgbvalue a float array with length of at least 3. 206 * @return a float array with length equal to the number of 207 * components in this ColorSpace. 208 * @throws ArrayIndexOutOfBoundsException if array length is not 209 * at least 3. 210 */ 211 public float[] fromRGB(float[] rgbvalue) { 212 213 if (srgb2this == null) { 214 ColorTransform[] transformList = new ColorTransform [2]; 215 ICC_ColorSpace srgbCS = 216 (ICC_ColorSpace) ColorSpace.getInstance (CS_sRGB); 217 PCMM mdl = CMSManager.getModule(); 218 transformList[0] = mdl.createTransform( 219 srgbCS.getProfile(), ColorTransform.Any, ColorTransform.In); 220 transformList[1] = mdl.createTransform( |