Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccCmm.h
Go to the documentation of this file.
1/** @file
2 File: IccCmm.h
3
4 Contains: Header file for implementation of the CIccCmm 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// -Added support for Monochrome ICC profile apply by Rohit Patil 12-03-2008
69// -Integrate changes for PCS adjustment by George Pawle 12-09-2008
70//
71//////////////////////////////////////////////////////////////////////
72
73#if !defined(_ICCCMM_H)
74#define _ICCCMM_H
75
76#include "IccProfile.h"
77#include "IccTag.h"
78#include "IccUtil.h"
79#include "IccMatrixMath.h"
80#include <list>
81#include <cstring>
82#include <cstdlib>
83
84#if defined(__cpluplus) && defined(USEREFICCMAXNAMESPACE)
85namespace refIccMAX {
86#endif
87
88/// CMM return status values
89//Note: Update CIccCMM::GetStatusText() as appropriate
111
112/// CMM Interpolation types
117
123
124/// CMM Xform LUT types
125typedef enum {
126 icXformLutColor = 0x0, //This is a combination of icXformLutColorimetric with icXformLutSpectral
138
139#define icPerceptualRefBlackX 0.00336
140#define icPerceptualRefBlackY 0.0034731
141#define icPerceptualRefBlackZ 0.00287
142
143#define icPerceptualRefWhiteX 0.9642
144#define icPerceptualRefWhiteY 1.0000
145#define icPerceptualRefWhiteZ 0.8249
146
147// CMM Xform types
160
161
162#ifdef __cplusplus
163
164/**
165**************************************************************************
166* Type: Class
167*
168* Purpose:
169* Interface for creation of a named xform hint
170**************************************************************************
171*/
172class ICCPROFLIB_API IIccCreateXformHint
173{
174public:
175 virtual ~IIccCreateXformHint() {}
176 virtual const char *GetHintType() const=0;
177};
178
179/**
180**************************************************************************
181* Type: Class
182*
183* Purpose:
184* Manages the named xform hints
185**************************************************************************
186*/
187class ICCPROFLIB_API CIccCreateXformHintManager
188{
189public:
190 CIccCreateXformHintManager() { m_pList = NULL; }
191 ~CIccCreateXformHintManager();
192
193 /// Adds and owns the passed named hint to it's list
194 bool AddHint(IIccCreateXformHint* pHint);
195
196 /// Deletes the object referenced by the passed named hint pointer and removes it from the list
197 bool DeleteHint(IIccCreateXformHint* pHint);
198
199 /// Finds and returns a pointer to the named hint
200 IIccCreateXformHint* GetHint(const char* hintName);
201
202private:
203 // private hint ptr class
204 class IIccCreateXformHintPtr {
205 public:
206 IIccCreateXformHint* ptr;
207 };
208 typedef std::list<IIccCreateXformHintPtr> IIccCreateXformHintList;
209
210 // private members
211 IIccCreateXformHintList* m_pList;
212};
213
214/**
215**************************************************************************
216* Type: Class
217*
218* Purpose:
219* Hint for creation of a named color xform
220**************************************************************************
221*/
222class ICCPROFLIB_API CIccCreateNamedColorXformHint : public IIccCreateXformHint
223{
224public:
225 CIccCreateNamedColorXformHint() {
226 csSpectralPcs = icSigNoSpectralData;
227 memset(&spectralRange, 0, sizeof(spectralRange));
228 memset(&biSpectralRange, 0, sizeof(biSpectralRange));
229 }
230
231 virtual const char *GetHintType() const {return "CIccCreateNamedColorXformHint";}
232
234 icColorSpaceSignature csDevice;
235 icSpectralColorSignature csSpectralPcs;
236 icSpectralRange spectralRange;
237 icSpectralRange biSpectralRange;
238};
239
240/**
241**************************************************************************
242* Type: Class
243*
244* Purpose:
245* Hint for getting CMM environment variable values
246**************************************************************************
247*/
248class ICCPROFLIB_API CIccCreateCmmEnvVarXformHint : public IIccCreateXformHint
249{
250public:
251 virtual ~CIccCreateCmmEnvVarXformHint() {}
252
253 virtual const char *GetHintType() const {return "CIccCreateCmmEnvVarXformHint";}
254 virtual IIccCmmEnvVarLookup *GetNewCmmEnvVarLookup() const=0;
255};
256
257/**
258**************************************************************************
259* Type: Class
260*
261* Purpose:
262* Hint for getting CMM environment variable values
263**************************************************************************
264*/
265class ICCPROFLIB_API CIccCreateCmmPccEnvVarXformHint : public IIccCreateXformHint
266{
267public:
268 virtual ~CIccCreateCmmPccEnvVarXformHint() {}
269
270 virtual const char* GetHintType() const { return "CIccCreateCmmPccEnvVarXformHint"; }
271 virtual IIccCmmEnvVarLookup* GetNewCmmEnvVarLookup() const = 0;
272};
273
274
275/**
276**************************************************************************
277* Type: Class
278*
279* Purpose:
280* Interface for calculating adjust PCS factors
281**************************************************************************
282*/
283class CIccXform;
284class ICCPROFLIB_API IIccAdjustPCSXform
285{
286public:
287 virtual ~IIccAdjustPCSXform() {}
288
289 virtual bool CalcFactors(const CIccProfile* pProfile, const CIccXform* pXfm, icFloatNumber* Scale, icFloatNumber* Offset) const=0;
290};
291
292/**
293**************************************************************************
294* Type: Class
295*
296* Purpose:
297* Hint for calculating adjust PCS factors
298**************************************************************************
299*/
300class ICCPROFLIB_API CIccCreateAdjustPCSXformHint : public IIccCreateXformHint
301{
302public:
303 virtual ~CIccCreateAdjustPCSXformHint() {}
304
305 virtual const char *GetHintType() const {return "CIccCreateAdjustPCSXformHint";}
306 virtual const char *GetAdjustPCSType() const=0;
307 virtual IIccAdjustPCSXform *GetNewAdjustPCSXform() const=0;
308};
309
310/**
311**************************************************************************
312* Type: Class
313*
314* Purpose:
315* Hint for using Luminance Matching colorimetric PCS processing
316**************************************************************************
317*/
318class ICCPROFLIB_API CIccLuminanceMatchingHint : public IIccCreateXformHint
319{
320public:
321 virtual const char *GetHintType() const { return "CIccLuminanceMatchingHint"; }
322};
323
324
325
326//forward reference to CIccXform used by CIccApplyXform
327class CIccApplyXform;
328
329/**
330 **************************************************************************
331 * Type: Class
332 *
333 * Purpose:
334 * This is the base CMM xform object. A general static creation function,
335 * base behavior, and data are defined. The Create() function will assign
336 * a profile to the class. The CIccProfile object will then be owned by the
337 * xform object and later deleted when the IccXform is deleted.
338 **************************************************************************
339 */
340class ICCPROFLIB_API CIccXform
341{
342 friend class CIccPcsXform;
343public:
344 CIccXform();
345 virtual ~CIccXform();
346
347 virtual icXformType GetXformType() const = 0;
348
349 ///Note: The returned CIccXform will own the profile.
350 static CIccXform *Create(CIccProfile *pProfile, bool bInput=true,
355 bool bUseD2BTags=true,
356 CIccCreateXformHintManager *pHintManager=NULL);
357
358 ///Note: Provide an interface to work profile references. The IccProfile is copied, and the copy's ownership
359 ///is turned over to the Returned CIccXform object.
360 static CIccXform *Create(CIccProfile &pProfile,
361 bool bInput=true,
366 bool bUseD2BTags=true,
367 CIccCreateXformHintManager *pHintManager=NULL);
368
369 ///Note: The returned CIccXform will own the profile.
370 static CIccXform *Create(CIccProfile *pProfile, CIccTag *pXformTag, bool bInput = true,
374 bool bUseSpectralPCS = false,
375 CIccCreateXformHintManager *pHintManager = NULL);
376
377 //ShareProfile should only be called when the profile is shared between transforms
378 void ShareProfile() { m_bOwnsProfile = false; }
379 void SetPcsAdjustXform() { m_bPcsAdjustXform = true; }
380
381 virtual icStatusCMM Begin();
382
383 virtual CIccApplyXform *GetNewApply(icStatusCMM &status);
384
385 virtual void Apply(CIccApplyXform *pXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const = 0;
386
387 //Detach and remove CIccIO object associated with xform's profile. Must call after Begin()
388 virtual bool RemoveIO() { return m_pProfile ? m_pProfile->Detach() : false; }
389
390 ///Returns the source color space of the transform
391 virtual icColorSpaceSignature GetSrcSpace() const;
392 virtual icUInt16Number GetNumSrcSamples() const;
393
394 ///Returns the destination color space of the transform
395 virtual icColorSpaceSignature GetDstSpace() const;
396 virtual icUInt16Number GetNumDstSamples() const;
397
398 ///Checks if version 2 PCS is to be used
399 virtual bool UseLegacyPCS() const { return false; }
400 ///Checks if the profile is version 2
401 virtual bool IsVersion2() const { return !m_pProfile || m_pProfile->m_Header.version < icVersionNumberV4; }
402
403 ///Checks if the profile is to be used as input profile
404 bool IsInput() const { return m_bInput; }
405
406 virtual bool IsLateBinding() const { return false; }
407 virtual IIccProfileConnectionConditions *GetProfileCC() const { return m_pProfile; }
408 virtual void SetAppliedCC(IIccProfileConnectionConditions *pPCC) {}
409
410 bool IsMCS() const { return m_nMCS!=icNoMCS; }
411
412 bool IsExtendedPCS() const { return m_pProfile && (m_pProfile->m_Header.flags & icExtendedRangePCS) != 0; }
413
414 bool IsAbstract() const { return m_bPcsAdjustXform || (m_pProfile && m_pProfile->m_Header.deviceClass==icSigAbstractClass); }
415
416 /// The following function is for Overridden create function
417 void SetParams(CIccProfile *pProfile, bool bInput, icRenderingIntent nIntent, icRenderingIntent nTagIntet,
418 bool bUseSpectralPCS, icXformInterp nInterp, CIccCreateXformHintManager *pHintManager=NULL,
419 bool bAbsToRel=false, icMCSConnectionType nMCS=icNoMCS);
420
421 /// Use these functions to extract the input/output curves from the xform
422 virtual LPIccCurve* ExtractInputCurves()=0;
423 virtual LPIccCurve* ExtractOutputCurves()=0;
424
425 virtual bool NoClipPCS() const { return true; }
426
427 /// Returns the profile pointer. Profile is still owned by the Xform.
428 const CIccProfile* GetProfile() const { return m_pProfile; }
429
430 /// Returns modifiable profile pointer. Profile is still owned by the Xform.
431 CIccProfile* GetProfilePtr() const { return m_pProfile; }
432
433 /// Returns the rendering intent being used by the Xform
434 icRenderingIntent GetIntent() const { return m_nIntent; }
435 icXformInterp GetInterp() const { return m_nInterp; }
436
437 void SetSrcPCSConversion(bool bPcsConvert) { m_bSrcPcsConversion = bPcsConvert; }
438 void SetDstPCSConversion(bool bPcsConvert) { m_bDstPcsConversion = bPcsConvert; }
439 bool NeedAdjustPCS() { return m_bAdjustPCS; }
440 bool LuminanceMatching() { return m_bLuminanceMatching; }
441
442 virtual IIccProfileConnectionConditions *GetConnectionConditions() const { return m_pConnectionConditions; }
443
444 virtual IIccCmmEnvVarLookup *GetCmmEnvVarLookup() { return m_pCmmEnvVarLookup; }
445
446 void AttachCmmEnvVarLookup(IIccCmmEnvVarLookup* pCmmEnvVarLookup) { m_pCmmEnvVarLookup = pCmmEnvVarLookup; m_bDeleteEnvLooup = false; }
447
448 void DetachAll();
449
450protected:
451 //Called by derived classes to initialize Base
452
453 const icFloatNumber *CheckSrcAbs(CIccApplyXform *pApply, const icFloatNumber *Pixel) const;
454 void CheckDstAbs(icFloatNumber *Pixel) const;
455 void AdjustPCS(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
456
457 virtual bool HasPerceptualHandling() { return true; }
458
459 CIccProfile *m_pProfile;
460 bool m_bOwnsProfile = true;
461 bool m_bPcsAdjustXform = false;
462 bool m_bInput;
463 icRenderingIntent m_nIntent;
464 icRenderingIntent m_nTagIntent;
465 icXYZNumber m_MediaXYZ;
466 icXformInterp m_nInterp;
467 bool m_bUseD2BTags;
468 bool m_bUseSpectralPCS;
469 bool m_bAbsToRel;
470 icMCSConnectionType m_nMCS;
471 bool m_bLuminanceMatching;
472
473 //Temporary field
474 bool m_bSrcPcsConversion;
475 bool m_bDstPcsConversion;
476
477 // track PCS adjustments
478 IIccAdjustPCSXform* m_pAdjustPCS;
479 bool m_bAdjustPCS;
480 icFloatNumber m_PCSScale[3]; // scale and offset for PCS adjustment in XYZ
481 icFloatNumber m_PCSOffset[3];
482
483 IIccProfileConnectionConditions *m_pConnectionConditions;
484
485 bool m_bDeleteEnvLooup = true;
486 IIccCmmEnvVarLookup *m_pCmmEnvVarLookup;
487};
488
489
490/**
491 **************************************************************************
492 * Type: Class
493 *
494 * Purpose: Pointer to the Cmm Xform object
495 **************************************************************************
496 */
497class ICCPROFLIB_API CIccXformPtr {
498public:
499 CIccXform *ptr;
500};
501
502
503/**
504 **************************************************************************
505 * Type: List Class
506 *
507 * Purpose: List of CIccXformPtr which is updated on addition of Xforms
508 **************************************************************************
509 */
510typedef std::list<CIccXformPtr> CIccXformList;
511
512
513/**
514**************************************************************************
515* Type: Class
516*
517* Purpose: The Apply Cmm Xform object (Allows xforms to have apply time data)
518**************************************************************************
519*/
520class ICCPROFLIB_API CIccApplyXform
521{
522 friend class CIccXform;
523public:
524 virtual ~CIccApplyXform();
525 virtual icXformType GetXformType() const { return icXformTypeUnknown; }
526
527 void __inline Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) { m_pXform->Apply(this, DstPixel, SrcPixel); }
528
529 const CIccXform *GetXform() { return m_pXform; }
530
531protected:
532 icFloatNumber m_AbsLab[3];
533
534 CIccApplyXform(CIccXform *pXform);
535
536 const CIccXform *m_pXform;
537};
538
539/**
540**************************************************************************
541* Type: Class
542*
543* Purpose: Pointer to the Apply Cmm Xform object
544**************************************************************************
545*/
546class ICCPROFLIB_API CIccApplyXformPtr {
547public:
548 CIccApplyXform *ptr;
549};
550
551
552/**
553**************************************************************************
554* Type: List Class
555*
556* Purpose: List of CIccApplyXformPtr which is updated on addition of Apply Xforms
557**************************************************************************
558*/
559typedef std::list<CIccApplyXformPtr> CIccApplyXformList;
560
561
562class CIccApplyPcsStep;
563
564typedef enum {
565 icPcsStepUnknown = 0,
566 icPcsStepIdentity,
567 icPcsStepRouteMcs,
568 icPcsStepLabToXYZ,
569 icPcsStepXYZToLab,
570 icPcsStepLab2ToXYZ,
571 icPcsStepXYZToLab2,
572 icPcsStepOffset,
573 icPcsStepScale,
574 icPcsStepMatrix,
575 icPcsStepMpe,
576 icPcsStepSrcMatrix,
577 icPcsStepSparseMatrix,
578 icPcsStepSrcSparseMatrix,
579} icPcsStepType;
580
581//forward reference to CIccXform used by CIccApplyXform
582class CIccApplyPcsStep;
583
584class ICCPROFLIB_API CIccPcsStep
585{
586public:
587 virtual icPcsStepType GetType() { return icPcsStepUnknown; }
588
589 virtual CIccApplyPcsStep *GetNewApply();
590
591 virtual ~CIccPcsStep() {}
592 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const=0;
593 virtual icUInt16Number GetSrcChannels() const =0;
594 virtual icUInt16Number GetDstChannels() const =0;
595
596 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const {return NULL;}
597 virtual bool isIdentity() const { return false; }
598 virtual CIccPcsStep *reduce() const { return (CIccPcsStep*)this; }
599
600 virtual void dump(std::string &str) const =0;
601};
602
603/**
604**************************************************************************
605* Type: Class
606*
607* Purpose: The Apply pcs step object (Allows pcs processing steps to have apply time data)
608**************************************************************************
609*/
610class ICCPROFLIB_API CIccApplyPcsStep
611{
612 friend class CIccPcsStep;
613public:
614 virtual ~CIccApplyPcsStep() {}
615 virtual icPcsStepType GetXformType() const { return m_stepType; }
616
617 void __inline Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) { m_pStep->Apply(this, DstPixel, SrcPixel); }
618
619 const CIccPcsStep *GetStep() const { return m_pStep; }
620
621protected:
622 icPcsStepType m_stepType;
623
624 CIccApplyPcsStep(CIccPcsStep *pStep) { m_pStep = pStep; m_stepType = icPcsStepUnknown; }
625
626 const CIccPcsStep *m_pStep;
627};
628
629
630class ICCPROFLIB_API CIccPcsStepIdentity : public CIccPcsStep
631{
632public:
633 CIccPcsStepIdentity(icUInt16Number nChannels) {m_nChannels=nChannels;}
634 virtual icPcsStepType GetType() { return icPcsStepIdentity; }
635
636 virtual ~CIccPcsStepIdentity() {}
637 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
638 virtual icUInt16Number GetSrcChannels() const {return m_nChannels;}
639 virtual icUInt16Number GetDstChannels() const {return m_nChannels;}
640
641 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const {return NULL;}
642 virtual bool isIdentity() const { return true; }
643
644 virtual void dump(std::string &str) const;
645protected:
646 icUInt16Number m_nChannels;
647};
648
649class CIccTagArray;
650class CIccTagNumArray;
651
652class ICCPROFLIB_API CIccPcsStepRouteMcs : public CIccPcsStep
653{
654public:
655 CIccPcsStepRouteMcs(CIccTagArray *pSrcChannels, CIccTagArray *pDstChannels, CIccTagNumArray *pDefaults);
656 virtual icPcsStepType GetType() { return icPcsStepRouteMcs; }
657
658 virtual ~CIccPcsStepRouteMcs();
659 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
660 virtual icUInt16Number GetSrcChannels() const {return m_nSrcChannels;}
661 virtual icUInt16Number GetDstChannels() const {return m_nDstChannels;}
662
663 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const {return NULL;}
664 virtual bool isIdentity() const ;
665
666 virtual void dump(std::string &str) const;
667protected:
668 icUInt16Number m_nSrcChannels;
669 icUInt16Number m_nDstChannels;
670 int *m_Index;
671 icFloatNumber *m_Defaults;
672};
673
674
675class ICCPROFLIB_API CIccPcsLabStep : public CIccPcsStep
676{
677public:
678 bool isSameWhite(const icFloatNumber *xyzWhite);
679protected:
680 icFloatNumber m_xyzWhite[3];
681};
682
683class ICCPROFLIB_API CIccPcsStepLabToXYZ : public CIccPcsLabStep
684{
685public:
686 CIccPcsStepLabToXYZ(const icFloatNumber *xyzWhite=NULL);
687 virtual icPcsStepType GetType() { return icPcsStepLabToXYZ; }
688
689 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
690 virtual icUInt16Number GetSrcChannels() const { return 3; }
691 virtual icUInt16Number GetDstChannels() const { return 3; }
692
693 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
694
695 virtual void dump(std::string &str) const;
696};
697
698class ICCPROFLIB_API CIccPcsStepXYZToLab : public CIccPcsLabStep
699{
700public:
701 CIccPcsStepXYZToLab(const icFloatNumber *xyzWhite=NULL);
702 virtual icPcsStepType GetType() { return icPcsStepXYZToLab; }
703
704 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
705 virtual icUInt16Number GetSrcChannels() const { return 3; }
706 virtual icUInt16Number GetDstChannels() const { return 3; }
707
708 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
709
710 virtual void dump(std::string &str) const;
711};
712
713class ICCPROFLIB_API CIccPcsStepLab2ToXYZ : public CIccPcsLabStep
714{
715public:
716 CIccPcsStepLab2ToXYZ(const icFloatNumber *xyzWhite=NULL);
717 virtual icPcsStepType GetType() { return icPcsStepLab2ToXYZ; }
718
719 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
720 virtual icUInt16Number GetSrcChannels() const { return 3; }
721 virtual icUInt16Number GetDstChannels() const { return 3; }
722
723 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
724
725 virtual void dump(std::string &str) const;
726};
727
728class ICCPROFLIB_API CIccPcsStepXYZToLab2 : public CIccPcsLabStep
729{
730public:
731 CIccPcsStepXYZToLab2(const icFloatNumber *xyzWhite=NULL);
732 virtual icPcsStepType GetType() { return icPcsStepXYZToLab2; }
733
734 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
735 virtual icUInt16Number GetSrcChannels() const { return 3; }
736 virtual icUInt16Number GetDstChannels() const { return 3; }
737
738 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
739
740 virtual void dump(std::string &str) const;
741};
742
743class ICCPROFLIB_API CIccPcsStepOffset : public CIccPcsStep
744{
745public:
746 CIccPcsStepOffset(icUInt16Number nChannels);
747 virtual icPcsStepType GetType() { return icPcsStepOffset; }
748
749 virtual ~CIccPcsStepOffset();
750
751 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
752 virtual icUInt16Number GetSrcChannels() const { return m_nChannels; }
753 virtual icUInt16Number GetDstChannels() const { return m_nChannels; }
754
755 CIccPcsStepOffset *Add(const CIccPcsStepOffset *offset) const;
756
757 icFloatNumber *data() { return m_vals; }
758 const icFloatNumber *data() const { return m_vals; }
759
760 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
761 virtual bool isIdentity() const;
762
763 virtual void dump(std::string &str) const;
764protected:
765 icUInt16Number m_nChannels;
766 icFloatNumber *m_vals;
767
768};
769
770class CIccPcsStepMatrix;
771class CIccMpeMatrix;
772
773class ICCPROFLIB_API CIccPcsStepScale : public CIccPcsStep
774{
775public:
776 CIccPcsStepScale(icUInt16Number nChannels);
777 virtual icPcsStepType GetType() { return icPcsStepScale; }
778
779 virtual ~CIccPcsStepScale();
780
781 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
782 virtual icUInt16Number GetSrcChannels() const { return m_nChannels; }
783 virtual icUInt16Number GetDstChannels() const { return m_nChannels; }
784
785 icFloatNumber *data() { return m_vals; }
786 const icFloatNumber *data() const { return m_vals; }
787
788 CIccPcsStepScale *Mult(const CIccPcsStepScale *scale) const;
789 CIccPcsStepMatrix *Mult(const CIccPcsStepMatrix *matrix) const;
790 CIccPcsStepMatrix *Mult(const CIccMpeMatrix *matrix) const;
791
792 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
793 virtual bool isIdentity() const;
794
795 virtual void dump(std::string &str) const;
796protected:
797 icUInt16Number m_nChannels;
798 icFloatNumber *m_vals;
799
800};
801
802class ICCPROFLIB_API CIccPcsStepMatrix : public CIccPcsStep, public CIccMatrixMath //Apply a matrix to a vector provided by the source
803{
804public:
805 CIccPcsStepMatrix(icUInt16Number nRows, icUInt16Number nCols, bool bInitIdentity=false) : CIccMatrixMath(nRows, nCols, bInitIdentity) {}
806 CIccPcsStepMatrix(const CIccPcsStepMatrix &mat) : CIccMatrixMath(mat) {}
807 CIccPcsStepMatrix(const CIccMatrixMath &mat) : CIccMatrixMath(mat) {}
808 virtual icPcsStepType GetType() { return icPcsStepMatrix; }
809
810 virtual ~CIccPcsStepMatrix() {}
811
812 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const {VectorMult(pDst, pSrc); }//Must support pApply=NULL
813 virtual icUInt16Number GetSrcChannels() const { return m_nCols; }
814 virtual icUInt16Number GetDstChannels() const { return m_nRows; }
815
816 CIccPcsStepMatrix *Mult(const CIccPcsStepScale *scale) const;
817 CIccPcsStepMatrix *Mult(const CIccPcsStepMatrix *matrix) const;
818
819 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const;
820 virtual bool isIdentity() const {return isIdentityMtx();}
821 virtual CIccPcsStep *reduce() const;
822
823 virtual void dump(std::string &str) const;
824};
825
827
828class ICCPROFLIB_API CIccPcsStepMpe : public CIccPcsStep //Apply a matrix to a vector provided by the source
829{
830public:
831 CIccPcsStepMpe(CIccTagMultiProcessElement *pMpe);
832 virtual icPcsStepType GetType() { return icPcsStepMpe; }
833
834 virtual ~CIccPcsStepMpe();
835
836 virtual CIccApplyPcsStep *GetNewApply();
837
838 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
839 virtual icUInt16Number GetSrcChannels() const;
840 virtual icUInt16Number GetDstChannels() const;
841
842 virtual bool isIdentity() const;
843
844 CIccMpeMatrix *GetMatrix() const;
845
846 //Begin must be called before Apply
847 bool Begin();
848
849 virtual void dump(std::string &str) const;
850
851protected:
853};
854
855class CIccApplyTagMpe;
856
857class ICCPROFLIB_API CIccApplyPcsStepMpe : public CIccApplyPcsStep
858{
859 friend class CIccPcsStepMpe;
860 virtual ~CIccApplyPcsStepMpe() { delete m_pApply; }
861protected:
862 CIccApplyPcsStepMpe(CIccPcsStep *pStep, CIccApplyTagMpe *pApply) : CIccApplyPcsStep(pStep) { m_pApply = pApply; }
863
864 CIccApplyTagMpe *m_pApply;
865};
866
867
868class ICCPROFLIB_API CIccPcsStepSrcMatrix : public CIccPcsStep //Apply a vector to the matrix provided by the source
869{
870public:
871 CIccPcsStepSrcMatrix(icUInt16Number nRows, icUInt16Number nCols);
872 virtual icPcsStepType GetType() { return icPcsStepSrcMatrix; }
873
874 virtual ~CIccPcsStepSrcMatrix();
875
876 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
877 virtual icUInt16Number GetSrcChannels() const { return m_nCols; }
878 virtual icUInt16Number GetDstChannels() const { return m_nRows; }
879
880 icFloatNumber *data() { return m_vals;}
881 const icFloatNumber *data() const { return m_vals;}
882
883 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const { return NULL; }
884
885 virtual void dump(std::string &str) const;
886protected:
887 icUInt16Number m_nRows, m_nCols;
888 icFloatNumber *m_vals;
889
890};
891
892
893class ICCPROFLIB_API CIccPcsStepSparseMatrix : public CIccPcsStep //Apply a sparse matrix to the vector provided by the source
894{
895public:
896 CIccPcsStepSparseMatrix(icUInt16Number nRows, icUInt16Number nCols, icUInt32Number nBytesPerMatrix);
897 virtual icPcsStepType GetType() { return icPcsStepSparseMatrix; }
898
899 virtual ~CIccPcsStepSparseMatrix();
900
901 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
902 virtual icUInt16Number GetSrcChannels() const { return m_nCols; }
903 virtual icUInt16Number GetDstChannels() const { return m_nRows; }
904
905 icFloatNumber *data() { return m_vals;}
906 const icFloatNumber *data() const { return m_vals;}
907
908 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const { return NULL; }
909
910 virtual void dump(std::string &str) const;
911protected:
912 icUInt16Number m_nRows, m_nCols, m_nChannels;
913 icUInt32Number m_nBytesPerMatrix;
914 icFloatNumber *m_vals;
915
916};
917
918class ICCPROFLIB_API CIccPcsStepSrcSparseMatrix : public CIccPcsStep //Apply a vector to the matrix provided by the source
919{
920public:
921 CIccPcsStepSrcSparseMatrix(icUInt16Number nRows, icUInt16Number nCols, icUInt16Number nChannels);
922 virtual icPcsStepType GetType() { return icPcsStepSrcSparseMatrix; }
923
924 virtual ~CIccPcsStepSrcSparseMatrix();
925
926 virtual void Apply(CIccApplyPcsStep *pApply, icFloatNumber *pDst, const icFloatNumber *pSrc) const;
927 virtual icUInt16Number GetSrcChannels() const { return m_nCols; }
928 virtual icUInt16Number GetDstChannels() const { return m_nRows; }
929
930 icFloatNumber *data() { return m_vals;}
931 const icFloatNumber *data() const { return m_vals;}
932
933 virtual CIccPcsStep *concat(CIccPcsStep *pNext) const { return NULL; }
934
935 virtual void dump(std::string &str) const;
936protected:
937 icUInt16Number m_nRows, m_nCols, m_nChannels;
938 icUInt32Number m_nBytesPerMatrix;
939 icFloatNumber *m_vals;
940
941};
942
943
944/**
945**************************************************************************
946* Type: Class
947*
948* Purpose: Pointer to the PcsStep object
949**************************************************************************
950*/
951class ICCPROFLIB_API CIccPcsStepPtr {
952public:
953 CIccPcsStep *ptr;
954};
955
956/**
957**************************************************************************
958* Type: List Class
959*
960* Purpose: List of CIccApplyXformPtr which is updated on addition of Apply Xforms
961**************************************************************************
962*/
963typedef std::list<CIccPcsStepPtr> CIccPcsStepList;
964
965
966/**
967**************************************************************************
968* Type: Class
969*
970* Purpose: The PCS Cmm Xform object
971**************************************************************************
972*/
973class ICCPROFLIB_API CIccPcsXform : public CIccXform
974{
975public:
976 CIccPcsXform();
977 virtual ~CIccPcsXform();
978
979 virtual icXformType GetXformType() const { return icXformTypePCS; }
980
981 icStatusCMM Connect(CIccXform *pFromXform, CIccXform *pToXform);
982
983 virtual icStatusCMM Begin() { return icCmmStatOk; }
984
985 virtual CIccApplyXform *GetNewApply(icStatusCMM &status); //Must be called after Begin
986
987 virtual void Apply(CIccApplyXform *pXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
988
989 ///Returns the source color space of the transform
990 virtual icColorSpaceSignature GetSrcSpace() const { return m_srcSpace; }
991 virtual icUInt16Number GetNumSrcSamples() const { return m_nSrcSamples; }
992
993 ///Returns the destination color space of the transform
994 virtual icColorSpaceSignature GetDstSpace() const { return m_dstSpace; }
995 virtual icUInt16Number GetNumDstSamples() const { return m_nDstSamples; }
996
997 ///Checks if version 2 PCS is to be used
998 virtual bool UseLegacyPCS() const { return false; }
999 ///Checks if the profile is version 2
1000 virtual bool IsVersion2() const { return false; }
1001
1002 /// Use these functions to extract the input/output curves from the xform
1003 virtual LPIccCurve* ExtractInputCurves() { return NULL; }
1004 virtual LPIccCurve* ExtractOutputCurves() { return NULL; }
1005
1006 icUInt16Number MaxChannels();
1007
1008 static CIccPcsStepMatrix *rangeMap(const icSpectralRange &srcRange, const icSpectralRange &dstRange);
1009
1010protected:
1011
1012 icStatusCMM Optimize();
1013
1014 void pushRouteMcs(CIccTagArray *pSrcChannels, CIccTagArray *pDstChannels, CIccTagNumArray *pDefaults);
1015 void pushLab2ToXyz(IIccProfileConnectionConditions *pPCC);
1016 void pushXyzToLab2(IIccProfileConnectionConditions *pPCC);
1017 void pushLabToXyz(IIccProfileConnectionConditions *pPCC);
1018 void pushXyzToLab(IIccProfileConnectionConditions *pPCC);
1019 void pushXyzToXyzIn();
1020 void pushXyzInToXyz();
1021 void pushXyzToXyzLum(IIccProfileConnectionConditions *pPCC);
1022 void pushXyzLumToXyz(IIccProfileConnectionConditions *pPCC);
1023 void pushScale3(icFloatNumber v1, icFloatNumber v2, icFloatNumber v3);
1024 void pushOffset3(icFloatNumber v1, icFloatNumber v2, icFloatNumber v3, bool bConvertIntXyzOffset=true);
1025 void pushRef2Xyz(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc);
1026 void pushSpecToRange(const icSpectralRange &srcRange, const icSpectralRange &dstRange);
1027 void pushApplyIllum(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc);
1028 void pushRad2Xyz(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc, bool bAbsoluteCIEColorimetry=false);
1029 icStatusCMM pushBiRef2Xyz(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc);
1030 icStatusCMM pushBiRef2Ref(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc);
1031 icStatusCMM pushBiRef2Rad(CIccProfile *pProfile, IIccProfileConnectionConditions *pPcc);
1032 void pushScale(icUInt16Number n, const icFloatNumber *vals);
1033 void pushMatrix(icUInt16Number nRows, icUInt16Number nCols, const icFloatNumber *vals);
1034 void pushMatrixTransverse(icUInt16Number nRows, icUInt16Number nCols, icFloatNumber *vals);
1035 icStatusCMM pushXYZConvert(CIccXform *pSrcXform, CIccXform *pDstXform);
1036 void pushXYZNormalize(IIccProfileConnectionConditions *pPcc, const icSpectralRange &srcRange, const icSpectralRange &dstRange);
1037
1038
1039 icColorSpaceSignature m_srcSpace;
1040 icUInt16Number m_nSrcSamples;
1041
1042 icColorSpaceSignature m_dstSpace;
1043 icUInt16Number m_nDstSamples;
1044
1045 CIccPcsStepList *m_list;
1046};
1047
1048
1049/**
1050**************************************************************************
1051* Type: Class
1052*
1053* Purpose: Pointer to the Apply PCS Step object
1054**************************************************************************
1055*/
1056class ICCPROFLIB_API CIccApplyPcsStepPtr {
1057public:
1058 CIccApplyPcsStep *ptr;
1059};
1060
1061
1062/**
1063**************************************************************************
1064* Type: List Class
1065*
1066* Purpose: List of CIccApplyXformPtr which is updated on addition of Apply Xforms
1067**************************************************************************
1068*/
1069typedef std::list<CIccApplyPcsStepPtr> CIccApplyPcsStepList;
1070
1071
1072/**
1073**************************************************************************
1074* Type: Class
1075*
1076* Purpose: The PCS Apply Cmm Xform object (Allows xforms to have apply time data)
1077**************************************************************************
1078*/
1079class ICCPROFLIB_API CIccApplyPcsXform : public CIccApplyXform
1080{
1081 friend class CIccPcsXform;
1082public:
1083 virtual ~CIccApplyPcsXform();
1084
1085 virtual icXformType GetXformType() const { return icXformTypePCS; }
1086
1087 void AppendApplyStep(CIccApplyPcsStep *pStep);
1088
1089protected:
1090 CIccApplyPcsXform(CIccXform *pXform);
1091 bool Init();
1092
1093 CIccApplyPcsStepList *m_list;
1094
1095 icFloatNumber *m_temp1;
1096 icFloatNumber *m_temp2;
1097};
1098
1099
1100/**
1101**************************************************************************
1102* Type: Class
1103*
1104* Purpose: This is the general Monochrome Xform (uses a grayTRCTag)
1105*
1106**************************************************************************
1107*/
1108class ICCPROFLIB_API CIccXformMonochrome : public CIccXform
1109{
1110public:
1111 CIccXformMonochrome();
1112 virtual ~CIccXformMonochrome();
1113
1114 virtual icXformType GetXformType() const { return icXformTypeMonochrome; }
1115
1116 virtual icStatusCMM Begin();
1117 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1118
1119 virtual LPIccCurve* ExtractInputCurves();
1120 virtual LPIccCurve* ExtractOutputCurves();
1121
1122protected:
1123
1124 virtual bool HasPerceptualHandling() { return false; }
1125
1126 CIccCurve *m_Curve;
1127 CIccCurve *GetCurve(icSignature sig) const;
1128 CIccCurve *GetInvCurve(icSignature sig) const;
1129
1130 bool m_bFreeCurve;
1131 /// used only when applying the xform
1132 LPIccCurve m_ApplyCurvePtr;
1133};
1134
1135/**
1136 **************************************************************************
1137 * Type: Class
1138 *
1139 * Purpose: This is the general Matrix-TRC Xform
1140 *
1141 **************************************************************************
1142 */
1143class ICCPROFLIB_API CIccXformMatrixTRC : public CIccXform
1144{
1145public:
1146 CIccXformMatrixTRC();
1147 virtual ~CIccXformMatrixTRC();
1148
1149 virtual icXformType GetXformType() const { return icXformTypeMatrixTRC; }
1150
1151 virtual icStatusCMM Begin();
1152 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1153
1154 virtual LPIccCurve* ExtractInputCurves();
1155 virtual LPIccCurve* ExtractOutputCurves();
1156
1157protected:
1158
1159 virtual bool HasPerceptualHandling() { return false; }
1160
1161 icFloatNumber m_e[9];
1162 CIccCurve *m_Curve[3];
1163 CIccCurve *GetCurve(icSignature sig) const;
1164 CIccCurve *GetInvCurve(icSignature sig) const;
1165
1166 CIccTagXYZ *GetColumn(icSignature sig) const;
1167 bool m_bFreeCurve;
1168 /// used only when applying the xform
1169 const LPIccCurve* m_ApplyCurvePtr;
1170};
1171
1172
1173/**
1174 **************************************************************************
1175 * Type: Class
1176 *
1177 * Purpose: This is the general 3D-LUT Xform
1178 *
1179 **************************************************************************
1180 */
1181class ICCPROFLIB_API CIccXform3DLut : public CIccXform
1182{
1183public:
1184 CIccXform3DLut(CIccTag *pTag);
1185 virtual ~CIccXform3DLut();
1186
1187 virtual icXformType GetXformType() const { return icXformType3DLut; }
1188
1189 virtual icStatusCMM Begin();
1190 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1191
1192 virtual bool UseLegacyPCS() const { return m_pTag->UseLegacyPCS(); }
1193
1194 virtual LPIccCurve* ExtractInputCurves();
1195 virtual LPIccCurve* ExtractOutputCurves();
1196protected:
1197
1198 const CIccMBB *m_pTag;
1199
1200 /// Pointers to data in m_pTag, used only for applying the xform
1201 const LPIccCurve* m_ApplyCurvePtrA;
1202 const LPIccCurve* m_ApplyCurvePtrB;
1203 const LPIccCurve* m_ApplyCurvePtrM;
1204 const CIccMatrix* m_ApplyMatrixPtr;
1205};
1206
1207
1208/**
1209 **************************************************************************
1210 * Type: Class
1211 *
1212 * Purpose: This is the general 4D-LUT Xform
1213 *
1214 **************************************************************************
1215 */
1216class ICCPROFLIB_API CIccXform4DLut : public CIccXform
1217{
1218public:
1219 CIccXform4DLut(CIccTag *pTag);
1220 virtual ~CIccXform4DLut();
1221
1222 virtual icXformType GetXformType() const { return icXformType4DLut; }
1223
1224 virtual icStatusCMM Begin();
1225 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1226
1227 virtual bool UseLegacyPCS() const { return m_pTag->UseLegacyPCS(); }
1228
1229 virtual LPIccCurve* ExtractInputCurves();
1230 virtual LPIccCurve* ExtractOutputCurves();
1231protected:
1232 const CIccMBB *m_pTag;
1233
1234 /// Pointers to data in m_pTag, used only for applying the xform
1235 const LPIccCurve* m_ApplyCurvePtrA;
1236 const LPIccCurve* m_ApplyCurvePtrB;
1237 const LPIccCurve* m_ApplyCurvePtrM;
1238 const CIccMatrix* m_ApplyMatrixPtr;
1239};
1240
1241
1242class ICCPROFLIB_API CIccApplyNDLutXform : public CIccApplyXform
1243{
1244 friend class CIccXformNDLut;
1245public:
1246 CIccApplyNDLutXform(CIccXformNDLut* pXform, CIccApplyCLUT* pApply);
1247 virtual ~CIccApplyNDLutXform();
1248
1249protected:
1250 CIccApplyCLUT* m_pApply;
1251};
1252
1253/**
1254 **************************************************************************
1255 * Type: Class
1256 *
1257 * Purpose: This is the general ND-LUT Xform
1258 *
1259 **************************************************************************
1260 */
1261class ICCPROFLIB_API CIccXformNDLut : public CIccXform
1262{
1263public:
1264 CIccXformNDLut(CIccTag *pTag);
1265 virtual ~CIccXformNDLut();
1266
1267 virtual icXformType GetXformType() const { return icXformTypeNDLut; }
1268
1269 virtual icStatusCMM Begin();
1270
1271 virtual CIccApplyXform* GetNewApply(icStatusCMM& status); //Must be called after Begin
1272
1273 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1274
1275 virtual bool UseLegacyPCS() const { return m_pTag->UseLegacyPCS(); }
1276
1277 virtual LPIccCurve* ExtractInputCurves();
1278 virtual LPIccCurve* ExtractOutputCurves();
1279protected:
1280 const CIccMBB *m_pTag;
1281 int m_nNumInput;
1282
1283 /// Pointers to data in m_pTag, used only for applying the xform
1284 const LPIccCurve* m_ApplyCurvePtrA;
1285 const LPIccCurve* m_ApplyCurvePtrB;
1286 const LPIccCurve* m_ApplyCurvePtrM;
1287 const CIccMatrix* m_ApplyMatrixPtr;
1288};
1289
1290
1291
1292/**
1293 **************************************************************************
1294 * Type: Enum
1295 *
1296 * Purpose: Defines the interface to be used when applying Named Color
1297 * Profiles.
1298 *
1299 **************************************************************************
1300 */
1301typedef enum {
1302 icApplyPixel2Pixel = 0,
1303 icApplyNamed2Pixel = 1,
1304 icApplyPixel2Named = 2,
1305 icApplyNamed2Named = 3,
1306} icApplyInterface;
1307
1308//Forward reference for CIccXformNamedColor
1310
1311/**
1312 **************************************************************************
1313 * Type: Class
1314 *
1315 * Purpose: This is the general Xform for Named Color Profiles.
1316 *
1317 **************************************************************************
1318 */
1319class ICCPROFLIB_API CIccXformNamedColor : public CIccXform
1320{
1321public:
1322 CIccXformNamedColor(CIccTag *pTag, icColorSpaceSignature csPcs, icColorSpaceSignature csDevice,
1324 const icSpectralRange *pSpectralRange = NULL,
1325 const icSpectralRange *pBiSPectralRange = NULL);
1326 virtual ~CIccXformNamedColor();
1327
1328 virtual icXformType GetXformType() const { return icXformTypeNamedColor; }
1329
1330 virtual icStatusCMM Begin();
1331
1332 ///Returns the type of interface that will be applied
1333 icApplyInterface GetInterface() const {return m_nApplyInterface;}
1334
1335 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const {}
1336
1337 icStatusCMM Apply(CIccApplyXform *pApplyXform, icChar *DstColorName, const icFloatNumber *SrcPixel) const;
1338 icStatusCMM Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icChar *SrcColorName, icFloatNumber tint=1.0f) const;
1339
1340 virtual bool UseLegacyPCS() const { return m_pTag ? m_pTag->UseLegacyPCS() : false; }
1341
1342 icStatusCMM SetSrcSpace(icColorSpaceSignature nSrcSpace);
1343 icStatusCMM SetDestSpace(icColorSpaceSignature nDestSpace);
1344
1345 ///Returns the source color space of the transform
1346 icColorSpaceSignature GetSrcSpace() const { return m_nSrcSpace; }
1347 ///Returns the destination color space of the transform
1348 icColorSpaceSignature GetDstSpace() const { return m_nDestSpace; }
1349
1350 ///Checks if the source space of the transform is PCS
1351 bool IsSrcPCS() const;
1352 ///Checks if the destination space of the transform is PCS
1353 bool IsDestPCS() const;
1354
1355
1356 virtual LPIccCurve* ExtractInputCurves() {return NULL;}
1357 virtual LPIccCurve* ExtractOutputCurves() {return NULL;}
1358
1359protected:
1360
1361 virtual bool HasPerceptualHandling() { return false; }
1362
1363 CIccTagNamedColor2 *m_pTag;
1364 CIccArrayNamedColor *m_pArray;
1365 icApplyInterface m_nApplyInterface;
1366 icColorSpaceSignature m_nSrcSpace;
1367 icColorSpaceSignature m_nDestSpace;
1368};
1369
1370
1371/**
1372**************************************************************************
1373* Type: Class
1374*
1375* Purpose: This is the general Xform for Multi Processing Elements.
1376*
1377**************************************************************************
1378*/
1379class ICCPROFLIB_API CIccXformMpe : public CIccXform
1380{
1381public:
1382 CIccXformMpe(CIccTag *pTag);
1383 virtual ~CIccXformMpe();
1384
1385 virtual icXformType GetXformType() const { return icXformTypeMpe; }
1386
1387 ///Note: The returned CIccXform will own the profile.
1388 static CIccXform *Create(CIccProfile *pProfile, bool bInput=true, icRenderingIntent nIntent=icUnknownIntent,
1389 icXformInterp nInterp=icInterpLinear, icXformLutType nLutType=icXformLutColor, CIccCreateXformHintManager *pHintManager=NULL);
1390
1391 virtual icStatusCMM Begin();
1392
1393 virtual CIccApplyXform *GetNewApply(icStatusCMM &status);
1394 virtual void Apply(CIccApplyXform *pApplyXform, icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) const;
1395
1396 virtual bool UseLegacyPCS() const { return false; }
1397 virtual LPIccCurve* ExtractInputCurves() {return NULL;}
1398 virtual LPIccCurve* ExtractOutputCurves() {return NULL;}
1399
1400 virtual bool NoClipPCS() const { return true; }
1401
1402 virtual bool IsLateBinding() const;
1403 virtual bool IsLateBindingReflectance() const;
1404 virtual IIccProfileConnectionConditions *GetConnectionConditions() const;
1405 virtual void SetAppliedCC(IIccProfileConnectionConditions *pPCC);
1406
1407
1408protected:
1410 bool m_bUsingAcs;
1411 IIccProfileConnectionConditions *m_pAppliedPCC;
1412 bool m_bDeleteAppliedPCC;
1413};
1414
1415/**
1416**************************************************************************
1417* Type: Class
1418*
1419* Purpose: The Apply general MPE Xform object (Allows xforms to have apply time data)
1420**************************************************************************
1421*/
1422class ICCPROFLIB_API CIccApplyXformMpe : public CIccApplyXform
1423{
1424 friend class CIccXformMpe;
1425public:
1426 virtual ~CIccApplyXformMpe();
1427 virtual icXformType GetXformType() const { return icXformTypeMpe; }
1428
1429protected:
1430 CIccApplyXformMpe(CIccXformMpe *pXform);
1431
1432 CIccApplyTagMpe *m_pApply;
1433};
1434
1435/**
1436 **************************************************************************
1437 * Type: Class
1438 *
1439 * Purpose: Independant PCS class to do PCS based calculations.
1440 * This is a class for managing PCS colorspace transformations. There
1441 * are two important categories V2 <-> V4, and Lab <-> XYZ.
1442 *
1443 **************************************************************************
1444 */
1445class ICCPROFLIB_API CIccPCS
1446{
1447public:
1448 CIccPCS();
1449 virtual ~CIccPCS() {}
1450
1451 void Reset(icColorSpaceSignature StartSpace, bool bUseLegacyPCS = false);
1452
1453 virtual const icFloatNumber *Check(const icFloatNumber *SrcPixel, const CIccXform *pXform);
1454 void CheckLast(icFloatNumber *SrcPixel, icColorSpaceSignature Space, bool bNoClip=false);
1455
1456 static void LabToXyz(icFloatNumber *Dst, const icFloatNumber *Src, bool bNoClip=false);
1457 static void XyzToLab(icFloatNumber *Dst, const icFloatNumber *Src, bool bNoClip=false);
1458 static void Lab2ToXyz(icFloatNumber *Dst, const icFloatNumber *Src, bool bNoClip=false);
1459 static void XyzToLab2(icFloatNumber *Dst, const icFloatNumber *Src, bool bNoClip=false);
1460 static icFloatNumber NegClip(icFloatNumber v);
1462
1463 static void Lab2ToLab4(icFloatNumber *Dst, const icFloatNumber *Src, bool bNoclip=false);
1464 static void Lab4ToLab2(icFloatNumber *Dst, const icFloatNumber *Src);
1465protected:
1466
1467 bool m_bIsV2Lab;
1468 bool m_bLastPcsXform;
1469 icColorSpaceSignature m_Space;
1470
1471 icFloatNumber m_Convert[3];
1472};
1473
1474/**
1475 **************************************************************************
1476 Color data passed to/from the CMM is encoded as floating point numbers ranging from 0.0 to 1.0
1477 Often data is encoded using other ranges. The icFloatColorEncoding enum is used by the
1478 ToInternalEncoding() and FromInternalEncoding() functions to convert to/from the internal
1479 encoding. The valid encoding transforms for the following color space signatures are given
1480 below.
1481
1482 'CMYK', 'RGB ', 'GRAY', 'CMY ', 'Luv ', 'YCbr', 'Yxy ', 'HSV ', 'HLS ', 'gamt'
1483 icEncodePercent: 0.0 <= value <= 100.0
1484 icEncodeFloat: 0.0 <= value <= 1.0
1485 icEncode8Bit: 0.0 <= value <= 255
1486 icEncode16Bit: 0.0 <= value <= 65535
1487 icEncode16BitV2: 0.0 <= value <= 65535
1488
1489 'XCLR'
1490 icEncodeValue: (if X>=3) 0.0 <= L <= 100.0; -128.0 <= a,b <= 127.0 others 0.0 <= value <= 1.0
1491 icEncodePercent: 0.0 <= value <= 100.0
1492 icEncodeFloat: 0.0 <= value <= 1.0
1493 icEncode8Bit: 0.0 <= value <= 255
1494 icEncode16Bit: 0.0 <= value <= 65535
1495 icEncode16BitV2: 0.0 <= value <= 65535
1496
1497 'Lab '
1498 icEncodeValue: 0.0 <= L <= 100.0; -128.0 <= a,b <= 127.0
1499 icEncodeFloat: 0.0 <= L,a,b <= 1.0 - ICC PCS encoding (See ICC Specification)
1500 icEncode8BIt: ICC 8 bit Lab Encoding - See ICC Specification
1501 icEncode16Bit: ICC 16 bit V4 Lab Encoding - See ICC Specification
1502 icEncode16BitV2: ICC 16 bit V2 Lab Encoding - See ICC Specification
1503
1504 'XYZ '
1505 icEncodeValue: 0.0 <= X,Y,Z < 1.999969482421875
1506 icEncodePercent: 0.0 <= X,Y,Z < 199.9969482421875
1507 icEncodeFloat: 0.0 <= L,a,b <= 1.0 - ICC PCS encoding (See ICC Specification
1508 icEncode16Bit: ICC 16 bit XYZ Encoding - (icU1Fixed15) See ICC Specification
1509 icEncode16BitV2: ICC 16 bit XYZ Encoding - (icU1Fixed15) See ICC Specification
1510 **************************************************************************
1511*/
1512
1513typedef enum
1514{
1515 icEncodeValue=0,
1516 icEncodePercent,
1517 icEncodeUnitFloat,
1518 icEncodeFloat,
1519 icEncode8Bit,
1520 icEncode16Bit,
1521 icEncode16BitV2,
1522 icEncodeUnknown,
1523} icFloatColorEncoding;
1524
1525//Forward Reference of CIccCmm for CIccCmmApply
1526class CIccCmm;
1527
1528/**
1529**************************************************************************
1530* Type: Class
1531*
1532* Purpose: Defines a class that provides and interface for applying pixel
1533* transformations through a CMM. Multiply CIccCmmApply objects can use
1534* a single CIccCmm Object.
1535*
1536**************************************************************************
1537*/
1538class ICCPROFLIB_API CIccApplyCmm
1539{
1540 friend class CIccCmm;
1541public:
1542 virtual ~CIccApplyCmm();
1543
1544 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel);
1545
1546 //Make sure that when DstPixel==SrcPixel the sizeof DstPixel is less than size of SrcPixel
1547 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel, icUInt32Number nPixels);
1548
1549 void AppendApplyXform(CIccApplyXform *pApplyXform);
1550
1551 CIccCmm *GetCmm() { return m_pCmm; }
1552
1553 bool InitPixel();
1554
1555protected:
1556 CIccApplyCmm(CIccCmm *pCmm);
1557
1558 CIccApplyXformList *m_Xforms;
1559 CIccCmm *m_pCmm;
1560
1561 CIccPCS *m_pPCS;
1562
1563 icFloatNumber *m_Pixel;
1564 icFloatNumber *m_Pixel2;
1565};
1566
1567class IXformIterator
1568{
1569public:
1570 IXformIterator() {}
1571 virtual ~IXformIterator() {}
1572
1573 virtual void iterate(const CIccXform* pxform) = 0;
1574};
1575
1576/**
1577 **************************************************************************
1578 * Type: Class
1579 *
1580 * Purpose: Defines a class that allows one or more profiles to be applied
1581 * in order that they are Added.
1582 *
1583 **************************************************************************
1584 */
1585class ICCPROFLIB_API CIccCmm
1586{
1587 friend class CIccApplyCmm;
1588public:
1589 CIccCmm(icColorSpaceSignature nSrcSpace=icSigUnknownData,
1591 bool bFirstInput=true);
1592 virtual ~CIccCmm();
1593
1594 virtual CIccPCS *GetPCS() { return new CIccPCS(); }
1595
1596 ///Must make at least one call to some form of AddXform() before calling Begin()
1597 virtual icStatusCMM AddXform(const icChar *szProfilePath,
1602 bool bUseD2BxB2DxTags=true,
1603 CIccCreateXformHintManager *pHintManager=NULL,
1604 bool bUseSubProfile=false);
1605 virtual icStatusCMM AddXform(icUInt8Number *pProfileMem, icUInt32Number nProfileLen,
1609 icXformLutType nLutType=icXformLutColor, bool bUseD2BxB2DxTags =true,
1610 CIccCreateXformHintManager *pHintManager=NULL,
1611 bool bUseSubProfile=false);
1612 virtual icStatusCMM AddXform(CIccProfile *pProfile,
1617 bool bUseD2BxB2DxTags =true,
1618 CIccCreateXformHintManager *pHintManager=NULL); //Note: profile will be owned by the CMM
1619 virtual icStatusCMM AddXform(CIccProfile &Profile,
1624 bool bUseD2BxB2DxTags =true,
1625 CIccCreateXformHintManager *pHintManager=NULL); //Note the profile will be copied
1626 virtual icStatusCMM AddXform(CIccProfile *pProfile,
1627 CIccTag *pXformTag,
1629 icXformInterp nInterp = icInterpLinear,
1631 bool bUseD2BxB2DxTags =false,
1632 CIccCreateXformHintManager *pHintManager = NULL); //Note: profile will be owned by the CMM
1633
1634 //The Begin function should be called before Apply or GetNewApplyCmm()
1635 virtual icStatusCMM Begin(bool bAllocNewApply=true, bool bUsePcsConversion=false);
1636
1637 //Get an additional Apply cmm object to apply pixels with. The Apply object should be deleted by the caller.
1638 virtual CIccApplyCmm *GetNewApplyCmm(icStatusCMM &status);
1639
1640 virtual CIccApplyCmm *GetApply() { return m_pApply; }
1641
1642 //The following apply functions should only be called if using Begin(true);
1643 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel);
1644 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel, icUInt32Number nPixels);
1645
1646 //Call to Detach and remove all pending IO objects attached to the profiles used by the CMM. Should be called only after Begin()
1647 virtual icStatusCMM RemoveAllIO();
1648
1649 ///Returns the number of profiles/transforms added
1650 virtual icUInt32Number GetNumXforms() const;
1651
1652 virtual void IterateXforms(IXformIterator* pIterater) const;
1653
1654 ///Returns the source color space
1655 icColorSpaceSignature GetSourceSpace() const { return m_nSrcSpace; }
1656 ///Returns the destination color space
1657 icColorSpaceSignature GetDestSpace() const { return m_nDestSpace; }
1658 ///Returns the color space of the last profile added
1659 icColorSpaceSignature GetLastSpace() const { return m_nLastSpace; }
1660 ///Returns the rendering intent of the last profile added
1661 icRenderingIntent GetLastIntent() const { return m_nLastIntent; }
1662
1663 bool IsLastOutPut() const { return !m_bLastInput; }
1664
1665 ///Returns the number of samples in the source color space
1666 icUInt16Number GetSourceSamples() const {return (icUInt16Number)icGetSpaceSamples(m_nSrcSpace);}
1667 ///Returns the number of samples in the destination color space
1668 icUInt16Number GetDestSamples() const {return (icUInt16Number)icGetSpaceSamples(m_nDestSpace);}
1669
1670 ///Checks if this is a valid CMM object
1671 bool Valid() const { return m_bValid; }
1672
1673 //Function to convert check if Internal representation of 'gamt' color is in gamut.
1674 static bool IsInGamut(icFloatNumber *pData);
1675
1676 ///Functions for converting to Internal representation of pixel colors
1677 static icStatusCMM ToInternalEncoding(icColorSpaceSignature nSpace, icFloatColorEncoding nEncode,
1678 icFloatNumber *pInternal, const icFloatNumber *pData, bool bClip=true);
1679 static icStatusCMM ToInternalEncoding(icColorSpaceSignature nSpace, icFloatNumber *pInternal,
1680 const icUInt8Number *pData);
1681 static icStatusCMM ToInternalEncoding(icColorSpaceSignature nSpace, icFloatNumber *pInternal,
1682 const icUInt16Number *pData);
1683 icStatusCMM ToInternalEncoding(icFloatNumber *pInternal, const icUInt8Number *pData) {return ToInternalEncoding(m_nSrcSpace, pInternal, pData);}
1684 icStatusCMM ToInternalEncoding(icFloatNumber *pInternal, const icUInt16Number *pData) {return ToInternalEncoding(m_nSrcSpace, pInternal, pData);}
1685
1686
1687 ///Functions for converting from Internal representation of pixel colors
1688 static icStatusCMM FromInternalEncoding(icColorSpaceSignature nSpace, icFloatColorEncoding nEncode,
1689 icFloatNumber *pData, const icFloatNumber *pInternal, bool bClip=true);
1690 static icStatusCMM FromInternalEncoding(icColorSpaceSignature nSpace, icUInt8Number *pData,
1691 const icFloatNumber *pInternal);
1692 static icStatusCMM FromInternalEncoding(icColorSpaceSignature nSpace, icUInt16Number *pData,
1693 const icFloatNumber *pInternal);
1694 icStatusCMM FromInternalEncoding(icUInt8Number *pData, icFloatNumber *pInternal) {return FromInternalEncoding(m_nDestSpace, pData, pInternal);}
1695 icStatusCMM FromInternalEncoding(icUInt16Number *pData, icFloatNumber *pInternal) {return FromInternalEncoding(m_nDestSpace, pData, pInternal);}
1696
1697 static const icChar *GetFloatColorEncoding(icFloatColorEncoding val);
1698 static icFloatColorEncoding GetFloatColorEncoding(const icChar* val);
1699
1700 virtual icColorSpaceSignature GetFirstXformSource();
1701 virtual icColorSpaceSignature GetLastXformDest();
1702
1703 static const icChar *GetStatusText(icStatusCMM stat);
1704
1705protected:
1706 void SetLateBindingCC();
1707
1708 icStatusCMM CheckPCSRangeConversions();
1709 icStatusCMM CheckPCSConnections(bool bUsePCSConversions=false);
1710
1711 CIccApplyCmm *m_pApply;
1712
1713 bool m_bValid;
1714
1715 bool m_bLastInput;
1716 icColorSpaceSignature m_nSrcSpace;
1717 icColorSpaceSignature m_nDestSpace;
1718
1719 icColorSpaceSignature m_nLastSpace;
1720 icRenderingIntent m_nLastIntent;
1721
1722 CIccXformList *m_Xforms;
1723};
1724
1725//Forward Class for CIccApplyNamedColorCmm
1726class CIccNamedColorCmm;
1727/**
1728**************************************************************************
1729* Type: Class
1730*
1731* Purpose: Defines a class that provides and interface for applying pixel
1732* transformations through a Named Color CMM. Multiply CIccApplyNamedColorCmm
1733* objects can refer to a single CIccNamedColorCmm Object.
1734*
1735**************************************************************************
1736*/
1737class ICCPROFLIB_API CIccApplyNamedColorCmm : public CIccApplyCmm
1738{
1739 friend class CIccNamedColorCmm;
1740public:
1741 virtual ~CIccApplyNamedColorCmm();
1742
1743 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel);
1744
1745 //Make sure that when DstPixel==SrcPixel the sizeof DstPixel is less than size of SrcPixel
1746 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel, icUInt32Number nPixels);
1747
1748 ///Define 4 apply interfaces that are used depending upon the source and destination xforms
1749 virtual icStatusCMM Apply(icChar* DstColorName, const icFloatNumber *SrcPixel);
1750 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icChar *SrcColorName, icFloatNumber tint=1.0);
1751 virtual icStatusCMM Apply(icChar* DstColorName, const icChar *SrcColorName, icFloatNumber tint=1.0);
1752
1753protected:
1754 CIccApplyNamedColorCmm(CIccNamedColorCmm *pCmm);
1755};
1756
1757/**
1758 **************************************************************************
1759 * Type: Class
1760 *
1761 * Purpose: A Slower Named Color Profile compatible CMM
1762 *
1763 **************************************************************************
1764 */
1765class ICCPROFLIB_API CIccNamedColorCmm : public CIccCmm
1766{
1767 friend class CIccApplyNamedColorCmm;
1768public:
1769 ///nSrcSpace cannot be icSigUnknownData if first profile is named color
1770 CIccNamedColorCmm(icColorSpaceSignature nSrcSpace=icSigUnknownData,
1772 bool bFirstInput=true);
1773 virtual ~CIccNamedColorCmm();
1774
1775 ///Must make at least one call to some form of AddXform() before calling Begin()
1776 virtual icStatusCMM AddXform(const icChar *szProfilePath,
1781 bool bUseD2BxB2DxTags=true,
1782 CIccCreateXformHintManager *pHintManager=NULL,
1783 bool bUseSubProfile=false);
1784 virtual icStatusCMM AddXform(CIccProfile *pProfile,
1789 bool bUseD2BxB2DxTags =true,
1790 CIccCreateXformHintManager *pHintManager=NULL); //Note: profile will be owned by the CMM
1791
1792 ///Must be called before calling Apply() or GetNewApply()
1793 //The Begin function should be called before Apply or GetNewApplyCmm()
1794 virtual icStatusCMM Begin(bool bAllocNewApply=true, bool bUsePcsConversion=false);
1795
1796 virtual CIccApplyCmm *GetNewApplyCmm(icStatusCMM &status);
1797
1798
1799 //The following apply functions should only be called if using Begin(true);
1800 icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel) { return CIccCmm::Apply(DstPixel, SrcPixel); }
1801 icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel, icUInt32Number nPixels) { return CIccCmm::Apply(DstPixel, SrcPixel, nPixels); }
1802 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icChar *SrcColorName, icFloatNumber tint=1.0);
1803 virtual icStatusCMM Apply(icChar* DstColorName, const icFloatNumber *SrcPixel);
1804 virtual icStatusCMM Apply(icChar* DstColorName, const icChar *SrcColorName, icFloatNumber tint=1.0);
1805
1806 ///Returns the type of interface that will be applied
1807 icApplyInterface GetInterface() const {return m_nApplyInterface;}
1808
1809 icStatusCMM SetLastXformDest(icColorSpaceSignature nDestSpace);
1810
1811protected:
1812 icApplyInterface m_nApplyInterface;
1813};
1814
1815template<class T>
1816class ICCPROFLIB_API CIccMruPixel
1817{
1818public:
1819 CIccMruPixel() { pPixelData = NULL; pNext = NULL; }
1820
1821 T *pPixelData;
1822 CIccMruPixel *pNext;
1823};
1824
1825typedef CIccMruPixel<icFloatNumber> CIccMruPixelFloat;
1826typedef CIccMruPixel<icUInt8Number> CIccMruPixel8;
1827typedef CIccMruPixel<icUInt16Number> CIccMruPixel16;
1828
1829/**
1830**************************************************************************
1831* Type: Class
1832*
1833* Purpose: Defines a class that provides and interface for caching
1834* application pf pixel transformations through a CMM.
1835*
1836**************************************************************************
1837*/
1838template <class T>
1839class ICCPROFLIB_API CIccMruCache
1840{
1841public:
1842 static CIccMruCache<T> *NewMruCache(icUInt16Number nSrcSamples, icUInt16Number nDstSamples, icUInt16Number nCacheSize = 4);
1843
1844 virtual ~CIccMruCache();
1845
1846 virtual bool Apply(T *DstPixel, const T *SrcPixel);
1847 virtual void Update(T *DstPixel);
1848
1849protected:
1850 CIccMruCache();
1851 bool Init(icUInt16Number nSrcSamples, icUInt16Number nDstSamples, icUInt16Number nCacheSize = 4);
1852
1853 icUInt16Number m_nCacheSize;
1854
1855 T *m_pixelData;
1856
1857 CIccMruPixel<T> *m_pFirst;
1858 CIccMruPixel<T> *m_cache;
1859
1860 icUInt16Number m_nNumPixel;
1861
1862 icUInt32Number m_nTotalSamples;
1863 icUInt32Number m_nSrcSamples;
1864
1865 icUInt32Number m_nSrcSize;
1866 icUInt32Number m_nDstSize;
1867};
1868
1869typedef CIccMruCache<icFloatNumber> CIccMruCacheFloat;
1870typedef CIccMruCache<icUInt8Number> CIccMruCache8;
1871typedef CIccMruCache<icUInt16Number> CIccMruCache16;
1872
1873// forward class CIccMruCmm used by CIccApplyMruCmm
1874class CIccMruCmm;
1875/**
1876**************************************************************************
1877* Type: Class
1878*
1879* Purpose: Defines a class that provides and interface for applying pixel
1880* transformations through a CMM. Multiply CIccCmmApply objects can use
1881* a single CIccCmm Object.
1882*
1883**************************************************************************
1884*/
1885class ICCPROFLIB_API CIccApplyMruCmm : public CIccApplyCmm
1886{
1887 friend class CIccMruCmm;
1888public:
1889 virtual ~CIccApplyMruCmm();
1890
1891 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel);
1892
1893 //Make sure that when DstPixel==SrcPixel the sizeof DstPixel is greater than size of SrcPixel
1894 virtual icStatusCMM Apply(icFloatNumber *DstPixel, const icFloatNumber *SrcPixel, icUInt32Number nPixels);
1895
1896protected:
1897 CIccApplyMruCmm(CIccMruCmm *pCmm);
1898
1899 bool Init(CIccCmm *pCachedCmm, icUInt16Number nCacheSize);
1900
1901 CIccCmm *m_pCachedCmm;
1902 CIccMruCacheFloat *m_pCache;
1903};
1904
1905/**
1906**************************************************************************
1907* Type: Class
1908*
1909* Purpose: A CMM decorator class that provides limited caching of results
1910*
1911**************************************************************************
1912*/
1913class ICCPROFLIB_API CIccMruCmm : public CIccCmm
1914{
1915 friend class CIccApplyMruCmm;
1916private:
1917 CIccMruCmm();
1918public:
1919 virtual ~CIccMruCmm();
1920
1921 //This is the function used to create a new CIccMruCmm. The pCmm must be valid and its Begin() already called.
1922 static CIccMruCmm* Attach(CIccCmm *pCmm, icUInt8Number nCacheSize=6, bool bDeleteCmm=true); //The returned object will own pCmm, and pCmm is deleted on failure.
1923
1924 //override AddXform/Begin functions to return bad status.
1925 virtual icStatusCMM AddXform(const icChar *szProfilePath, icRenderingIntent nIntent=icUnknownIntent,
1927 bool bUseMpeTags=true, CIccCreateXformHintManager *pHintManager=NULL) { return icCmmStatBad; }
1928 virtual icStatusCMM AddXform(icUInt8Number *pProfileMem, icUInt32Number nProfileLen,
1930 icXformLutType nLutType=icXformLutColor, bool bUseMpeTags=true, CIccCreateXformHintManager *pHintManager=NULL) { return icCmmStatBad; }
1931 virtual icStatusCMM AddXform(CIccProfile *pProfile, icRenderingIntent nIntent=icUnknownIntent,
1933 bool bUseMpeTags=true, CIccCreateXformHintManager *pHintManager=NULL) { return icCmmStatBad; }
1934 virtual icStatusCMM AddXform(CIccProfile &Profile, icRenderingIntent nIntent=icUnknownIntent,
1936 bool bUseMpeTags=true, CIccCreateXformHintManager *pHintManager=NULL) { return icCmmStatBad; }
1937
1938 virtual CIccApplyCmm *GetNewApplyCmm(icStatusCMM &status);
1939
1940 //Forward calls to attached CMM
1941 virtual icStatusCMM RemoveAllIO() { return m_pCmm->RemoveAllIO(); }
1942 virtual CIccPCS *GetPCS() { return m_pCmm->GetPCS(); }
1943 virtual icUInt32Number GetNumXforms() const { return m_pCmm->GetNumXforms(); }
1944
1945 virtual icColorSpaceSignature GetFirstXformSource() { return m_pCmm->GetFirstXformSource(); }
1946 virtual icColorSpaceSignature GetLastXformDest() { return m_pCmm->GetLastXformDest(); }
1947
1948protected:
1949 CIccCmm *m_pCmm;
1950 icUInt16Number m_nCacheSize;
1951 bool m_bDeleteCmm;
1952
1953};
1954
1955#endif //__cplusplus
1956
1957#if defined(__cplusplus) && defined(USEREFICCMAXNAMESPACE)
1958}; //namespace refIccMAX
1959#endif
1960
1961#endif // !defined(_ICCCMM_H)
icArraySignature sig
icXformLutType
CMM Xform LUT types.
Definition IccCmm.h:125
@ icXformLutNamedColor
Definition IccCmm.h:127
@ icXformLutBRDFDirect
Definition IccCmm.h:132
@ icXformLutBRDFMcsParam
Definition IccCmm.h:133
@ icXformLutGamut
Definition IccCmm.h:129
@ icXformLutColorimetric
Definition IccCmm.h:135
@ icXformLutMCS
Definition IccCmm.h:134
@ icXformLutColor
Definition IccCmm.h:126
@ icXformLutSpectral
Definition IccCmm.h:136
@ icXformLutBPC
Definition IccCmm.h:130
@ icXformLutPreview
Definition IccCmm.h:128
@ icXformLutBRDFParam
Definition IccCmm.h:131
icXformInterp
CMM Interpolation types.
Definition IccCmm.h:113
@ icInterpTetrahedral
Definition IccCmm.h:115
@ icInterpLinear
Definition IccCmm.h:114
icStatusCMM
CMM return status values.
Definition IccCmm.h:90
@ icCmmStatBadLutType
Definition IccCmm.h:103
@ icCmmStatInvalidProfile
Definition IccCmm.h:95
@ icCmmStatTooManySamples
Definition IccCmm.h:108
@ icCmmStatProfileMissingTag
Definition IccCmm.h:98
@ icCmmStatBadSpaceLink
Definition IccCmm.h:94
@ icCmmStatBadMCSLink
Definition IccCmm.h:109
@ icCmmStatIncorrectApply
Definition IccCmm.h:100
@ icCmmStatUnsupportedPcsLink
Definition IccCmm.h:105
@ icCmmStatBadColorEncoding
Definition IccCmm.h:101
@ icCmmStatCantOpenProfile
Definition IccCmm.h:93
@ icCmmStatBadConnection
Definition IccCmm.h:106
@ icCmmStatBadXform
Definition IccCmm.h:96
@ icCmmStatBad
Definition IccCmm.h:91
@ icCmmStatBadTintXform
Definition IccCmm.h:107
@ icCmmStatColorNotFound
Definition IccCmm.h:99
@ icCmmStatOk
Definition IccCmm.h:92
@ icCmmStatIdentityXform
Definition IccCmm.h:104
@ icCmmStatInvalidLut
Definition IccCmm.h:97
@ icCmmStatAllocErr
Definition IccCmm.h:102
icMCSConnectionType
Definition IccCmm.h:118
@ icNoMCS
Definition IccCmm.h:119
@ icToMCS
Definition IccCmm.h:120
@ icFromMCS
Definition IccCmm.h:121
icXformType
Definition IccCmm.h:148
@ icXformTypeMpe
Definition IccCmm.h:154
@ icXformTypeMatrixTRC
Definition IccCmm.h:149
@ icXformTypeNDLut
Definition IccCmm.h:152
@ icXformTypeMonochrome
Definition IccCmm.h:155
@ icXformType3DLut
Definition IccCmm.h:150
@ icXformType4DLut
Definition IccCmm.h:151
@ icXformTypeNamedColor
Definition IccCmm.h:153
@ icXformTypeUnknown
Definition IccCmm.h:158
@ icXformTypePCS
Definition IccCmm.h:157
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
File: IccCmm.h.
#define ICCPROFLIB_API
File: IccProfile.h.
File: IccTag.h.
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
Definition IccUtil.cpp:1303
File: IccUtil.h.
unsigned int icUInt32Number
Class: CIccApplyCLUT.
Definition IccTagLut.h:302
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:321
Class: CIccArrayNamedColor.
Class: CIccCurve.
Definition IccTagLut.h:91
Class: CIccMBB.
Definition IccTagLut.h:428
Class: CIccMatrix.
Definition IccTagLut.h:260
Type: Class.
Class: CIccMpeMatrix.
Class: CIccTagArray.
Class: CIccTag.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
Class: CIccTagNamedColor2.
Class: CIccTagNumArray.
Class: CIccTagXYZ.
Type: Class.
Definition IccUtil.h:401
unsigned char icUInt8Number
Number definitions.
#define icUnknownIntent
Convenience Enum Definitions - Not defined in ICC specification.
unsigned short icUInt16Number
#define icVersionNumberV4
@ icSigAbstractClass
icColorSpaceSignature
Color Space Signatures.
icUInt32Number icSignature
#define icSigUnknownData
icSpectralColorSignature
icSpectralColorSignature enumerations
@ icSigNoSpectralData
#define icExtendedRangePCS
icRenderingIntent
Rendering Intents, used in the profile header.
static icFloatNumber UnitClip(icFloatNumber v)
spectral range