author | bae |
Sat, 04 Jun 2011 23:08:38 +0400 | |
changeset 9784 | 3a0ebf0b855d |
parent 9035 | 1255eb81cc2f |
child 14154 | 9acc7f86a458 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
7951
diff
changeset
|
2 |
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <stdio.h> |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
27 |
#include <stdlib.h> |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
28 |
#include <memory.h> |
2 | 29 |
#include "sun_java2d_cmm_lcms_LCMS.h" |
30 |
#include "jni_util.h" |
|
31 |
#include "Trace.h" |
|
32 |
#include "Disposer.h" |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
33 |
#include "lcms2.h" |
2 | 34 |
|
2392 | 35 |
|
36 |
#define ALIGNLONG(x) (((x)+3) & ~(3)) // Aligns to DWORD boundary |
|
37 |
||
38 |
#ifdef USE_BIG_ENDIAN |
|
39 |
#define AdjustEndianess32(a) |
|
40 |
#else |
|
41 |
||
42 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
43 |
void AdjustEndianess32(cmsUInt8Number *pByte) |
2392 | 44 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
45 |
cmsUInt8Number temp1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
46 |
cmsUInt8Number temp2; |
2392 | 47 |
|
48 |
temp1 = *pByte++; |
|
49 |
temp2 = *pByte++; |
|
50 |
*(pByte-1) = *pByte; |
|
51 |
*pByte++ = temp2; |
|
52 |
*(pByte-3) = *pByte; |
|
53 |
*pByte = temp1; |
|
54 |
} |
|
55 |
||
56 |
#endif |
|
57 |
||
58 |
// Transports to properly encoded values - note that icc profiles does use |
|
59 |
// big endian notation. |
|
60 |
||
61 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
62 |
cmsInt32Number TransportValue32(cmsInt32Number Value) |
2392 | 63 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
64 |
cmsInt32Number Temp = Value; |
2392 | 65 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
66 |
AdjustEndianess32((cmsUInt8Number*) &Temp); |
2392 | 67 |
return Temp; |
68 |
} |
|
69 |
||
2 | 70 |
#define SigMake(a,b,c,d) \ |
71 |
( ( ((int) ((unsigned char) (a))) << 24) | \ |
|
72 |
( ((int) ((unsigned char) (b))) << 16) | \ |
|
73 |
( ((int) ((unsigned char) (c))) << 8) | \ |
|
74 |
(int) ((unsigned char) (d))) |
|
75 |
||
76 |
#define TagIdConst(a, b, c, d) \ |
|
77 |
((int) SigMake ((a), (b), (c), (d))) |
|
78 |
||
79 |
#define SigHead TagIdConst('h','e','a','d') |
|
80 |
||
81 |
#define DT_BYTE 0 |
|
82 |
#define DT_SHORT 1 |
|
83 |
#define DT_INT 2 |
|
84 |
#define DT_DOUBLE 3 |
|
85 |
||
86 |
/* Default temp profile list size */ |
|
87 |
#define DF_ICC_BUF_SIZE 32 |
|
88 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
89 |
#define ERR_MSG_SIZE 256 |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
90 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
91 |
#ifdef _MSC_VER |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
92 |
# ifndef snprintf |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
93 |
# define snprintf _snprintf |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
94 |
# endif |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
95 |
#endif |
2 | 96 |
|
97 |
typedef union storeID_s { /* store SProfile stuff in a Java Long */ |
|
98 |
cmsHPROFILE pf; |
|
99 |
cmsHTRANSFORM xf; |
|
100 |
jobject jobj; |
|
101 |
jlong j; |
|
102 |
} storeID_t, *storeID_p; |
|
103 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
104 |
typedef union { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
105 |
cmsTagSignature cms; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
106 |
jint j; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
107 |
} TagSignature_t, *TagSignature_p; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
108 |
|
2 | 109 |
static jfieldID Trans_profileIDs_fID; |
110 |
static jfieldID Trans_renderType_fID; |
|
111 |
static jfieldID Trans_ID_fID; |
|
112 |
static jfieldID IL_isIntPacked_fID; |
|
113 |
static jfieldID IL_dataType_fID; |
|
114 |
static jfieldID IL_pixelType_fID; |
|
115 |
static jfieldID IL_dataArray_fID; |
|
116 |
static jfieldID IL_offset_fID; |
|
117 |
static jfieldID IL_nextRowOffset_fID; |
|
118 |
static jfieldID IL_width_fID; |
|
119 |
static jfieldID IL_height_fID; |
|
120 |
static jfieldID PF_ID_fID; |
|
121 |
||
122 |
JavaVM *javaVM; |
|
123 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
124 |
void errorHandler(cmsContext ContextID, cmsUInt32Number errorCode, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
125 |
const char *errorText) { |
2 | 126 |
JNIEnv *env; |
127 |
char errMsg[ERR_MSG_SIZE]; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
128 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
129 |
int count = snprintf(errMsg, ERR_MSG_SIZE, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
130 |
"LCMS error %d: %s", errorCode, errorText); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
131 |
if (count < 0 || count >= ERR_MSG_SIZE) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
132 |
count = ERR_MSG_SIZE - 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
133 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
134 |
errMsg[count] = 0; |
2 | 135 |
|
136 |
(*javaVM)->AttachCurrentThread(javaVM, (void**)&env, NULL); |
|
137 |
JNU_ThrowByName(env, "java/awt/color/CMMException", errMsg); |
|
138 |
} |
|
139 |
||
7951
8479f9f404f8
7002766: Java2d: Changes to correct c/c++ language issues for use of parfait
bae
parents:
7668
diff
changeset
|
140 |
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { |
2 | 141 |
javaVM = jvm; |
142 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
143 |
cmsSetLogErrorHandler(errorHandler); |
2 | 144 |
return JNI_VERSION_1_6; |
145 |
} |
|
146 |
||
147 |
void LCMS_freeTransform(JNIEnv *env, jlong ID) |
|
148 |
{ |
|
149 |
storeID_t sTrans; |
|
150 |
sTrans.j = ID; |
|
151 |
/* Passed ID is always valid native ref so there is no check for zero */ |
|
152 |
cmsDeleteTransform(sTrans.xf); |
|
153 |
} |
|
154 |
||
155 |
/* |
|
156 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
157 |
* Method: createNativeTransform |
|
158 |
* Signature: ([JI)J |
|
159 |
*/ |
|
160 |
JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_createNativeTransform |
|
161 |
(JNIEnv *env, jclass cls, jlongArray profileIDs, jint renderType, |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
162 |
jint inFormatter, jint outFormatter, jobject disposerRef) |
2 | 163 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
164 |
cmsHPROFILE _iccArray[DF_ICC_BUF_SIZE]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
165 |
cmsHPROFILE *iccArray = &_iccArray[0]; |
2 | 166 |
storeID_t sTrans; |
167 |
int i, j, size; |
|
168 |
jlong* ids; |
|
169 |
||
170 |
size = (*env)->GetArrayLength (env, profileIDs); |
|
171 |
ids = (*env)->GetPrimitiveArrayCritical(env, profileIDs, 0); |
|
172 |
||
173 |
if (DF_ICC_BUF_SIZE < size*2) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
174 |
iccArray = (cmsHPROFILE*) malloc( |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
175 |
size*2*sizeof(cmsHPROFILE)); |
2 | 176 |
if (iccArray == NULL) { |
177 |
J2dRlsTraceLn(J2D_TRACE_ERROR, "getXForm: iccArray == NULL"); |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
178 |
return 0L; |
2 | 179 |
} |
180 |
} |
|
181 |
||
182 |
j = 0; |
|
183 |
for (i = 0; i < size; i++) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
184 |
cmsHPROFILE icc; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
185 |
cmsColorSpaceSignature cs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
186 |
|
2 | 187 |
sTrans.j = ids[i]; |
188 |
icc = sTrans.pf; |
|
189 |
iccArray[j++] = icc; |
|
190 |
||
191 |
/* Middle non-abstract profiles should be doubled before passing to |
|
192 |
* the cmsCreateMultiprofileTransform function |
|
193 |
*/ |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
194 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
195 |
cs = cmsGetColorSpace(icc); |
2 | 196 |
if (size > 2 && i != 0 && i != size - 1 && |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
197 |
cs != cmsSigXYZData && cs != cmsSigLabData) |
2 | 198 |
{ |
199 |
iccArray[j++] = icc; |
|
200 |
} |
|
201 |
} |
|
202 |
||
203 |
sTrans.xf = cmsCreateMultiprofileTransform(iccArray, j, |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
204 |
inFormatter, outFormatter, renderType, 0); |
2 | 205 |
|
206 |
(*env)->ReleasePrimitiveArrayCritical(env, profileIDs, ids, 0); |
|
207 |
||
208 |
if (sTrans.xf == NULL) { |
|
209 |
J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_createNativeTransform: " |
|
210 |
"sTrans.xf == NULL"); |
|
211 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
212 |
"Cannot get color transform"); |
|
6868
f9131565859e
6963489: ZDI-CAN-803: Sun JRE ICC Profile Device Information Tag Remote Code Execution Vulnerability
bae
parents:
5506
diff
changeset
|
213 |
} else { |
f9131565859e
6963489: ZDI-CAN-803: Sun JRE ICC Profile Device Information Tag Remote Code Execution Vulnerability
bae
parents:
5506
diff
changeset
|
214 |
Disposer_AddRecord(env, disposerRef, LCMS_freeTransform, sTrans.j); |
2 | 215 |
} |
216 |
||
217 |
if (iccArray != &_iccArray[0]) { |
|
218 |
free(iccArray); |
|
219 |
} |
|
220 |
return sTrans.j; |
|
221 |
} |
|
222 |
||
223 |
||
224 |
/* |
|
225 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
226 |
* Method: loadProfile |
|
227 |
* Signature: ([B)J |
|
228 |
*/ |
|
229 |
JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_loadProfile |
|
230 |
(JNIEnv *env, jobject obj, jbyteArray data) |
|
231 |
{ |
|
232 |
jbyte* dataArray; |
|
233 |
jint dataSize; |
|
234 |
storeID_t sProf; |
|
235 |
||
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
236 |
if (JNU_IsNull(env, data)) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
237 |
JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
238 |
return 0L; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
239 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
240 |
|
2 | 241 |
dataArray = (*env)->GetByteArrayElements (env, data, 0); |
242 |
dataSize = (*env)->GetArrayLength (env, data); |
|
243 |
||
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
244 |
if (dataArray == NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
245 |
JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
246 |
return 0L; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
247 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
248 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
249 |
sProf.pf = cmsOpenProfileFromMem((const void *)dataArray, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
250 |
(cmsUInt32Number) dataSize); |
2 | 251 |
|
2392 | 252 |
(*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
253 |
||
2 | 254 |
if (sProf.pf == NULL) { |
255 |
JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); |
|
256 |
} |
|
257 |
||
258 |
return sProf.j; |
|
259 |
} |
|
260 |
||
261 |
/* |
|
262 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
263 |
* Method: freeProfile |
|
264 |
* Signature: (J)V |
|
265 |
*/ |
|
266 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_freeProfile |
|
267 |
(JNIEnv *env, jobject obj, jlong id) |
|
268 |
{ |
|
269 |
storeID_t sProf; |
|
270 |
||
271 |
sProf.j = id; |
|
272 |
if (cmsCloseProfile(sProf.pf) == 0) { |
|
273 |
J2dRlsTraceLn1(J2D_TRACE_ERROR, "LCMS_freeProfile: cmsCloseProfile(%d)" |
|
274 |
"== 0", id); |
|
275 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
276 |
"Cannot close profile"); |
|
277 |
} |
|
278 |
||
279 |
} |
|
280 |
||
281 |
/* |
|
282 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
283 |
* Method: getProfileSize |
|
284 |
* Signature: (J)I |
|
285 |
*/ |
|
286 |
JNIEXPORT jint JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileSize |
|
287 |
(JNIEnv *env, jobject obj, jlong id) |
|
288 |
{ |
|
289 |
storeID_t sProf; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
290 |
cmsUInt32Number pfSize = 0; |
2 | 291 |
sProf.j = id; |
292 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
293 |
if (cmsSaveProfileToMem(sProf.pf, NULL, &pfSize) && ((jint)pfSize > 0)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
294 |
return (jint)pfSize; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
295 |
} else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
296 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
297 |
"Can not access specified profile."); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
298 |
return -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
299 |
} |
2 | 300 |
} |
301 |
||
302 |
/* |
|
303 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
304 |
* Method: getProfileData |
|
305 |
* Signature: (J[B)V |
|
306 |
*/ |
|
307 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileData |
|
308 |
(JNIEnv *env, jobject obj, jlong id, jbyteArray data) |
|
309 |
{ |
|
310 |
storeID_t sProf; |
|
311 |
jint size; |
|
312 |
jbyte* dataArray; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
313 |
cmsUInt32Number pfSize = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
314 |
cmsBool status; |
2 | 315 |
|
316 |
sProf.j = id; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
317 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
318 |
// determine actual profile size |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
319 |
if (!cmsSaveProfileToMem(sProf.pf, NULL, &pfSize)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
320 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
321 |
"Can not access specified profile."); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
322 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
323 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
324 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
325 |
// verify java buffer capacity |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
326 |
size = (*env)->GetArrayLength(env, data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
327 |
if (0 >= size || pfSize > (cmsUInt32Number)size) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
328 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
329 |
"Insufficient buffer capacity."); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
330 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
331 |
} |
2 | 332 |
|
333 |
dataArray = (*env)->GetByteArrayElements (env, data, 0); |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
334 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
335 |
status = cmsSaveProfileToMem(sProf.pf, dataArray, &pfSize); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
336 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
337 |
(*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
2 | 338 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
339 |
if (!status) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
340 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
341 |
"Can not access specified profile."); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
342 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
343 |
} |
2 | 344 |
} |
345 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
346 |
/* Get profile header info */ |
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
347 |
static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
348 |
static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
349 |
static cmsBool _writeCookedTag(cmsHPROFILE pfTarget, cmsTagSignature sig, jbyte *pData, jint size); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
350 |
|
2 | 351 |
/* |
352 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
353 |
* Method: getTagSize |
|
354 |
* Signature: (JI)I |
|
355 |
*/ |
|
356 |
JNIEXPORT jint JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagSize |
|
357 |
(JNIEnv *env, jobject obj, jlong id, jint tagSig) |
|
358 |
{ |
|
359 |
storeID_t sProf; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
360 |
TagSignature_t sig; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
361 |
jint result = -1; |
2 | 362 |
|
363 |
sProf.j = id; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
364 |
sig.j = tagSig; |
2 | 365 |
|
366 |
if (tagSig == SigHead) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
367 |
result = sizeof(cmsICCHeader); |
2 | 368 |
} else { |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
369 |
if (cmsIsTag(sProf.pf, sig.cms)) { |
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
370 |
result = cmsReadRawTag(sProf.pf, sig.cms, NULL, 0); |
2 | 371 |
} else { |
372 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
373 |
"ICC profile tag not found"); |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
return result; |
|
378 |
} |
|
379 |
||
380 |
/* |
|
381 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
382 |
* Method: getTagData |
|
383 |
* Signature: (JI[B)V |
|
384 |
*/ |
|
385 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagData |
|
386 |
(JNIEnv *env, jobject obj, jlong id, jint tagSig, jbyteArray data) |
|
387 |
{ |
|
388 |
storeID_t sProf; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
389 |
TagSignature_t sig; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
390 |
cmsInt32Number tagSize; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
391 |
|
2 | 392 |
jbyte* dataArray; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
393 |
jint bufSize; |
2 | 394 |
|
395 |
sProf.j = id; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
396 |
sig.j = tagSig; |
2 | 397 |
|
398 |
if (tagSig == SigHead) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
399 |
cmsBool status; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
400 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
401 |
bufSize =(*env)->GetArrayLength(env, data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
402 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
403 |
if (bufSize < sizeof(cmsICCHeader)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
404 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
405 |
"Insufficient buffer capacity"); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
406 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
407 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
408 |
|
2 | 409 |
dataArray = (*env)->GetByteArrayElements (env, data, 0); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
410 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
411 |
if (dataArray == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
412 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
413 |
"Unable to get buffer"); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
414 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
415 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
416 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
417 |
status = _getHeaderInfo(sProf.pf, dataArray, bufSize); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
418 |
|
2 | 419 |
(*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
420 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
421 |
if (!status) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
422 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
423 |
"ICC Profile header not found"); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
424 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
425 |
|
2 | 426 |
return; |
427 |
} |
|
428 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
429 |
if (cmsIsTag(sProf.pf, sig.cms)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
430 |
tagSize = cmsReadRawTag(sProf.pf, sig.cms, NULL, 0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
431 |
} else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
432 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
433 |
"ICC profile tag not found"); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
434 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
435 |
} |
2 | 436 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
437 |
// verify data buffer capacity |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
438 |
bufSize = (*env)->GetArrayLength(env, data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
439 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
440 |
if (tagSize < 0 || 0 > bufSize || tagSize > bufSize) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
441 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
442 |
"Insufficient buffer capacity."); |
2 | 443 |
return; |
444 |
} |
|
445 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
446 |
dataArray = (*env)->GetByteArrayElements (env, data, 0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
447 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
448 |
if (dataArray == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
449 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
450 |
"Unable to get buffer"); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
451 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
452 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
453 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
454 |
bufSize = cmsReadRawTag(sProf.pf, sig.cms, dataArray, tagSize); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
455 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
456 |
(*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
457 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
458 |
if (bufSize != tagSize) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
459 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
460 |
"Can not get tag data."); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
461 |
} |
2 | 462 |
return; |
463 |
} |
|
464 |
||
465 |
/* |
|
466 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
467 |
* Method: setTagData |
|
468 |
* Signature: (JI[B)V |
|
469 |
*/ |
|
470 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_setTagData |
|
471 |
(JNIEnv *env, jobject obj, jlong id, jint tagSig, jbyteArray data) |
|
472 |
{ |
|
2392 | 473 |
storeID_t sProf; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
474 |
TagSignature_t sig; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
475 |
cmsBool status; |
2392 | 476 |
jbyte* dataArray; |
477 |
int tagSize; |
|
478 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
479 |
sProf.j = id; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
480 |
sig.j = tagSig; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
481 |
|
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
482 |
if (JNU_IsNull(env, data)) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
483 |
JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
484 |
return; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
485 |
} |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
486 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
487 |
tagSize =(*env)->GetArrayLength(env, data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
488 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
489 |
dataArray = (*env)->GetByteArrayElements(env, data, 0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
490 |
|
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
491 |
if (dataArray == NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
492 |
JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
493 |
return; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
494 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
495 |
|
2392 | 496 |
if (tagSig == SigHead) { |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
497 |
status = _setHeaderInfo(sProf.pf, dataArray, tagSize); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
498 |
} else { |
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
499 |
status = _writeCookedTag(sProf.pf, sig.cms, dataArray, tagSize); |
2392 | 500 |
} |
501 |
||
502 |
(*env)->ReleaseByteArrayElements(env, data, dataArray, 0); |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
503 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
504 |
if (!status) { |
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
505 |
JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
506 |
} |
2 | 507 |
} |
508 |
||
509 |
void* getILData (JNIEnv *env, jobject img, jint* pDataType, |
|
510 |
jobject* pDataObject) { |
|
511 |
void* result = NULL; |
|
512 |
*pDataType = (*env)->GetIntField (env, img, IL_dataType_fID); |
|
513 |
*pDataObject = (*env)->GetObjectField(env, img, IL_dataArray_fID); |
|
514 |
switch (*pDataType) { |
|
515 |
case DT_BYTE: |
|
516 |
result = (*env)->GetByteArrayElements (env, *pDataObject, 0); |
|
517 |
break; |
|
518 |
case DT_SHORT: |
|
519 |
result = (*env)->GetShortArrayElements (env, *pDataObject, 0); |
|
520 |
break; |
|
521 |
case DT_INT: |
|
522 |
result = (*env)->GetIntArrayElements (env, *pDataObject, 0); |
|
523 |
break; |
|
524 |
case DT_DOUBLE: |
|
525 |
result = (*env)->GetDoubleArrayElements (env, *pDataObject, 0); |
|
526 |
break; |
|
527 |
} |
|
528 |
||
529 |
return result; |
|
530 |
} |
|
531 |
||
532 |
void releaseILData (JNIEnv *env, void* pData, jint dataType, |
|
533 |
jobject dataObject) { |
|
534 |
switch (dataType) { |
|
535 |
case DT_BYTE: |
|
536 |
(*env)->ReleaseByteArrayElements(env,dataObject,(jbyte*)pData,0); |
|
537 |
break; |
|
538 |
case DT_SHORT: |
|
539 |
(*env)->ReleaseShortArrayElements(env,dataObject,(jshort*)pData, 0); |
|
540 |
break; |
|
541 |
case DT_INT: |
|
542 |
(*env)->ReleaseIntArrayElements(env,dataObject,(jint*)pData,0); |
|
543 |
break; |
|
544 |
case DT_DOUBLE: |
|
545 |
(*env)->ReleaseDoubleArrayElements(env,dataObject,(jdouble*)pData, |
|
546 |
0); |
|
547 |
break; |
|
548 |
} |
|
549 |
} |
|
550 |
||
551 |
/* |
|
552 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
553 |
* Method: colorConvert |
|
554 |
* Signature: (Lsun/java2d/cmm/lcms/LCMSTransform;Lsun/java2d/cmm/lcms/LCMSImageLayout;Lsun/java2d/cmm/lcms/LCMSImageLayout;)V |
|
555 |
*/ |
|
556 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert |
|
557 |
(JNIEnv *env, jclass obj, jobject trans, jobject src, jobject dst) |
|
558 |
{ |
|
559 |
storeID_t sTrans; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
560 |
int inFmt, outFmt, srcDType, dstDType; |
2 | 561 |
int srcOffset, srcNextRowOffset, dstOffset, dstNextRowOffset; |
562 |
int width, height, i; |
|
563 |
void* inputBuffer; |
|
564 |
void* outputBuffer; |
|
565 |
char* inputRow; |
|
566 |
char* outputRow; |
|
567 |
jobject srcData, dstData; |
|
568 |
||
569 |
inFmt = (*env)->GetIntField (env, src, IL_pixelType_fID); |
|
570 |
outFmt = (*env)->GetIntField (env, dst, IL_pixelType_fID); |
|
571 |
srcOffset = (*env)->GetIntField (env, src, IL_offset_fID); |
|
572 |
srcNextRowOffset = (*env)->GetIntField (env, src, IL_nextRowOffset_fID); |
|
573 |
dstOffset = (*env)->GetIntField (env, dst, IL_offset_fID); |
|
574 |
dstNextRowOffset = (*env)->GetIntField (env, dst, IL_nextRowOffset_fID); |
|
575 |
width = (*env)->GetIntField (env, src, IL_width_fID); |
|
576 |
height = (*env)->GetIntField (env, src, IL_height_fID); |
|
577 |
#ifdef _LITTLE_ENDIAN |
|
578 |
/* Reversing data packed into int for LE archs */ |
|
579 |
if ((*env)->GetBooleanField (env, src, IL_isIntPacked_fID) == JNI_TRUE) { |
|
580 |
inFmt ^= DOSWAP_SH(1); |
|
581 |
} |
|
582 |
if ((*env)->GetBooleanField (env, dst, IL_isIntPacked_fID) == JNI_TRUE) { |
|
583 |
outFmt ^= DOSWAP_SH(1); |
|
584 |
} |
|
585 |
#endif |
|
586 |
sTrans.j = (*env)->GetLongField (env, trans, Trans_ID_fID); |
|
587 |
||
588 |
if (sTrans.xf == NULL) { |
|
589 |
J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_colorConvert: transform == NULL"); |
|
590 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
591 |
"Cannot get color transform"); |
|
592 |
return; |
|
593 |
} |
|
594 |
||
595 |
||
596 |
inputBuffer = getILData (env, src, &srcDType, &srcData); |
|
597 |
||
598 |
if (inputBuffer == NULL) { |
|
599 |
J2dRlsTraceLn(J2D_TRACE_ERROR, ""); |
|
600 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
601 |
"Cannot get input data"); |
|
602 |
return; |
|
603 |
} |
|
604 |
||
605 |
outputBuffer = getILData (env, dst, &dstDType, &dstData); |
|
606 |
||
607 |
if (outputBuffer == NULL) { |
|
608 |
releaseILData(env, inputBuffer, srcDType, srcData); |
|
609 |
JNU_ThrowByName(env, "java/awt/color/CMMException", |
|
610 |
"Cannot get output data"); |
|
611 |
return; |
|
612 |
} |
|
613 |
||
614 |
inputRow = (char*)inputBuffer + srcOffset; |
|
615 |
outputRow = (char*)outputBuffer + dstOffset; |
|
616 |
||
617 |
for (i = 0; i < height; i++) { |
|
618 |
cmsDoTransform(sTrans.xf, inputRow, outputRow, width); |
|
619 |
inputRow += srcNextRowOffset; |
|
620 |
outputRow += dstNextRowOffset; |
|
621 |
} |
|
622 |
||
623 |
releaseILData(env, inputBuffer, srcDType, srcData); |
|
624 |
releaseILData(env, outputBuffer, dstDType, dstData); |
|
625 |
} |
|
626 |
||
627 |
/* |
|
628 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
629 |
* Method: getProfileID |
|
630 |
* Signature: (Ljava/awt/color/ICC_Profile;)J |
|
631 |
*/ |
|
632 |
JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileID |
|
633 |
(JNIEnv *env, jclass cls, jobject pf) |
|
634 |
{ |
|
635 |
return (*env)->GetLongField (env, pf, PF_ID_fID); |
|
636 |
} |
|
637 |
||
638 |
/* |
|
639 |
* Class: sun_java2d_cmm_lcms_LCMS |
|
640 |
* Method: initLCMS |
|
641 |
* Signature: (Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)V |
|
642 |
*/ |
|
643 |
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_initLCMS |
|
644 |
(JNIEnv *env, jclass cls, jclass Trans, jclass IL, jclass Pf) |
|
645 |
{ |
|
646 |
/* TODO: move initialization of the IDs to the static blocks of |
|
647 |
* corresponding classes to avoid problems with invalidating ids by class |
|
648 |
* unloading |
|
649 |
*/ |
|
650 |
Trans_profileIDs_fID = (*env)->GetFieldID (env, Trans, "profileIDs", "[J"); |
|
651 |
Trans_renderType_fID = (*env)->GetFieldID (env, Trans, "renderType", "I"); |
|
652 |
Trans_ID_fID = (*env)->GetFieldID (env, Trans, "ID", "J"); |
|
653 |
||
654 |
IL_isIntPacked_fID = (*env)->GetFieldID (env, IL, "isIntPacked", "Z"); |
|
655 |
IL_dataType_fID = (*env)->GetFieldID (env, IL, "dataType", "I"); |
|
656 |
IL_pixelType_fID = (*env)->GetFieldID (env, IL, "pixelType", "I"); |
|
657 |
IL_dataArray_fID = (*env)->GetFieldID(env, IL, "dataArray", |
|
658 |
"Ljava/lang/Object;"); |
|
659 |
IL_width_fID = (*env)->GetFieldID (env, IL, "width", "I"); |
|
660 |
IL_height_fID = (*env)->GetFieldID (env, IL, "height", "I"); |
|
661 |
IL_offset_fID = (*env)->GetFieldID (env, IL, "offset", "I"); |
|
662 |
IL_nextRowOffset_fID = (*env)->GetFieldID (env, IL, "nextRowOffset", "I"); |
|
663 |
||
664 |
PF_ID_fID = (*env)->GetFieldID (env, Pf, "ID", "J"); |
|
665 |
} |
|
2392 | 666 |
|
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
667 |
static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize) |
2392 | 668 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
669 |
cmsUInt32Number pfSize = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
670 |
cmsUInt8Number* pfBuffer = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
671 |
cmsBool status = FALSE; |
2392 | 672 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
673 |
if (!cmsSaveProfileToMem(pf, NULL, &pfSize) || |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
674 |
pfSize < sizeof(cmsICCHeader) || |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
675 |
bufferSize < sizeof(cmsICCHeader)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
676 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
677 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
678 |
} |
2392 | 679 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
680 |
pfBuffer = malloc(pfSize); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
681 |
if (pfBuffer == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
682 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
683 |
} |
2392 | 684 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
685 |
// load raw profile data into the buffer |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
686 |
if (cmsSaveProfileToMem(pf, pfBuffer, &pfSize)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
687 |
memcpy(pBuffer, pfBuffer, sizeof(cmsICCHeader)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
688 |
status = TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
689 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
690 |
free(pfBuffer); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
691 |
return status; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
692 |
} |
2392 | 693 |
|
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
694 |
static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize) |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
695 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
696 |
cmsICCHeader pfHeader = { 0 }; |
2392 | 697 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
698 |
if (pBuffer == NULL || bufferSize < sizeof(cmsICCHeader)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
699 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
700 |
} |
2392 | 701 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
702 |
memcpy(&pfHeader, pBuffer, sizeof(cmsICCHeader)); |
2392 | 703 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
704 |
// now set header fields, which we can access using the lcms2 public API |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
705 |
cmsSetHeaderFlags(pf, pfHeader.flags); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
706 |
cmsSetHeaderManufacturer(pf, pfHeader.manufacturer); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
707 |
cmsSetHeaderModel(pf, pfHeader.model); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
708 |
cmsSetHeaderAttributes(pf, pfHeader.attributes); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
709 |
cmsSetHeaderProfileID(pf, (cmsUInt8Number*)&(pfHeader.profileID)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
710 |
cmsSetHeaderRenderingIntent(pf, pfHeader.renderingIntent); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
711 |
cmsSetPCS(pf, pfHeader.pcs); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
712 |
cmsSetColorSpace(pf, pfHeader.colorSpace); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
713 |
cmsSetDeviceClass(pf, pfHeader.deviceClass); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
714 |
cmsSetEncodedICCversion(pf, pfHeader.version); |
2392 | 715 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
716 |
return TRUE; |
2392 | 717 |
} |
9784
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
718 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
719 |
static cmsBool _writeCookedTag(cmsHPROFILE pfTarget, |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
720 |
cmsTagSignature sig, |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
721 |
jbyte *pData, jint size) |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
722 |
{ |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
723 |
cmsBool status; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
724 |
cmsUInt32Number pfSize = 0; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
725 |
cmsUInt8Number* pfBuffer = NULL; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
726 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
727 |
cmsHPROFILE p = cmsCreateProfilePlaceholder(NULL); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
728 |
if (NULL != p) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
729 |
cmsICCHeader hdr = { 0 }; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
730 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
731 |
/* Populate the placeholder's header according to target profile */ |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
732 |
hdr.flags = cmsGetHeaderFlags(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
733 |
hdr.renderingIntent = cmsGetHeaderRenderingIntent(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
734 |
hdr.manufacturer = cmsGetHeaderManufacturer(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
735 |
hdr.model = cmsGetHeaderModel(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
736 |
hdr.pcs = cmsGetPCS(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
737 |
hdr.colorSpace = cmsGetColorSpace(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
738 |
hdr.deviceClass = cmsGetDeviceClass(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
739 |
hdr.version = cmsGetEncodedICCversion(pfTarget); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
740 |
cmsGetHeaderAttributes(pfTarget, &hdr.attributes); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
741 |
cmsGetHeaderProfileID(pfTarget, (cmsUInt8Number*)&hdr.profileID); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
742 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
743 |
cmsSetHeaderFlags(p, hdr.flags); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
744 |
cmsSetHeaderManufacturer(p, hdr.manufacturer); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
745 |
cmsSetHeaderModel(p, hdr.model); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
746 |
cmsSetHeaderAttributes(p, hdr.attributes); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
747 |
cmsSetHeaderProfileID(p, (cmsUInt8Number*)&(hdr.profileID)); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
748 |
cmsSetHeaderRenderingIntent(p, hdr.renderingIntent); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
749 |
cmsSetPCS(p, hdr.pcs); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
750 |
cmsSetColorSpace(p, hdr.colorSpace); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
751 |
cmsSetDeviceClass(p, hdr.deviceClass); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
752 |
cmsSetEncodedICCversion(p, hdr.version); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
753 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
754 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
755 |
if (cmsWriteRawTag(p, sig, pData, size)) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
756 |
if (cmsSaveProfileToMem(p, NULL, &pfSize)) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
757 |
pfBuffer = malloc(pfSize); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
758 |
if (pfBuffer != NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
759 |
/* load raw profile data into the buffer */ |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
760 |
if (!cmsSaveProfileToMem(p, pfBuffer, &pfSize)) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
761 |
free(pfBuffer); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
762 |
pfBuffer = NULL; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
763 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
764 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
765 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
766 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
767 |
cmsCloseProfile(p); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
768 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
769 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
770 |
if (pfBuffer == NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
771 |
return FALSE; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
772 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
773 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
774 |
/* re-open the placeholder profile */ |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
775 |
p = cmsOpenProfileFromMem(pfBuffer, pfSize); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
776 |
free(pfBuffer); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
777 |
status = FALSE; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
778 |
|
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
779 |
if (p != NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
780 |
/* Note that pCookedTag points to internal structures of the placeholder, |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
781 |
* so this data is valid only while the placeholder is open. |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
782 |
*/ |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
783 |
void *pCookedTag = cmsReadTag(p, sig); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
784 |
if (pCookedTag != NULL) { |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
785 |
status = cmsWriteTag(pfTarget, sig, pCookedTag); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
786 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
787 |
pCookedTag = NULL; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
788 |
cmsCloseProfile(p); |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
789 |
} |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
790 |
return status; |
3a0ebf0b855d
7042594: 3 testis api/java_awt/Color/ICC_ProfileRGB/index.html fail against RI b138 OEL6x64.
bae
parents:
9035
diff
changeset
|
791 |
} |