Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccMpeACS.cpp
Go to the documentation of this file.
1/** @file
2 File: IccMpeACS.cpp
3
4 Contains: Implementation of ACS Elements
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 1-30-2006
68//
69//////////////////////////////////////////////////////////////////////
70
71#ifdef WIN32
72#pragma warning( disable: 4786) //disable warning in <list.h>
73#endif
74
75#include <stdio.h>
76#include <math.h>
77#include <string.h>
78#include <stdlib.h>
79#include "IccMpeACS.h"
80#include "IccIO.h"
81#include <map>
82#include "IccUtil.h"
83
84#ifdef USEREFICCMAXNAMESPACE
85namespace refIccMAX {
86#endif
87
88
89/**
90******************************************************************************
91* Name: CIccMpeAcs::CIccMpeACS
92*
93* Purpose:
94* Base constructor (protected)
95******************************************************************************/
97{
98 m_pData = NULL;
99 m_nDataSize = 0;
100 m_signature = icSigAcsZero;
101 m_nReserved = 0;
102}
103
104/**
105******************************************************************************
106* Name: CIccMpeAcs::~CIccMpeAcs
107*
108* Purpose:
109* Base destructor
110******************************************************************************/
112{
113 if (m_pData)
114 free(m_pData);
115}
116
117/**
118******************************************************************************
119* Name: CIccMpeAcs::Describe
120*
121* Purpose:
122*
123* Args:
124*
125* Return:
126******************************************************************************/
127void CIccMpeAcs::Describe(std::string &sDescription, int nVerboseness)
128{
129 icChar sigBuf[30];
130
131 if (GetBAcsSig())
132 sDescription += "ELEM_bACS\n";
133 else
134 sDescription += "ELEM_eACS\n";
135
136 icGetSig(sigBuf, m_signature);
137 sDescription += " Signature = ";
138 sDescription += sigBuf;
139 sDescription += "\n";
140
141 if ((m_pData) && (nVerboseness > 50)) {
142 sDescription += "\nData Follows:\n";
143
144 icMemDump(sDescription, m_pData, m_nDataSize);
145 }
146}
147
148/**
149******************************************************************************
150* Name: CIccMpeAcs::Read
151*
152* Purpose:
153*
154* Args:
155*
156* Return:
157******************************************************************************/
159{
161
162 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
163 sizeof(icUInt32Number) +
164 sizeof(icUInt16Number) +
165 sizeof(icUInt16Number) +
166 sizeof(icUInt32Number);
167
168 if (headerSize > size)
169 return false;
170
171 if (!pIO) {
172 return false;
173 }
174
175 if (!pIO->Read32(&sig))
176 return false;
177
178 if (!pIO->Read32(&m_nReserved))
179 return false;
180
181 if (!pIO->Read16(&m_nInputChannels))
182 return false;
183
184 if (!pIO->Read16(&m_nOutputChannels))
185 return false;
186
187 if (!pIO->Read32(&m_signature))
188 return false;
189
190 icUInt32Number dataSize = size - headerSize;
191
192 if (!AllocData(dataSize))
193 return false;
194
195 if (dataSize) {
196 if (pIO->Read8(m_pData, dataSize)!=(icInt32Number)dataSize)
197 return false;
198 }
199
200 return true;
201}
202
203/**
204******************************************************************************
205* Name: CIccMpeAcs::Write
206*
207* Purpose:
208*
209* Args:
210*
211* Return:
212******************************************************************************/
214{
215 icElemTypeSignature sig = GetType();
216
217 if (!pIO)
218 return false;
219
220 if (!pIO->Write32(&sig))
221 return false;
222
223 if (!pIO->Write32(&m_nReserved))
224 return false;
225
226 if (!pIO->Write16(&m_nInputChannels))
227 return false;
228
229 if (!pIO->Write16(&m_nOutputChannels))
230 return false;
231
232 if (!pIO->Write32(&m_signature))
233 return false;
234
235 if (m_pData && m_nDataSize) {
236 if (pIO->Write8(m_pData, m_nDataSize)!=m_nDataSize)
237 return false;
238 }
239
240 return true;
241}
242
243/**
244******************************************************************************
245* Name: CIccMpeAcs::Begin
246*
247* Purpose:
248*
249* Args:
250*
251* Return:
252******************************************************************************/
254{
255 if (m_nInputChannels!=m_nOutputChannels)
256 return false;
257
258 return true;
259}
260
261/**
262******************************************************************************
263* Name: CIccMpeAcs::Apply
264*
265* Purpose:
266*
267* Args:
268*
269* Return:
270******************************************************************************/
271void CIccMpeAcs::Apply(CIccApplyMpe *pApply, icFloatNumber *dstPixel, const icFloatNumber *srcPixel) const
272{
273 memcpy(dstPixel, srcPixel, m_nInputChannels*sizeof(icFloatNumber));
274}
275
276/**
277******************************************************************************
278* Name: CIccMpeAcs::Validate
279*
280* Purpose:
281*
282* Args:
283*
284* Return:
285******************************************************************************/
286icValidateStatus CIccMpeAcs::Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement* pMPE/*=NULL*/, const CIccProfile *pProfile/*=NULL*/) const
287{
288 icValidateStatus rv = CIccMultiProcessElement::Validate(sigPath, sReport, pMPE, pProfile);
289
290 return rv;
291}
292
293/**
294******************************************************************************
295* Name: CIccMpeAcs::AllocData
296*
297* Purpose:
298*
299* Args:
300*
301* Return:
302******************************************************************************/
304{
305 if (m_pData)
306 free(m_pData);
307
308 if (size) {
309 m_pData = (icUInt8Number*)malloc(size);
310 if (m_pData)
311 m_nDataSize = size;
312 }
313 else {
314 m_pData = NULL;
315 m_nDataSize = 0;
316 }
317
318 return (size==0 || m_pData!=NULL);
319}
320
321
322/**
323******************************************************************************
324* Name: CIccMpeBeginAcs::CIccMpeBeginAcs
325*
326* Purpose:
327*
328* Args:
329*
330* Return:
331******************************************************************************/
332CIccMpeBAcs::CIccMpeBAcs(icUInt16Number nChannels/* =0 */, icAcsSignature sig /* = icSigUnknownAcs */)
333{
334 m_signature = sig;
335
336 m_nInputChannels = nChannels;
337 m_nOutputChannels = nChannels;
338}
339
340/**
341******************************************************************************
342* Name: CIccMpeBeginAcs::CIccMpeBeginAcs
343*
344* Purpose:
345*
346* Args:
347*
348* Return:
349******************************************************************************/
351{
352
353 m_signature = elemAcs.m_signature;
354 m_nReserved = elemAcs.m_nReserved;
355 m_nInputChannels = elemAcs.m_nInputChannels;
356 m_nOutputChannels = elemAcs.m_nOutputChannels;
357
358 m_pData = NULL;
359 m_nDataSize = 0;
360
361 AllocData(elemAcs.m_nDataSize);
362 if (m_pData && elemAcs.m_nDataSize) {
363 memcpy(m_pData, elemAcs.m_pData, m_nDataSize);
364 }
365
366 m_nReserved = 0;
367}
368
369/**
370******************************************************************************
371* Name: &CIccMpeBeginAcs::operator=
372*
373* Purpose:
374*
375* Args:
376*
377* Return:
378******************************************************************************/
380{
381 m_signature = elemAcs.m_signature;
382 m_nReserved = elemAcs.m_nReserved;
383 m_nInputChannels = elemAcs.m_nInputChannels;
384 m_nOutputChannels = elemAcs.m_nOutputChannels;
385
386 AllocData(elemAcs.m_nDataSize);
387 if (m_pData && elemAcs.m_nDataSize) {
388 memcpy(m_pData, elemAcs.m_pData, m_nDataSize);
389 }
390
391 return *this;
392}
393
394/**
395******************************************************************************
396* Name: CIccMpeBeginAcs::~CIccMpeBeginAcs
397*
398* Purpose:
399*
400* Args:
401*
402* Return:
403******************************************************************************/
407
408/**
409******************************************************************************
410* Name: CIccMpeEndAcs::CIccMpeEndAcs
411*
412* Purpose:
413*
414* Args:
415*
416* Return:
417******************************************************************************/
418CIccMpeEAcs::CIccMpeEAcs(icUInt16Number nChannels/* =0 */, icAcsSignature sig /* = icSigUnknownAcs */)
419{
420 m_signature = sig;
421
422 m_nInputChannels = nChannels;
423 m_nOutputChannels = nChannels;
424}
425
426/**
427******************************************************************************
428* Name: CIccMpeEndAcs::CIccMpeEndAcs
429*
430* Purpose:
431*
432* Args:
433*
434* Return:
435******************************************************************************/
437{
438 m_signature = elemAcs.m_signature;
439 m_nReserved = elemAcs.m_nReserved;
440
441 m_nInputChannels = elemAcs.m_nInputChannels;
442 m_nOutputChannels = elemAcs.m_nOutputChannels;
443
444 AllocData(elemAcs.m_nDataSize);
445 if (m_pData && elemAcs.m_nDataSize) {
446 memcpy(m_pData, elemAcs.m_pData, m_nDataSize);
447 }
448}
449
450/**
451******************************************************************************
452* Name: &CIccMpeEndAcs::operator=
453*
454* Purpose:
455*
456* Args:
457*
458* Return:
459******************************************************************************/
461{
462 m_signature = elemAcs.m_signature;
463 m_nReserved = elemAcs.m_nReserved;
464 m_nInputChannels = elemAcs.m_nInputChannels;
465 m_nOutputChannels = elemAcs.m_nOutputChannels;
466
467 AllocData(elemAcs.m_nDataSize);
468 if (m_pData && elemAcs.m_nDataSize) {
469 memcpy(m_pData, elemAcs.m_pData, m_nDataSize);
470 }
471
472 return *this;
473}
474
475/**
476******************************************************************************
477* Name: CIccMpeEndAcs::~CIccMpeEndAcs
478*
479* Purpose:
480*
481* Args:
482*
483* Return:
484******************************************************************************/
488
489#ifdef USEREFICCMAXNAMESPACE
490} //namespace refIccMAX
491#endif
icArraySignature sig
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: IccIO.h.
File: IccMpeACS.h.
icElemInterp
Definition IccTagMPE.h:93
void icMemDump(std::string &sDump, void *pBuf, icUInt32Number nNum)
Definition IccUtil.cpp:951
const icChar * icGetSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1028
File: IccUtil.h.
icTagTypeSignature
unsigned int icUInt32Number
Class: CIccApplyMpe.
Definition IccTagMPE.h:203
Type: Class.
Definition IccIO.h:97
virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:105
icInt32Number Write16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:122
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
bool AllocData(icUInt32Number size)
Name: CIccMpeAcs::AllocData.
icAcsSignature m_signature
Definition IccMpeACS.h:115
virtual bool Begin(icElemInterp nInterp, CIccTagMultiProcessElement *pMPE)
Name: CIccMpeAcs::Begin.
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
Name: CIccMpeAcs::Validate.
virtual bool Write(CIccIO *pIO)
Name: CIccMpeAcs::Write.
virtual bool Read(icUInt32Number size, CIccIO *pIO)
Name: CIccMpeAcs::Read.
virtual void Apply(CIccApplyMpe *pApply, icFloatNumber *dstPixel, const icFloatNumber *srcPixel) const
Name: CIccMpeAcs::Apply.
virtual void Describe(std::string &sDescription, int nVerboseness)
Name: CIccMpeAcs::Describe.
icUInt32Number m_nDataSize
Definition IccMpeACS.h:117
virtual ~CIccMpeAcs()
Name: CIccMpeAcs::~CIccMpeAcs.
CIccMpeAcs()
Name: CIccMpeAcs::CIccMpeACS.
Definition IccMpeACS.cpp:96
icUInt8Number * m_pData
Definition IccMpeACS.h:118
Class: CIccMpeBAcs.
Definition IccMpeACS.h:131
CIccMpeBAcs(icUInt16Number nChannels=0, icAcsSignature sig=0)
Name: CIccMpeBeginAcs::CIccMpeBeginAcs.
virtual ~CIccMpeBAcs()
Name: CIccMpeBeginAcs::~CIccMpeBeginAcs.
CIccMpeBAcs & operator=(const CIccMpeBAcs &elemAcs)
Name: &CIccMpeBeginAcs::operator=.
Class: CIccMpeEndAcs.
Definition IccMpeACS.h:155
virtual ~CIccMpeEAcs()
Name: CIccMpeEndAcs::~CIccMpeEndAcs.
CIccMpeEAcs(icUInt16Number nChannels=0, icAcsSignature sig=0)
Name: CIccMpeEndAcs::CIccMpeEndAcs.
CIccMpeEAcs & operator=(const CIccMpeEAcs &elemAcs)
Name: &CIccMpeEndAcs::operator=.
icUInt16Number m_nOutputChannels
Definition IccTagMPE.h:192
icUInt16Number m_nInputChannels
Definition IccTagMPE.h:191
icUInt32Number m_nReserved
Definition IccTagMPE.h:188
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const =0
Name: CIccProcessElement::Validate.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
unsigned char icUInt8Number
Number definitions.
icSignature icAcsSignature
MPE Future Extension Acs signature.
unsigned short icUInt16Number
long icInt32Number
icElemTypeSignature
Multi-Processing Element type signatures.
#define icSigAcsZero
Convenience Definition - Not defined in ICC specification.