Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccWrapper.cpp
Go to the documentation of this file.
1/** @file
2File: IccWrapper.h
3
4Contains: Header file for C Wrapper interface functions for CIccProfile
5and CIccCmm classes.
6
7Version: V1
8
9Copyright: (c) see ICC Software License
10*/
11
12/*
13* The ICC Software License, Version 0.2
14*
15*
16* Copyright (c) 2003-2016 The International Color Consortium. All rights
17* reserved.
18*
19* Redistribution and use in source and binary forms, with or without
20* modification, are permitted provided that the following conditions
21* are met:
22*
23* 1. Redistributions of source code must retain the above copyright
24* notice, this list of conditions and the following disclaimer.
25*
26* 2. Redistributions in binary form must reproduce the above copyright
27* notice, this list of conditions and the following disclaimer in
28* the documentation and/or other materials provided with the
29* distribution.
30*
31* 3. In the absence of prior written permission, the names "ICC" and "The
32* International Color Consortium" must not be used to imply that the
33* ICC organization endorses or promotes products derived from this
34* software.
35*
36*
37* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40* DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
41* ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48* SUCH DAMAGE.
49* ====================================================================
50*
51* This software consists of voluntary contributions made by many
52* individuals on behalf of the The International Color Consortium.
53*
54*
55* Membership in the ICC is encouraged when this software is used for
56* commercial purposes.
57*
58*
59* For more information on The International Color Consortium, please
60* see <http://www.color.org/>.
61*
62*
63*/
64
65#include "IccWrapper.h"
66#include "IccApplyBPC.h"
67
69{
70public:
72
73 virtual bool GetEnvVar(icSigCmmEnvVar sig, icFloatNumber &val);
74 virtual bool IndexedEnvVar(icUInt32Number nIndex, icSigCmmEnvVar &sig, icFloatNumber &val);
75protected:
77};
78
80{
81 if (!m_pVars || !m_pVars->sigs || !m_pVars->vals) {
82 val = 0;
83 return false;
84 }
85
87 for (i = 0; i < m_pVars->nVars; i++) {
88 if (sig == m_pVars->sigs[i]) {
89 val = m_pVars->vals[i];
90 return true;
91 }
92 }
93 val = 0;
94 return false;
95}
96
98{
99 if (!m_pVars || !m_pVars->sigs || !m_pVars->vals) {
100 sig = (icSigCmmEnvVar)0;
101 val = 0;
102 return false;
103 }
104
105 if (nIndex < m_pVars->nVars) {
106 sig = m_pVars->sigs[nIndex];
107 val = m_pVars->vals[nIndex];
108 return true;
109 }
110
111 sig = (icSigCmmEnvVar)0;
112 val = 0;
113 return false;
114}
115
116class CIccCmmEnvVarWrapperHint : public CIccCreateCmmEnvVarXformHint
117{
118public:
120
122protected:
124};
125
126CIccCmmHandle* IccCmmCreate(icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace, unsigned char bFirstIsInput)
127{
128 return (CIccCmmHandle*)new CIccCmm(srcSpace, dstSpace, bFirstIsInput != 0);
129}
130
132 const char *szFname,
133 icRenderingIntent nIntent,
134 icXformInterp nInterp,
135 CIccProfileHandle *pPcc, //may be NULL (ownership not taken)
136 icXformLutType nLutType,
137 unsigned char bUseDtoBTags,
138 unsigned char bUseBPC,
139 SIccCmmEnvVars *pVars) //may be NULL (ownership not taken)
140{
141 if (!pCmm)
142 return icCmmStatBad;
143
144 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
145
146 CIccCreateXformHintManager hint;
147 bool bUseHint = false;
148
149 if (bUseBPC) {
150 hint.AddHint(new CIccApplyBPCHint());
151 bUseHint = true;
152 }
153
154 if (pVars) {
155 hint.AddHint(new CIccCmmEnvVarWrapperHint(pVars));
156 bUseHint = true;
157 }
158
159 return pCmmPtr->AddXform(szFname, nIntent, nInterp, (CIccProfile*)pPcc, nLutType, bUseDtoBTags != 0, bUseHint ? &hint : NULL);
160}
161
163 CIccProfileHandle *pProfile, // CMM assumes ownership of profile
164 icRenderingIntent nIntent,
165 icXformInterp nInterp,
166 CIccProfileHandle *pPcc,
167 icXformLutType nLutType,
168 unsigned char bUseDtoBTags,
169 unsigned char bUseBPC,
170 SIccCmmEnvVars *pVars)
171{
172 if (!pCmm)
173 return icCmmStatBad;
174
175 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
176 CIccProfile *pProfilePtr = (CIccProfile*)pProfile;
177
178 CIccCreateXformHintManager hint;
179 bool bUseHint = false;
180
181 if (bUseBPC) {
182 hint.AddHint(new CIccApplyBPCHint());
183 bUseHint = true;
184 }
185
186 if (pVars) {
187 hint.AddHint(new CIccCmmEnvVarWrapperHint(pVars));
188 bUseHint = true;
189 }
190
191 return pCmmPtr->AddXform(pProfilePtr, nIntent, nInterp, (CIccProfile*)pPcc, nLutType, bUseDtoBTags != 0, bUseHint ? &hint : NULL);
192}
193
195{
196 if (!pCmm)
197 return icCmmStatBad;
198
199 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
200
201 return pCmmPtr->Begin();
202}
203
205{
206 if (!pCmm)
207 return NULL;
208
209 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
210
211 return (CIccApplyHandle*)pCmmPtr->GetApply();
212}
213
215{
216 if (!pCmm || !pCmmInfo)
217 return icCmmStatBad;
218
219 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
220
221 pCmmInfo->srcSpace = pCmmPtr->GetSourceSpace();
222 pCmmInfo->srcSamples = pCmmPtr->GetSourceSamples();
223 pCmmInfo->dstSpace = pCmmPtr->GetDestSpace();
224 pCmmInfo->dstSamples = pCmmPtr->GetDestSamples();
225
226 return icCmmStatOk;
227}
228
230{
231 if (!pCmm || !pTo || !pFrom)
232 return icCmmStatBad;
233
234 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
235
236 return pCmmPtr->Apply(pTo, pFrom);
237}
238
240{
241 if (!pCmm || !pTo || !pFrom)
242 return icCmmStatBad;
243
244 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
245
246 return pCmmPtr->Apply(pTo, pFrom, nPixels);
247}
248
250{
251 if (pCmm) {
252 CIccCmm *pCmmPtr = (CIccCmm*)pCmm;
253 delete pCmmPtr;
254 }
255}
256
258{
259 if (!pApply || !pTo || !pFrom)
260 return icCmmStatBad;
261
262 CIccApplyCmm *pApplyPtr = (CIccApplyCmm*)pApply;
263
264 return pApplyPtr->Apply(pTo, pFrom);
265}
266
268{
269 if (!pApply || !pTo || !pFrom)
270 return icCmmStatBad;
271
272 CIccApplyCmm *pApplyPtr = (CIccApplyCmm*)pApply;
273
274 return pApplyPtr->Apply(pTo, pFrom, nPixels);
275}
276
278{
279 if (pApply) {
280 CIccApplyCmm *pApplyPtr = (CIccApplyCmm*)pApply;
281 delete pApplyPtr;
282 }
283}
284
286{
287 return (CIccProfileHandle*)ReadIccProfile(szFname);
288}
289
291{
292 return (CIccProfileHandle*)OpenIccProfile(szFname);
293}
295{
296 if (!pProfile || !pHeader)
297 return 0;
298
299 CIccProfile *pProfilePtr = (CIccProfile*)pProfile;
300
301 *pHeader = pProfilePtr->m_Header;
302
303 return 1;
304}
305
307{
308 if (pProfile) {
309 CIccProfileHandle *pProfilePtr = (CIccProfileHandle*)pProfile;
310 delete pProfilePtr;
311 }
312}
313
File: IccApplyBPC.h.
icArraySignature sig
icXformLutType
CMM Xform LUT types.
Definition IccCmm.h:125
icXformInterp
CMM Interpolation types.
Definition IccCmm.h:113
icStatusCMM
CMM return status values.
Definition IccCmm.h:90
@ icCmmStatBad
Definition IccCmm.h:91
@ icCmmStatOk
Definition IccCmm.h:92
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
#define ICCPROFLIB_API
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: ReadIccProfile.
CIccProfile * OpenIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: OpenIccProfile.
CIccCmmHandle * IccCmmCreate(icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace, unsigned char bFirstIsInput)
CIccApplyHandle * IccCmmGetApply(CIccCmmHandle *pCmm)
icStatusCMM IccCmmGetInfo(CIccCmmHandle *pCmm, SIccCmmStruct *pCmmInfo)
icStatusCMM IccCmmAttachProfileFile(CIccCmmHandle *pCmm, const char *szFname, icRenderingIntent nIntent, icXformInterp nInterp, CIccProfileHandle *pPcc, icXformLutType nLutType, unsigned char bUseDtoBTags, unsigned char bUseBPC, SIccCmmEnvVars *pVars)
icBoolean IccProfileGetHeader(CIccProfileHandle *pProfile, icHeader *pHeader)
void IccApplyFree(CIccApplyHandle *pApply)
void IccCmmFree(CIccCmmHandle *pCmm)
CIccProfileHandle * IccProfileReadHandle(const char *szFname)
icStatusCMM IccCmmApplyFloatMulti(CIccCmmHandle *pCmm, icFloatNumber *pTo, icFloatNumber *pFrom, icUInt32Number nPixels)
CIccProfileHandle * IccProfileOpenHandle(const char *szFname)
void IccProfileFree(CIccProfileHandle *pProfile)
icStatusCMM IccCmmBegin(CIccCmmHandle *pCmm)
icStatusCMM IccCmmApplyFloat(CIccCmmHandle *pCmm, icFloatNumber *pTo, icFloatNumber *pFrom)
icStatusCMM IccApplyApplyFloat(CIccApplyHandle *pApply, icFloatNumber *pTo, icFloatNumber *pFrom)
icStatusCMM IccApplyApplyFloatMulti(CIccApplyHandle *pApply, icFloatNumber *pTo, icFloatNumber *pFrom, icUInt32Number nPixels)
icStatusCMM IccCmmAttachProfileHandle(CIccCmmHandle *pCmm, CIccProfileHandle *pProfile, icRenderingIntent nIntent, icXformInterp nInterp, CIccProfileHandle *pPcc, icXformLutType nLutType, unsigned char bUseDtoBTags, unsigned char bUseBPC, SIccCmmEnvVars *pVars)
File: IccWrapper.h.
void CIccCmmHandle
Definition IccWrapper.h:76
void CIccProfileHandle
Definition IccWrapper.h:78
void CIccApplyHandle
Definition IccWrapper.h:77
unsigned char icBoolean
Definition IccWrapper.h:93
unsigned int icUInt32Number
Type: Class.
Definition IccApplyBPC.h:89
SIccCmmEnvVars * m_pVars
virtual IIccCmmEnvVarLookup * GetNewCmmEnvVarLookup() const
CIccCmmEnvVarWrapperHint(SIccCmmEnvVars *pVars)
CIccCmmEnvVarsWrapper(SIccCmmEnvVars *pVars)
virtual bool GetEnvVar(icSigCmmEnvVar sig, icFloatNumber &val)
virtual bool IndexedEnvVar(icUInt32Number nIndex, icSigCmmEnvVar &sig, icFloatNumber &val)
SIccCmmEnvVars * m_pVars
Type: Class.
Definition IccUtil.h:401
icColorSpaceSignature
Color Space Signatures.
icRenderingIntent
Rendering Intents, used in the profile header.
icSigCmmEnvVar
icSigCmmEnvVar * sigs
Definition IccWrapper.h:89
icUInt32Number nVars
Definition IccWrapper.h:88
icFloat32Number * vals
Definition IccWrapper.h:90
icColorSpaceSignature dstSpace
Definition IccWrapper.h:82
icUInt16Number srcSamples
Definition IccWrapper.h:83
icUInt16Number dstSamples
Definition IccWrapper.h:84
icColorSpaceSignature srcSpace
Definition IccWrapper.h:81
The Profile header.