< prev index next >

src/java.desktop/share/native/liblcms/LCMS.c

Print this page

  1 /*
  2  * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
  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
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 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  *
 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

171     j = 0;
172     for (i = 0; i < size; i++) {
173         cmsColorSpaceSignature cs;
174         lcmsProfile_p profilePtr = (lcmsProfile_p)jlong_to_ptr(ids[i]);
175         cmsHPROFILE icc = profilePtr->pf;
176 
177         iccArray[j++] = icc;
178 
179         /* Middle non-abstract profiles should be doubled before passing to
180          * the cmsCreateMultiprofileTransform function
181          */
182 
183         cs = cmsGetColorSpace(icc);
184         if (size > 2 && i != 0 && i != size - 1 &&
185             cs != cmsSigXYZData && cs != cmsSigLabData)
186         {
187             iccArray[j++] = icc;
188         }
189     }
190 





191     sTrans = cmsCreateMultiprofileTransform(iccArray, j,
192         inFormatter, outFormatter, renderingIntent, cmsFLAGS_COPY_ALPHA);
193 
194     (*env)->ReleaseLongArrayElements(env, profileIDs, ids, 0);
195 
196     if (sTrans == NULL) {
197         J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_createNativeTransform: "
198                                        "sTrans == NULL");
199         if (!(*env)->ExceptionCheck(env)) { // errorHandler may throw it
200             JNU_ThrowByName(env, "java/awt/color/CMMException",
201                             "Cannot get color transform");
202         }
203     } else {
204         Disposer_AddRecord(env, disposerRef, LCMS_freeTransform, ptr_to_jlong(sTrans));
205     }
206 
207     if (iccArray != &_iccArray[0]) {
208         free(iccArray);
209     }
210     return ptr_to_jlong(sTrans);
211 }
212 

  1 /*
  2  * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
  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
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 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  *
 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

171     j = 0;
172     for (i = 0; i < size; i++) {
173         cmsColorSpaceSignature cs;
174         lcmsProfile_p profilePtr = (lcmsProfile_p)jlong_to_ptr(ids[i]);
175         cmsHPROFILE icc = profilePtr->pf;
176 
177         iccArray[j++] = icc;
178 
179         /* Middle non-abstract profiles should be doubled before passing to
180          * the cmsCreateMultiprofileTransform function
181          */
182 
183         cs = cmsGetColorSpace(icc);
184         if (size > 2 && i != 0 && i != size - 1 &&
185             cs != cmsSigXYZData && cs != cmsSigLabData)
186         {
187             iccArray[j++] = icc;
188         }
189     }
190 
191     cmsUInt32Number dwFlags = 0;
192     if (T_EXTRA(inFormatter) > 0 && T_EXTRA(outFormatter) > 0) {
193         dwFlags |= cmsFLAGS_COPY_ALPHA;
194     }
195 
196     sTrans = cmsCreateMultiprofileTransform(iccArray, j,
197         inFormatter, outFormatter, renderingIntent, dwFlags);
198 
199     (*env)->ReleaseLongArrayElements(env, profileIDs, ids, 0);
200 
201     if (sTrans == NULL) {
202         J2dRlsTraceLn(J2D_TRACE_ERROR, "LCMS_createNativeTransform: "
203                                        "sTrans == NULL");
204         if (!(*env)->ExceptionCheck(env)) { // errorHandler may throw it
205             JNU_ThrowByName(env, "java/awt/color/CMMException",
206                             "Cannot get color transform");
207         }
208     } else {
209         Disposer_AddRecord(env, disposerRef, LCMS_freeTransform, ptr_to_jlong(sTrans));
210     }
211 
212     if (iccArray != &_iccArray[0]) {
213         free(iccArray);
214     }
215     return ptr_to_jlong(sTrans);
216 }
217 
< prev index next >