Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccProfile.h
Go to the documentation of this file.
1/** @file
2 File: IccProfile.h
3
4 Contains: Header for implementation of the CIccProfile class.
5
6 Version: V1
7
8 Copyright: (c) see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Initial implementation by Max Derhak 5-15-2003
68//
69//////////////////////////////////////////////////////////////////////
70
71#if !defined(_ICCPROFILE_H)
72#define _ICCPROFILE_H
73
74#include "IccDefs.h"
75#include "IccPcc.h"
76#include <list>
77#include <string>
78
79#if defined(__cplusplus) && defined(USEREFICCMAXNAMESPACE)
80namespace refIccMAX {
81#endif
82
83#ifdef __cplusplus
84
88
89/**
90 **************************************************************************
91 * Type: Structure
92 *
93 * Purpose:
94 * This structure stores all the information of an individual tag
95 * including the header information (tag signature, offset and size).
96 **************************************************************************
97 */
98struct IccTagEntry
99{
100
101 icTag TagInfo;
102 CIccTag* pTag;
103};
104
105/**
106 **************************************************************************
107 * Type: List
108 *
109 * Purpose: List of all the tag entries.
110 *
111 **************************************************************************
112 */
113typedef std::list<IccTagEntry> TagEntryList;
114
115/**
116 **************************************************************************
117 * Type: Structure
118 *
119 * Purpose: Contains pointer to a tag.
120 **************************************************************************
121 */
122typedef struct {CIccTag *ptr;} IccTagPtr;
123
124/**
125 **************************************************************************
126 * Type: List
127 *
128 * Purpose: List of pointers to the tags.
129 *
130 **************************************************************************
131 */
132typedef std::list<IccTagPtr> TagPtrList;
133
134typedef enum {
135 icVersionBasedID,
136 icAlwaysWriteID,
137 icNeverWriteID,
138}icProfileIDSaveMethod;
139
140/**
141 **************************************************************************
142 * Type: Class
143 *
144 * Purpose:
145 * This is the base class for an ICC profile. All the operations
146 * on a profile is done using this object.
147 **************************************************************************
148 */
149class ICCPROFLIB_API CIccProfile : public IIccProfileConnectionConditions
150{
151public:
152 CIccProfile();
153 CIccProfile(const CIccProfile &Profile);
154 CIccProfile &operator=(const CIccProfile &Profile);
155 virtual CIccProfile* NewCopy() const { return new CIccProfile(*this); }
156 virtual CIccProfile* NewProfile() const { return new CIccProfile(); }
157 virtual ~CIccProfile();
158
159 virtual const char *GetClassName() const { return "CIccProfile"; }
160
161 icHeader m_Header;
162
163 TagEntryList *m_Tags;
164
165 CIccTag* FindTag(icSignature sig);
166 const CIccTag* FindTagConst(icSignature sig) const;
167 CIccTag* FindTagOfType(icSignature tagSig, icTagTypeSignature typeSig);
168
169 bool AttachTag(icSignature sig, CIccTag *pTag);
170 bool DeleteTag(icSignature sig);
171 CIccMemIO* GetTagIO(icSignature sig); //caller should delete returned result
172 bool ReadTags(CIccProfile* pProfile); // will read in all the tags using the IO of the passed profile
173
174 bool Attach(CIccIO *pIO, bool bUseSubProfile=false);
175 bool Detach();
176 bool HasIO() { return m_pAttachIO != NULL; }
177
178 bool Read(CIccIO *pIO, bool bUseSubProfile=false);
179 icValidateStatus ReadValidate(CIccIO *pIO, std::string &sReport);
180 bool Write(CIccIO *pIO, icProfileIDSaveMethod nWriteId=icVersionBasedID);
181
182 bool ReadProfileID(icProfileID &profileID); //works if HasIO() is true
183
184 void InitHeader();
185 icValidateStatus Validate(std::string &sReport, std::string sSigPath="") const;
186
187 icUInt16Number GetSpaceSamples() const;
188
189 bool AreTagsUnique() const;
190 bool IsTagPresent(icSignature sig) const { return (GetTag(sig)!=NULL); }
191
192
193 //Implement the IIccProfileConnectionConditions interface
194 virtual const CIccTagSpectralViewingConditions *getPccViewingConditions() { return (const CIccTagSpectralViewingConditions*)
197 virtual CIccTagMultiProcessElement *getCustomToStandardPcc() { return (CIccTagMultiProcessElement*)
198 FindTagOfType(icSigCustomToStandardPccTag,
200
201 virtual CIccTagMultiProcessElement *getStandardToCustomPcc() { return (CIccTagMultiProcessElement*)
202 FindTagOfType(icSigStandardToCustomPccTag,
204 virtual icIlluminant getPccIlluminant();
205 virtual icFloatNumber getPccCCT();
206 virtual icStandardObserver getPccObserver();
207 virtual void getNormIlluminantXYZ(icFloatNumber *pXYZ);
208 virtual void getLumIlluminantXYZ(icFloatNumber *pXYZ);
209 virtual bool getMediaWhiteXYZ(icFloatNumber *pXYZ);
210
211 bool calcNormIlluminantXYZ(icFloatNumber *pXYZ, IIccProfileConnectionConditions *pObservingPCC);
212 bool calcLumIlluminantXYZ(icFloatNumber *pXYZ, IIccProfileConnectionConditions *pObservingPCC);
213 bool calcMediaWhiteXYZ(icFloatNumber *pXYZ, IIccProfileConnectionConditions *pObservingPCC);
214
215protected:
216
217 void Cleanup();
218 IccTagEntry* GetTag(icSignature sig) const;
219 IccTagEntry* GetTag(CIccTag *pTag) const;
220 bool ReadBasic(CIccIO *pIO);
221 bool LoadTag(IccTagEntry *pTagEntry, CIccIO *pIO, bool bReadAll=false);
222 bool DetachTag(CIccTag *pTag);
223
224 CIccIO* ConnectSubProfile(CIccIO *pIO, bool bOwnIO) const;
225
226 // Profile Validation functions
227 icValidateStatus CheckRequiredTags(std::string &sReport) const;
228 bool CheckTagExclusion(std::string &sReport) const;
229 icValidateStatus CheckHeader(std::string &sReport) const;
230 icValidateStatus CheckTagTypes(std::string &sReport) const;
231 bool IsTypeValid(icTagSignature tagSig, icTagTypeSignature typeSig,
234 bool CheckFileSize(CIccIO *pIO) const;
235
236 CIccIO *m_pAttachIO;
237
238 TagPtrList *m_TagVals;
239};
240
241CIccProfile ICCPROFLIB_API *ReadIccProfile(const icChar *szFilename, bool bUseSubProfile=false);
242CIccProfile ICCPROFLIB_API *ReadIccProfile(const icUInt8Number *pMem, icUInt32Number nSize, bool bUseSubProfile=false);
243CIccProfile ICCPROFLIB_API *OpenIccProfile(const icChar *szFilename, bool bUseSubProfile=false);
244CIccProfile ICCPROFLIB_API *OpenIccProfile(const icUInt8Number *pMem, icUInt32Number nSize, bool bUseSubProfile=false); //pMem must be available for entire life of returned CIccProfile Object
245
246CIccProfile ICCPROFLIB_API *ValidateIccProfile(CIccIO *pIO, std::string &sReport, icValidateStatus &nStatus);
247CIccProfile ICCPROFLIB_API *ValidateIccProfile(const icChar *szFilename, std::string &sReport, icValidateStatus &nStatus);
248
249bool ICCPROFLIB_API SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId=icVersionBasedID);
250bool ICCPROFLIB_API SaveIccProfile(FILE *f, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId = icVersionBasedID);
251
252void ICCPROFLIB_API CalcProfileID(CIccIO *pIO, icProfileID *profileID);
253bool ICCPROFLIB_API CalcProfileID(const icChar *szFilename, icProfileID *profileID);
254
255#ifdef WIN32
256CIccProfile ICCPROFLIB_API *ReadIccProfile(const icWChar *szFilename, bool bUseSubProfile=false);
257CIccProfile ICCPROFLIB_API *OpenIccProfile(const icWChar *szFilename, bool bUseSubProfile=false);
258CIccProfile ICCPROFLIB_API *ValidateIccProfile(const icWChar *szFilename, std::string &sReport, icValidateStatus &nStatus);
259bool ICCPROFLIB_API SaveIccProfile(const icWChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId=icVersionBasedID);
260bool ICCPROFLIB_API CalcProfileID(const icWChar *szFilename, icProfileID *profileID);
261#endif
262
263
264typedef CIccProfile* CIccProfilePtr;
265
266#endif //__cplusplus
267
268#ifdef USEREFICCMAXNAMESPACE
269} //namespace refIccMAX
270#endif
271
272#endif // !defined(_ICCPROFILE_H)
icArraySignature sig
File: IccDefs.h
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
icValidateStatus
Definition IccDefs.h:118
File: IccPcc.h.
#define ICCPROFLIB_API
CIccProfile * ValidateIccProfile(CIccIO *pIO, std::string &sReport, icValidateStatus &nStatus)
Name: ValidateIccProfile.
bool SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId)
Name: SaveIccProfile.
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: ReadIccProfile.
CIccProfile * OpenIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: OpenIccProfile.
void CalcProfileID(CIccIO *pIO, icProfileID *pProfileID)
Name: CalcProfileID.
icTagTypeSignature
unsigned int icUInt32Number
Type: Class.
Definition IccIO.h:97
Type: Class.
Definition IccIO.h:217
Class: CIccTag.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
Class: CIccTagSpectralViewingConditions.
unsigned char icUInt8Number
Number definitions.
unsigned short icUInt16Number
icIlluminant
Pre-defined illuminants, used in measurement and viewing conditions type.
icUInt32Number icSignature
@ icSigMultiProcessElementType
@ icSigSpectralViewingConditionsType
icStructSignature
Tag Structure type signatures.
@ icSigUndefinedStruct
icArraySignature
Tag Array type signatures.
@ icSigUndefinedArray
icTagSignature
public tags and sizes
@ icSigSpectralViewingConditionsTag
@ icSigCustomToStandardPccTag
@ icSigStandardToCustomPccTag
icStandardObserver
Standard Observer, used in the measurmentType tag.
The Profile header.
Lists of tags, tags, profile header and profile structure.
Profile ID.