95 #endif |
96 #endif |
96 |
97 |
97 typedef struct lcmsProfile_s { |
98 typedef struct lcmsProfile_s { |
98 cmsHPROFILE pf; |
99 cmsHPROFILE pf; |
99 } lcmsProfile_t, *lcmsProfile_p; |
100 } lcmsProfile_t, *lcmsProfile_p; |
100 |
|
101 typedef union storeID_s { /* store SProfile stuff in a Java Long */ |
|
102 lcmsProfile_p lcmsPf; |
|
103 cmsHTRANSFORM xf; |
|
104 jobject jobj; |
|
105 jlong j; |
|
106 } storeID_t, *storeID_p; |
|
107 |
101 |
108 typedef union { |
102 typedef union { |
109 cmsTagSignature cms; |
103 cmsTagSignature cms; |
110 jint j; |
104 jint j; |
111 } TagSignature_t, *TagSignature_p; |
105 } TagSignature_t, *TagSignature_p; |
146 cmsSetLogErrorHandler(errorHandler); |
140 cmsSetLogErrorHandler(errorHandler); |
147 return JNI_VERSION_1_6; |
141 return JNI_VERSION_1_6; |
148 } |
142 } |
149 |
143 |
150 void LCMS_freeProfile(JNIEnv *env, jlong ptr) { |
144 void LCMS_freeProfile(JNIEnv *env, jlong ptr) { |
151 storeID_t sProfile; |
145 lcmsProfile_p p = (lcmsProfile_p)jlong_to_ptr(ptr); |
152 sProfile.j = ptr; |
146 |
153 |
147 if (p != NULL) { |
154 if (sProfile.lcmsPf != NULL) { |
148 if (p->pf != NULL) { |
155 if (sProfile.lcmsPf->pf != NULL) { |
149 cmsCloseProfile(p->pf); |
156 cmsCloseProfile(sProfile.lcmsPf->pf); |
150 } |
157 } |
151 free(p); |
158 free(sProfile.lcmsPf); |
|
159 } |
152 } |
160 } |
153 } |
161 |
154 |
162 void LCMS_freeTransform(JNIEnv *env, jlong ID) |
155 void LCMS_freeTransform(JNIEnv *env, jlong ID) |
163 { |
156 { |
164 storeID_t sTrans; |
157 cmsHTRANSFORM sTrans = jlong_to_ptr(ID); |
165 sTrans.j = ID; |
|
166 /* Passed ID is always valid native ref so there is no check for zero */ |
158 /* Passed ID is always valid native ref so there is no check for zero */ |
167 cmsDeleteTransform(sTrans.xf); |
159 cmsDeleteTransform(sTrans); |
168 } |
160 } |
169 |
161 |
170 /* |
162 /* |
171 * Class: sun_java2d_cmm_lcms_LCMS |
163 * Class: sun_java2d_cmm_lcms_LCMS |
172 * Method: createNativeTransform |
164 * Method: createNativeTransform |
177 jint inFormatter, jboolean isInIntPacked, |
169 jint inFormatter, jboolean isInIntPacked, |
178 jint outFormatter, jboolean isOutIntPacked, jobject disposerRef) |
170 jint outFormatter, jboolean isOutIntPacked, jobject disposerRef) |
179 { |
171 { |
180 cmsHPROFILE _iccArray[DF_ICC_BUF_SIZE]; |
172 cmsHPROFILE _iccArray[DF_ICC_BUF_SIZE]; |
181 cmsHPROFILE *iccArray = &_iccArray[0]; |
173 cmsHPROFILE *iccArray = &_iccArray[0]; |
182 storeID_t sTrans; |
174 cmsHTRANSFORM sTrans = NULL; |
183 int i, j, size; |
175 int i, j, size; |
184 jlong* ids; |
176 jlong* ids; |
185 |
177 |
186 size = (*env)->GetArrayLength (env, profileIDs); |
178 size = (*env)->GetArrayLength (env, profileIDs); |
187 ids = (*env)->GetLongArrayElements(env, profileIDs, 0); |
179 ids = (*env)->GetLongArrayElements(env, profileIDs, 0); |
211 } |
203 } |
212 } |
204 } |
213 |
205 |
214 j = 0; |
206 j = 0; |
215 for (i = 0; i < size; i++) { |
207 for (i = 0; i < size; i++) { |
216 cmsHPROFILE icc; |
|
217 cmsColorSpaceSignature cs; |
208 cmsColorSpaceSignature cs; |
218 |
209 lcmsProfile_p profilePtr = (lcmsProfile_p)jlong_to_ptr(ids[i]); |
219 sTrans.j = ids[i]; |
210 cmsHPROFILE icc = profilePtr->pf; |
220 icc = sTrans.lcmsPf->pf; |
211 |
221 iccArray[j++] = icc; |
212 iccArray[j++] = icc; |
222 |
213 |
223 /* Middle non-abstract profiles should be doubled before passing to |
214 /* Middle non-abstract profiles should be doubled before passing to |
224 * the cmsCreateMultiprofileTransform function |
215 * the cmsCreateMultiprofileTransform function |
225 */ |
216 */ |
230 { |
221 { |
231 iccArray[j++] = icc; |
222 iccArray[j++] = icc; |
232 } |
223 } |
233 } |
224 } |
234 |
225 |
235 sTrans.xf = cmsCreateMultiprofileTransform(iccArray, j, |
226 sTrans = cmsCreateMultiprofileTransform(iccArray, j, |
236 inFormatter, outFormatter, renderType, 0); |
227 inFormatter, outFormatter, renderType, 0); |
237 |
228 |
238 (*env)->ReleaseLongArrayElements(env, profileIDs, ids, 0); |
229 (*env)->ReleaseLongArrayElements(env, profileIDs, ids, 0); |
239 |
230 |
240 if (sTrans.xf == NULL) { |
231 if (sTrans == NULL) { |
241 J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_createNativeTransform: " |
232 J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_createNativeTransform: " |
242 "sTrans.xf == NULL"); |
233 "sTrans == NULL"); |
243 if ((*env)->ExceptionOccurred(env) == NULL) { |
234 if ((*env)->ExceptionOccurred(env) == NULL) { |
244 JNU_ThrowByName(env, "java/awt/color/CMMException", |
235 JNU_ThrowByName(env, "java/awt/color/CMMException", |
245 "Cannot get color transform"); |
236 "Cannot get color transform"); |
246 } |
237 } |
247 } else { |
238 } else { |
248 Disposer_AddRecord(env, disposerRef, LCMS_freeTransform, sTrans.j); |
239 Disposer_AddRecord(env, disposerRef, LCMS_freeTransform, ptr_to_jlong(sTrans)); |
249 } |
240 } |
250 |
241 |
251 if (iccArray != &_iccArray[0]) { |
242 if (iccArray != &_iccArray[0]) { |
252 free(iccArray); |
243 free(iccArray); |
253 } |
244 } |
254 return sTrans.j; |
245 return ptr_to_jlong(sTrans); |
255 } |
246 } |
256 |
247 |
257 |
248 |
258 /* |
249 /* |
259 * Class: sun_java2d_cmm_lcms_LCMS |
250 * Class: sun_java2d_cmm_lcms_LCMS |
263 JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_loadProfileNative |
254 JNIEXPORT jlong JNICALL Java_sun_java2d_cmm_lcms_LCMS_loadProfileNative |
264 (JNIEnv *env, jobject obj, jbyteArray data, jobject disposerRef) |
255 (JNIEnv *env, jobject obj, jbyteArray data, jobject disposerRef) |
265 { |
256 { |
266 jbyte* dataArray; |
257 jbyte* dataArray; |
267 jint dataSize; |
258 jint dataSize; |
268 storeID_t sProf; |
259 lcmsProfile_p sProf = NULL; |
269 cmsHPROFILE pf; |
260 cmsHPROFILE pf; |
270 |
261 |
271 if (JNU_IsNull(env, data)) { |
262 if (JNU_IsNull(env, data)) { |
272 JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); |
263 JNU_ThrowIllegalArgumentException(env, "Invalid profile data"); |
273 return 0L; |
264 return 0L; |
274 } |
265 } |
275 |
|
276 sProf.j = 0L; |
|
277 |
266 |
278 dataArray = (*env)->GetByteArrayElements (env, data, 0); |
267 dataArray = (*env)->GetByteArrayElements (env, data, 0); |
279 if (dataArray == NULL) { |
268 if (dataArray == NULL) { |
280 // An exception should have already been thrown. |
269 // An exception should have already been thrown. |
281 return 0L; |
270 return 0L; |
305 } |
294 } |
306 } |
295 } |
307 |
296 |
308 if (pf != NULL) { |
297 if (pf != NULL) { |
309 // create profile holder |
298 // create profile holder |
310 sProf.lcmsPf = (lcmsProfile_p)malloc(sizeof(lcmsProfile_t)); |
299 sProf = (lcmsProfile_p)malloc(sizeof(lcmsProfile_t)); |
311 if (sProf.lcmsPf != NULL) { |
300 if (sProf != NULL) { |
312 // register the disposer record |
301 // register the disposer record |
313 sProf.lcmsPf->pf = pf; |
302 sProf->pf = pf; |
314 Disposer_AddRecord(env, disposerRef, LCMS_freeProfile, sProf.j); |
303 Disposer_AddRecord(env, disposerRef, LCMS_freeProfile, ptr_to_jlong(sProf)); |
315 } else { |
304 } else { |
316 cmsCloseProfile(pf); |
305 cmsCloseProfile(pf); |
317 } |
306 } |
318 } |
307 } |
319 |
308 |
320 return sProf.j; |
309 return ptr_to_jlong(sProf); |
321 } |
310 } |
322 |
311 |
323 /* |
312 /* |
324 * Class: sun_java2d_cmm_lcms_LCMS |
313 * Class: sun_java2d_cmm_lcms_LCMS |
325 * Method: getProfileSizeNative |
314 * Method: getProfileSizeNative |
326 * Signature: (J)I |
315 * Signature: (J)I |
327 */ |
316 */ |
328 JNIEXPORT jint JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileSizeNative |
317 JNIEXPORT jint JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileSizeNative |
329 (JNIEnv *env, jobject obj, jlong id) |
318 (JNIEnv *env, jobject obj, jlong id) |
330 { |
319 { |
331 storeID_t sProf; |
320 lcmsProfile_p sProf = (lcmsProfile_p)jlong_to_ptr(id); |
332 cmsUInt32Number pfSize = 0; |
321 cmsUInt32Number pfSize = 0; |
333 sProf.j = id; |
322 |
334 |
323 if (cmsSaveProfileToMem(sProf->pf, NULL, &pfSize) && ((jint)pfSize > 0)) { |
335 if (cmsSaveProfileToMem(sProf.lcmsPf->pf, NULL, &pfSize) && ((jint)pfSize > 0)) { |
|
336 return (jint)pfSize; |
324 return (jint)pfSize; |
337 } else { |
325 } else { |
338 JNU_ThrowByName(env, "java/awt/color/CMMException", |
326 JNU_ThrowByName(env, "java/awt/color/CMMException", |
339 "Can not access specified profile."); |
327 "Can not access specified profile."); |
340 return -1; |
328 return -1; |
347 * Signature: (J[B)V |
335 * Signature: (J[B)V |
348 */ |
336 */ |
349 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileDataNative |
337 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_getProfileDataNative |
350 (JNIEnv *env, jobject obj, jlong id, jbyteArray data) |
338 (JNIEnv *env, jobject obj, jlong id, jbyteArray data) |
351 { |
339 { |
352 storeID_t sProf; |
340 lcmsProfile_p sProf = (lcmsProfile_p)jlong_to_ptr(id); |
353 jint size; |
341 jint size; |
354 jbyte* dataArray; |
342 jbyte* dataArray; |
355 cmsUInt32Number pfSize = 0; |
343 cmsUInt32Number pfSize = 0; |
356 cmsBool status; |
344 cmsBool status; |
357 |
345 |
358 sProf.j = id; |
|
359 |
|
360 // determine actual profile size |
346 // determine actual profile size |
361 if (!cmsSaveProfileToMem(sProf.lcmsPf->pf, NULL, &pfSize)) { |
347 if (!cmsSaveProfileToMem(sProf->pf, NULL, &pfSize)) { |
362 JNU_ThrowByName(env, "java/awt/color/CMMException", |
348 JNU_ThrowByName(env, "java/awt/color/CMMException", |
363 "Can not access specified profile."); |
349 "Can not access specified profile."); |
364 return; |
350 return; |
365 } |
351 } |
366 |
352 |
376 if (dataArray == NULL) { |
362 if (dataArray == NULL) { |
377 // An exception should have already been thrown. |
363 // An exception should have already been thrown. |
378 return; |
364 return; |
379 } |
365 } |
380 |
366 |
381 status = cmsSaveProfileToMem(sProf.lcmsPf->pf, dataArray, &pfSize); |
367 status = cmsSaveProfileToMem(sProf->pf, dataArray, &pfSize); |
382 |
368 |
383 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
369 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
384 |
370 |
385 if (!status) { |
371 if (!status) { |
386 JNU_ThrowByName(env, "java/awt/color/CMMException", |
372 JNU_ThrowByName(env, "java/awt/color/CMMException", |
401 * Signature: (JI[B)V |
387 * Signature: (JI[B)V |
402 */ |
388 */ |
403 JNIEXPORT jbyteArray JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagNative |
389 JNIEXPORT jbyteArray JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagNative |
404 (JNIEnv *env, jobject obj, jlong id, jint tagSig) |
390 (JNIEnv *env, jobject obj, jlong id, jint tagSig) |
405 { |
391 { |
406 storeID_t sProf; |
392 lcmsProfile_p sProf = (lcmsProfile_p)jlong_to_ptr(id); |
407 TagSignature_t sig; |
393 TagSignature_t sig; |
408 cmsInt32Number tagSize; |
394 cmsInt32Number tagSize; |
409 |
395 |
410 jbyte* dataArray = NULL; |
396 jbyte* dataArray = NULL; |
411 jbyteArray data = NULL; |
397 jbyteArray data = NULL; |
412 |
398 |
413 jint bufSize; |
399 jint bufSize; |
414 |
400 |
415 sProf.j = id; |
|
416 sig.j = tagSig; |
401 sig.j = tagSig; |
417 |
402 |
418 if (tagSig == SigHead) { |
403 if (tagSig == SigHead) { |
419 cmsBool status; |
404 cmsBool status; |
420 |
405 |
432 if (dataArray == NULL) { |
417 if (dataArray == NULL) { |
433 // An exception should have already been thrown. |
418 // An exception should have already been thrown. |
434 return NULL; |
419 return NULL; |
435 } |
420 } |
436 |
421 |
437 status = _getHeaderInfo(sProf.lcmsPf->pf, dataArray, bufSize); |
422 status = _getHeaderInfo(sProf->pf, dataArray, bufSize); |
438 |
423 |
439 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
424 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
440 |
425 |
441 if (!status) { |
426 if (!status) { |
442 JNU_ThrowByName(env, "java/awt/color/CMMException", |
427 JNU_ThrowByName(env, "java/awt/color/CMMException", |
445 } |
430 } |
446 |
431 |
447 return data; |
432 return data; |
448 } |
433 } |
449 |
434 |
450 if (cmsIsTag(sProf.lcmsPf->pf, sig.cms)) { |
435 if (cmsIsTag(sProf->pf, sig.cms)) { |
451 tagSize = cmsReadRawTag(sProf.lcmsPf->pf, sig.cms, NULL, 0); |
436 tagSize = cmsReadRawTag(sProf->pf, sig.cms, NULL, 0); |
452 } else { |
437 } else { |
453 JNU_ThrowByName(env, "java/awt/color/CMMException", |
438 JNU_ThrowByName(env, "java/awt/color/CMMException", |
454 "ICC profile tag not found"); |
439 "ICC profile tag not found"); |
455 return NULL; |
440 return NULL; |
456 } |
441 } |
467 if (dataArray == NULL) { |
452 if (dataArray == NULL) { |
468 // An exception should have already been thrown. |
453 // An exception should have already been thrown. |
469 return NULL; |
454 return NULL; |
470 } |
455 } |
471 |
456 |
472 bufSize = cmsReadRawTag(sProf.lcmsPf->pf, sig.cms, dataArray, tagSize); |
457 bufSize = cmsReadRawTag(sProf->pf, sig.cms, dataArray, tagSize); |
473 |
458 |
474 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
459 (*env)->ReleaseByteArrayElements (env, data, dataArray, 0); |
475 |
460 |
476 if (bufSize != tagSize) { |
461 if (bufSize != tagSize) { |
477 JNU_ThrowByName(env, "java/awt/color/CMMException", |
462 JNU_ThrowByName(env, "java/awt/color/CMMException", |
487 * Signature: (JI[B)V |
472 * Signature: (JI[B)V |
488 */ |
473 */ |
489 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_setTagDataNative |
474 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_setTagDataNative |
490 (JNIEnv *env, jobject obj, jlong id, jint tagSig, jbyteArray data) |
475 (JNIEnv *env, jobject obj, jlong id, jint tagSig, jbyteArray data) |
491 { |
476 { |
492 storeID_t sProf; |
477 lcmsProfile_p sProf = (lcmsProfile_p)jlong_to_ptr(id); |
493 cmsHPROFILE pfReplace = NULL; |
478 cmsHPROFILE pfReplace = NULL; |
494 |
479 |
495 TagSignature_t sig; |
480 TagSignature_t sig; |
496 cmsBool status = FALSE; |
481 cmsBool status = FALSE; |
497 jbyte* dataArray; |
482 jbyte* dataArray; |
498 int tagSize; |
483 int tagSize; |
499 |
484 |
500 sProf.j = id; |
|
501 sig.j = tagSig; |
485 sig.j = tagSig; |
502 |
486 |
503 if (JNU_IsNull(env, data)) { |
487 if (JNU_IsNull(env, data)) { |
504 JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
488 JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
505 return; |
489 return; |
513 // An exception should have already been thrown. |
497 // An exception should have already been thrown. |
514 return; |
498 return; |
515 } |
499 } |
516 |
500 |
517 if (tagSig == SigHead) { |
501 if (tagSig == SigHead) { |
518 status = _setHeaderInfo(sProf.lcmsPf->pf, dataArray, tagSize); |
502 status = _setHeaderInfo(sProf->pf, dataArray, tagSize); |
519 } else { |
503 } else { |
520 /* |
504 /* |
521 * New strategy for generic tags: create a place holder, |
505 * New strategy for generic tags: create a place holder, |
522 * dump all existing tags there, dump externally supplied |
506 * dump all existing tags there, dump externally supplied |
523 * tag, and return the new profile to the java. |
507 * tag, and return the new profile to the java. |
524 */ |
508 */ |
525 pfReplace = _writeCookedTag(sProf.lcmsPf->pf, sig.cms, dataArray, tagSize); |
509 pfReplace = _writeCookedTag(sProf->pf, sig.cms, dataArray, tagSize); |
526 status = (pfReplace != NULL); |
510 status = (pfReplace != NULL); |
527 } |
511 } |
528 |
512 |
529 (*env)->ReleaseByteArrayElements(env, data, dataArray, 0); |
513 (*env)->ReleaseByteArrayElements(env, data, dataArray, 0); |
530 |
514 |
531 if (!status) { |
515 if (!status) { |
532 JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
516 JNU_ThrowIllegalArgumentException(env, "Can not write tag data."); |
533 } else if (pfReplace != NULL) { |
517 } else if (pfReplace != NULL) { |
534 cmsCloseProfile(sProf.lcmsPf->pf); |
518 cmsCloseProfile(sProf->pf); |
535 sProf.lcmsPf->pf = pfReplace; |
519 sProf->pf = pfReplace; |
536 } |
520 } |
537 } |
521 } |
538 |
522 |
539 void* getILData (JNIEnv *env, jobject img, jint* pDataType, |
523 void* getILData (JNIEnv *env, jobject img, jint* pDataType, |
540 jobject* pDataObject) { |
524 jobject* pDataObject) { |
584 * Signature: (Lsun/java2d/cmm/lcms/LCMSTransform;Lsun/java2d/cmm/lcms/LCMSImageLayout;Lsun/java2d/cmm/lcms/LCMSImageLayout;)V |
568 * Signature: (Lsun/java2d/cmm/lcms/LCMSTransform;Lsun/java2d/cmm/lcms/LCMSImageLayout;Lsun/java2d/cmm/lcms/LCMSImageLayout;)V |
585 */ |
569 */ |
586 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert |
570 JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_colorConvert |
587 (JNIEnv *env, jclass obj, jobject trans, jobject src, jobject dst) |
571 (JNIEnv *env, jclass obj, jobject trans, jobject src, jobject dst) |
588 { |
572 { |
589 storeID_t sTrans; |
573 cmsHTRANSFORM sTrans = NULL; |
590 int srcDType, dstDType; |
574 int srcDType, dstDType; |
591 int srcOffset, srcNextRowOffset, dstOffset, dstNextRowOffset; |
575 int srcOffset, srcNextRowOffset, dstOffset, dstNextRowOffset; |
592 int width, height, i; |
576 int width, height, i; |
593 void* inputBuffer; |
577 void* inputBuffer; |
594 void* outputBuffer; |
578 void* outputBuffer; |
605 height = (*env)->GetIntField (env, src, IL_height_fID); |
589 height = (*env)->GetIntField (env, src, IL_height_fID); |
606 |
590 |
607 srcAtOnce = (*env)->GetBooleanField(env, src, IL_imageAtOnce_fID); |
591 srcAtOnce = (*env)->GetBooleanField(env, src, IL_imageAtOnce_fID); |
608 dstAtOnce = (*env)->GetBooleanField(env, dst, IL_imageAtOnce_fID); |
592 dstAtOnce = (*env)->GetBooleanField(env, dst, IL_imageAtOnce_fID); |
609 |
593 |
610 sTrans.j = (*env)->GetLongField (env, trans, Trans_ID_fID); |
594 sTrans = jlong_to_ptr((*env)->GetLongField (env, trans, Trans_ID_fID)); |
611 |
595 |
612 if (sTrans.xf == NULL) { |
596 if (sTrans == NULL) { |
613 J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_colorConvert: transform == NULL"); |
597 J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_colorConvert: transform == NULL"); |
614 JNU_ThrowByName(env, "java/awt/color/CMMException", |
598 JNU_ThrowByName(env, "java/awt/color/CMMException", |
615 "Cannot get color transform"); |
599 "Cannot get color transform"); |
616 return; |
600 return; |
617 } |
601 } |
635 |
619 |
636 inputRow = (char*)inputBuffer + srcOffset; |
620 inputRow = (char*)inputBuffer + srcOffset; |
637 outputRow = (char*)outputBuffer + dstOffset; |
621 outputRow = (char*)outputBuffer + dstOffset; |
638 |
622 |
639 if (srcAtOnce && dstAtOnce) { |
623 if (srcAtOnce && dstAtOnce) { |
640 cmsDoTransform(sTrans.xf, inputRow, outputRow, width * height); |
624 cmsDoTransform(sTrans, inputRow, outputRow, width * height); |
641 } else { |
625 } else { |
642 for (i = 0; i < height; i++) { |
626 for (i = 0; i < height; i++) { |
643 cmsDoTransform(sTrans.xf, inputRow, outputRow, width); |
627 cmsDoTransform(sTrans, inputRow, outputRow, width); |
644 inputRow += srcNextRowOffset; |
628 inputRow += srcNextRowOffset; |
645 outputRow += dstNextRowOffset; |
629 outputRow += dstNextRowOffset; |
646 } |
630 } |
647 } |
631 } |
648 |
632 |
750 cmsUInt8Number* pfBuffer = NULL; |
734 cmsUInt8Number* pfBuffer = NULL; |
751 cmsBool status = FALSE; |
735 cmsBool status = FALSE; |
752 |
736 |
753 if (!cmsSaveProfileToMem(pf, NULL, &pfSize) || |
737 if (!cmsSaveProfileToMem(pf, NULL, &pfSize) || |
754 pfSize < sizeof(cmsICCHeader) || |
738 pfSize < sizeof(cmsICCHeader) || |
755 bufferSize < sizeof(cmsICCHeader)) |
739 bufferSize < (jint)sizeof(cmsICCHeader)) |
756 { |
740 { |
757 return FALSE; |
741 return FALSE; |
758 } |
742 } |
759 |
743 |
760 pfBuffer = malloc(pfSize); |
744 pfBuffer = malloc(pfSize); |
771 return status; |
755 return status; |
772 } |
756 } |
773 |
757 |
774 static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize) |
758 static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize) |
775 { |
759 { |
776 cmsICCHeader pfHeader = { 0 }; |
760 cmsICCHeader pfHeader; |
777 |
761 |
778 if (pBuffer == NULL || bufferSize < sizeof(cmsICCHeader)) { |
762 if (pBuffer == NULL || bufferSize < (jint)sizeof(cmsICCHeader)) { |
779 return FALSE; |
763 return FALSE; |
780 } |
764 } |
781 |
765 |
782 memcpy(&pfHeader, pBuffer, sizeof(cmsICCHeader)); |
766 memcpy(&pfHeader, pBuffer, sizeof(cmsICCHeader)); |
783 |
767 |
806 cmsUInt32Number pfSize = 0; |
790 cmsUInt32Number pfSize = 0; |
807 const cmsInt32Number tagCount = cmsGetTagCount(pfTarget); |
791 const cmsInt32Number tagCount = cmsGetTagCount(pfTarget); |
808 cmsInt32Number i; |
792 cmsInt32Number i; |
809 cmsHPROFILE pfSanity = NULL; |
793 cmsHPROFILE pfSanity = NULL; |
810 |
794 |
811 cmsICCHeader hdr = { 0 }; |
795 cmsICCHeader hdr; |
812 |
796 |
813 cmsHPROFILE p = cmsCreateProfilePlaceholder(NULL); |
797 cmsHPROFILE p = cmsCreateProfilePlaceholder(NULL); |
814 |
798 |
815 if (NULL == p) { |
799 if (NULL == p) { |
816 return NULL; |
800 return NULL; |
817 } |
801 } |
|
802 memset(&hdr, 0, sizeof(cmsICCHeader)); |
818 |
803 |
819 // Populate the placeholder's header according to target profile |
804 // Populate the placeholder's header according to target profile |
820 hdr.flags = cmsGetHeaderFlags(pfTarget); |
805 hdr.flags = cmsGetHeaderFlags(pfTarget); |
821 hdr.renderingIntent = cmsGetHeaderRenderingIntent(pfTarget); |
806 hdr.renderingIntent = cmsGetHeaderRenderingIntent(pfTarget); |
822 hdr.manufacturer = cmsGetHeaderManufacturer(pfTarget); |
807 hdr.manufacturer = cmsGetHeaderManufacturer(pfTarget); |