mg2cms.h

Go to the documentation of this file.
00001 /**
00002  * \file mi32/mg2cms.h
00003  * \brief MGD classes for ICM
00004  *
00005  * vim: ts=3 sw=3
00006  *
00007  * \if NODOC
00008  * $Log: mg2cms.h_v $
00009  * Revision 1.17  2003/10/01 22:16:27  dwilliss
00010  * Doxygen
00011  *
00012  * Revision 1.16  2003/09/15 13:49:56  fileserver!dwilliss
00013  * Doxygen
00014  *
00015  * Revision 1.15  2003/07/31 20:36:07  dwilliss
00016  * Added operator== and operator!= for MGD::PROFILE
00017  *
00018  * Revision 1.14  2003/07/03 22:17:08  dwilliss
00019  * *** empty log message ***
00020  *
00021  * Revision 1.13  2003/07/03 17:52:10  dwilliss
00022  * *** empty log message ***
00023  *
00024  * Revision 1.12  2003/06/27 19:12:14  dwilliss
00025  * *** empty log message ***
00026  *
00027  * Revision 1.11  2003/06/16 22:56:43  dwilliss
00028  * *** empty log message ***
00029  *
00030  * Revision 1.10  2003/06/13 20:28:12  dwilliss
00031  * Added PROFILEPARMS base class, changed PROFILEPARMS_RGB to derive from it
00032  * and added PROFILEPARMS_PRINTER
00033  *
00034  * Revision 1.9  2003/06/12 17:40:52  dwilliss
00035  * Fixed a const problem
00036  *
00037  * Revision 1.8  2003/06/12 15:05:54  dwilliss
00038  * include colorspc.h
00039  *
00040  * Revision 1.7  2003/06/11 17:11:43  dwilliss
00041  * Virtual methods all renamed to start with v_ and made private (where
00042  * Changed a bunch of stuff
00043  * AAARG!)
00044  * possible) or protected.
00045  *
00046  * Revision 1.6  2003/06/06 22:34:29  dwilliss
00047  * Still implementing
00048  *
00049  * Revision 1.5  2003/05/28 15:13:46  dwilliss
00050  * Still working on implementation
00051  *
00052  * Revision 1.4  2003/05/22 15:43:35  dwilliss
00053  * Cleaned up so that the implementation module will compile without having
00054  * to cast stuff all over the place
00055  *
00056  * Revision 1.3  2003/05/22 14:17:24  dwilliss
00057  * Don't include contrib include file here.
00058  *
00059  * Revision 1.2  2003/05/21 22:30:37  dwilliss
00060  * *** empty log message ***
00061  *
00062  * Revision 1.1  2003/05/16 16:01:07  dwilliss
00063  * Initial revision
00064  *
00065  *
00066  * \endif
00067  **/
00068 
00069 #ifndef INC_MI32_MG2CMS_H
00070 #define INC_MI32_MG2CMS_H
00071 
00072 #ifndef INC_MI32_STDDEFNS_H
00073 #include <mi32/stddefns.h>
00074 #endif
00075 
00076 #ifndef INC_MI32_FILEPATH_H
00077 #include <mi32/filepath.h>
00078 #endif
00079 
00080 #ifndef INC_MI32_MILIST_H
00081 #include <mi32/milist.h>
00082 #endif
00083 
00084 #ifndef INC_MI32_COLORSPC_H
00085 #include <mi32/colorspc.h>
00086 #endif
00087 
00088 #ifndef INC_MI32_MCB_H
00089 #include <mi32/mcb.h>
00090 #endif
00091 
00092 #ifndef INC_MI32_SERIALIZ_H
00093 #include <mi32/serializ.h>
00094 #endif
00095 
00096 struct COLOR;
00097 class MISTRING;
00098 class XMLNODE;
00099 
00100 namespace MGUI {
00101 class XMLFORM_DATA;
00102 }
00103 
00104 
00105 //! Forward decl of things defined in lcms/lcms.h, which we can't include here.
00106 typedef void* cmsHPROFILE;
00107 typedef void* cmsHTRANSFORM;
00108 
00109 #ifndef GENERATING_DOXYGEN_OUTPUT
00110 //! Warning! This is evil!
00111 //! Several methods need to take a COLORXYZ or COLORxyY, which consists of three
00112 //! doubles and won't fit in our COLOR structure.  I'd like to just pass the
00113 //! cmsCIEXYZ and cmsCIExyY structures, but they're defined in an include file
00114 //! that our rules say I can't include here. 
00115 //! I can define my own versions of them, but then I'd have to cast them a lot
00116 //! inside the implementation module.  The solution is to define them as being
00117 //! derived from the real cms classes if lcms/lcms.h has been included and 
00118 //! define the same thing myself if not.
00119 #ifdef __cms_H
00120 #define COLORXYZ_BASE   cmsCIEXYZ
00121 #define COLORxyY_BASE   cmsCIExyY
00122 #else
00123 namespace { 
00124    struct CIECOLORXYZ { double X, Y, Z; }; 
00125    struct CIECOLORxyY { double x, y, Y; }; 
00126 }
00127 #define COLORXYZ_BASE   CIECOLORXYZ
00128 #define COLORxyY_BASE   CIECOLORxyY
00129 #endif
00130 #endif // GENERATING_DOXYGEN_OUTPUT
00131 
00132 
00133 //! A color in XYZ space, represented using doubles instead of INT16.
00134 //! The class members are public, but not shown here due to the way
00135 //! the class is defined. They're named X, Y, and Z
00136 //! If you have included <lcms/lcms.h> before this include file, then
00137 //! COLORXYZ is defined as being derived from cmsCIEXYZ so that you can
00138 //! pass one to functions in the lcms library.  But only the mg2cms.c
00139 //! module needs to do that.
00140 class COLORXYZ : public COLORXYZ_BASE {
00141    public:
00142       COLORXYZ();
00143       COLORXYZ(double X, double Y, double Z);
00144       COLORXYZ(const COLORXYZ&);
00145       explicit COLORXYZ(const COLOR&);
00146       COLORXYZ& operator=(const COLORXYZ& rhs);
00147       COLORXYZ& operator=(const COLOR& rhs);
00148 
00149       //! Get the ITEMDEF array for serializing this class
00150       static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00151 
00152       //! Converts the color to sRGB and returns in our COLOR structure
00153       //! Returns false if out of gammut
00154       bool GetColor_sRGB(COLOR&) const;
00155    };
00156 
00157 
00158 //! A color in xyY space, represented using doubles instead of INT16.
00159 //! The class members are public, but not shown here due to the way
00160 //! the class is defined. They're named x, y, and Y
00161 //! If you have included <lcms/lcms.h> before this include file, then
00162 //! COLORxyY is defined as being derived from cmsCIExyY so that you can
00163 //! pass one to functions in the lcms library.  But only the mg2cms.c
00164 //! module needs to do that.
00165 class COLORxyY : public COLORxyY_BASE {
00166    public:
00167       COLORxyY();
00168       COLORxyY(double x, double y, double Y);
00169       COLORxyY(const COLORxyY&);
00170       COLORxyY(const COLOR&);
00171       COLORxyY& operator=(const COLORxyY& rhs);
00172       COLORxyY& operator=(const COLOR& rhs);
00173 
00174       //! Get the ITEMDEF array for serializing this class
00175       static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00176 
00177       //! Set a color as a WhitePoint in degrees Kelvin
00178       bool SetTemperature (
00179          int DegreesKelvin
00180          );
00181 
00182       //! Converts the color to sRGB and returns in our COLOR structure
00183       //! Returns false if out of gammut
00184       bool GetColor_sRGB(COLOR&) const;
00185 
00186    //! Actual data is inherited from the base class, defined by lcms.h
00187    };
00188 
00189 namespace MGD {
00190 
00191    class TRANSFORM;
00192    class DEVICE;
00193    class PROFILEPARMS_RGB;
00194    class PROFILEPARMS_PRINTER;
00195 
00196    class GAMMA {
00197       public:
00198          GAMMA (
00199             int entries,
00200             double gamma
00201             );
00202 
00203          ~GAMMA();
00204 
00205          //! Smooths the gamma table.
00206          //! "Smooth" curves work better and are more pleasant to the eyes.
00207          //! Documentation doesn't say what lambda values should be.
00208          bool Smooth (
00209             double lambda
00210             );
00211 
00212          #ifndef GENERATING_DOXYGEN_OUTPUT
00213 #ifdef __cms_H
00214          //! Returns the GAMMATABLE as expected by the lcms library functions
00215          GAMMATABLE* GetTable (
00216             ) const {
00217             return m_table;
00218             }
00219 #endif
00220          #endif // GENERATING_DOXYGEN_OUTPUT
00221 
00222          //! Could define += and + operators which would call
00223          //!   cmsJoinGamma
00224          //!
00225       private:
00226          #ifndef GENERATING_DOXYGEN_OUTPUT
00227 #ifdef __cms_H
00228          //! Only defined inside the implementation module.  We can't forward
00229          //! declare it because it's defined in a contributed include file as
00230          //! an nunamed struct with a typedef.
00231          GAMMATABLE* m_table;
00232 #else
00233          void* m_table; 
00234 #endif
00235          #endif // GENERATING_DOXYGEN_OUTPUT
00236 
00237       };
00238 
00239    //! In-memory representataion of an ICM profile
00240    class PROFILE {
00241       public:
00242          //! Profiles which can be hard-coded without the need for a file
00243          enum BUILTIN_PROFILE {
00244             PROFILE_NONE      = -1,    //!< so we can initialize to "not set" 
00245             PROFILE_sRGB      = 0,
00246             PROFILE_XYZ,
00247             PROFILE_LAB,
00248             PROFILE_AdobeRGB_1998,
00249             PROFILE_AppleRGB
00250             };
00251 
00252          //! Rendering Intent
00253          enum INTENT {
00254             INTENT_Perceptual             = 0,     //!< The default
00255             INTENT_RelativeColorimetric   = 1,
00256             INTENT_Saturation             = 2,
00257             INTENT_AbsoluteColorimetric   = 3
00258             };
00259 
00260          //! Profile usage.  Used as a parameter to SupportsIntent()
00261          enum USAGE {
00262             USAGE_Input    = 0,
00263             USAGE_Output   = 1,
00264             USAGE_Proof    = 2
00265             };
00266 
00267          //! ICM Profile tags.
00268          //! These are only used to see if a profile has a given tag, and 
00269          //! eventually to retrieve data for specific tags
00270          enum TAG {
00271             TAG_AToB0                       = 0x41324230L,  //!<  'A2B0' 
00272             TAG_AToB1                       = 0x41324231L,  //!<  'A2B1' 
00273             TAG_AToB2                       = 0x41324232L,  //!<  'A2B2' 
00274             TAG_BlueColorant                = 0x6258595AL,  //!<  'bXYZ' 
00275             TAG_BlueTRC                     = 0x62545243L,  //!<  'bTRC' 
00276             TAG_BToA0                       = 0x42324130L,  //!<  'B2A0' 
00277             TAG_BToA1                       = 0x42324131L,  //!<  'B2A1' 
00278             TAG_BToA2                       = 0x42324132L,  //!<  'B2A2' 
00279             TAG_CalibrationDateTime         = 0x63616C74L,  //!<  'calt' 
00280             TAG_CharTarget                  = 0x74617267L,  //!<  'targ' 
00281             TAG_Copyright                   = 0x63707274L,  //!<  'cprt' 
00282             TAG_CrdInfo                     = 0x63726469L,  //!<  'crdi' 
00283             TAG_DeviceMfgDesc               = 0x646D6E64L,  //!<  'dmnd' 
00284             TAG_DeviceModelDesc             = 0x646D6464L,  //!<  'dmdd' 
00285             TAG_Gamut                       = 0x67616D74L,  //!<  'gamt ' 
00286             TAG_GrayTRC                     = 0x6b545243L,  //!<  'kTRC' 
00287             TAG_GreenColorant               = 0x6758595AL,  //!<  'gXYZ' 
00288             TAG_GreenTRC                    = 0x67545243L,  //!<  'gTRC' 
00289             TAG_Luminance                   = 0x6C756d69L,  //!<  'lumi' 
00290             TAG_Measurement                 = 0x6D656173L,  //!<  'meas' 
00291             TAG_MediaBlackPoint             = 0x626B7074L,  //!<  'bkpt' 
00292             TAG_MediaWhitePoint             = 0x77747074L,  //!<  'wtpt' 
00293             TAG_NamedColor                  = 0x6E636f6CL,  /* 'ncol' 
00294                                                                   * OBSOLETE, use ncl2 */
00295             TAG_NamedColor2                 = 0x6E636C32L,  //!<  'ncl2' 
00296             TAG_Preview0                    = 0x70726530L,  //!<  'pre0' 
00297             TAG_Preview1                    = 0x70726531L,  //!<  'pre1' 
00298             TAG_Preview2                    = 0x70726532L,  //!<  'pre2' 
00299             TAG_ProfileDescription          = 0x64657363L,  //!<  'desc' 
00300             TAG_ProfileSequenceDesc         = 0x70736571L,  //!<  'pseq' 
00301             TAG_Ps2CRD0                     = 0x70736430L,  //!<  'psd0' 
00302             TAG_Ps2CRD1                     = 0x70736431L,  //!<  'psd1' 
00303             TAG_Ps2CRD2                     = 0x70736432L,  //!<  'psd2' 
00304             TAG_Ps2CRD3                     = 0x70736433L,  //!<  'psd3' 
00305             TAG_Ps2CSA                      = 0x70733273L,  //!<  'ps2s' 
00306             TAG_RenderingIntent             = 0x70733269L,  //!<  'ps2i' 
00307             TAG_RedColorant                 = 0x7258595AL,  //!<  'rXYZ' 
00308             TAG_RedTRC                      = 0x72545243L,  //!<  'rTRC' 
00309             TAG_ScreeningDesc               = 0x73637264L,  //!<  'scrd' 
00310             TAG_Screening                   = 0x7363726EL,  //!<  'scrn' 
00311             TAG_Technology                  = 0x74656368L,  //!<  'tech' 
00312             TAG_UcrBg                       = 0x62666420L,  //!<  'bfd ' 
00313             TAG_ViewingCondDesc             = 0x76756564L,  //!<  'vued' 
00314             TAG_ViewingConditions           = 0x76696577L  //!<  'view' 
00315          };
00316 
00317          /* 
00318           * Color Space Signatures
00319           * Note that only icSigXYZData and icSigLabData are valid
00320           * Profile Connection Spaces (PCSs)
00321           *
00322           * These are NOT the same as our COLORSPACE enum, which really should
00323           * have been called FORMAT or something.
00324           */ 
00325          enum ICMCOLORSPACE {
00326             ICMCOLORSPACE_XYZ                 = 0x58595A20L,  //!<  'XYZ ' 
00327             ICMCOLORSPACE_Lab                 = 0x4C616220L,  //!<  'Lab ' 
00328             ICMCOLORSPACE_Luv                 = 0x4C757620L,  //!<  'Luv ' 
00329             ICMCOLORSPACE_YCbCr               = 0x59436272L,  //!<  'YCbr' 
00330             ICMCOLORSPACE_Yxy                 = 0x59787920L,  //!<  'Yxy ' 
00331             ICMCOLORSPACE_RGB                 = 0x52474220L,  //!<  'RGB ' 
00332             ICMCOLORSPACE_Gray                = 0x47524159L,  //!<  'GRAY' 
00333             ICMCOLORSPACE_HSV                 = 0x48535620L,  //!<  'HSV ' 
00334             ICMCOLORSPACE_HLS                 = 0x484C5320L,  //!<  'HLS ' 
00335             ICMCOLORSPACE_CMYK                = 0x434D594BL,  //!<  'CMYK' 
00336             ICMCOLORSPACE_CMY                 = 0x434D5920L,  //!<  'CMY ' 
00337             ICMCOLORSPACE_2Color              = 0x32434C52L,  //!<  '2CLR' 
00338             ICMCOLORSPACE_3Color              = 0x33434C52L,  //!<  '3CLR' 
00339             ICMCOLORSPACE_4Color              = 0x34434C52L,  //!<  '4CLR' 
00340             ICMCOLORSPACE_5Color              = 0x35434C52L,  //!<  '5CLR' 
00341             ICMCOLORSPACE_6Color              = 0x36434C52L,  //!<  '6CLR' 
00342             ICMCOLORSPACE_7Color              = 0x37434C52L,  //!<  '7CLR' 
00343             ICMCOLORSPACE_8Color              = 0x38434C52L   //!<  '8CLR' 
00344             };
00345 
00346          //! Profile class
00347          enum CLASS {
00348             CLASS_Unspecified               = 0,
00349             CLASS_Input                     = 0x73636E72L,  //!<  'scnr' 
00350             CLASS_Display                   = 0x6D6E7472L,  //!<  'mntr' 
00351             CLASS_Output                    = 0x70727472L,  //!<  'prtr' 
00352             CLASS_Link                      = 0x6C696E6BL,  //!<  'link' 
00353             CLASS_Abstract                  = 0x61627374L,  //!<  'abst' 
00354             CLASS_ColorSpace                = 0x73706163L,  //!<  'spac' 
00355             CLASS_NamedColor                = 0x6e6d636cL   //!<  'nmcl' 
00356             };
00357 
00358          //! Predefined primaries for custom RGB profiles.  
00359          //! Call EnumeratePrimaries() to retrieve a list of pre-defined primaries
00360          struct PRIMARIES {
00361             int id;              //!< A unique identifier for comboboxes
00362             const char* name;    //!< will be translated through tntxres.txt, though most are acronyms (NTCS, PAL, etc)
00363             COLORxyY red;
00364             COLORxyY green;
00365             COLORxyY blue;
00366          
00367             //! Get the ITEMDEF array for serializing this class
00368             static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00369             };
00370 
00371          //! Standard Whitepoints
00372          //! Call EnumerateWhitePoints() to retrieve a list of pre-defined white points
00373          struct WHITEPOINT {
00374             int id;              //!< A unique identifier for comboboxes
00375             const char* name;    //!< will be translated through tntxres.txt, though most are like "6500\\xB0K (D65)"  ('\\xB0' is the degree symbol)
00376             COLORxyY color;
00377             };
00378 
00379          class LISTENTRY;
00380 
00381          //! Default constructor
00382          //! Empty profile until Open or something els/PRIM is called
00383          PROFILE (
00384             ) :
00385             m_priv(0)
00386             {
00387             }
00388 
00389          //! Construct a built-in profile
00390          //!   - PROFILE::PROFILE_sRGB
00391          //!   - PROFILE::PROFILE_XYZ
00392          //!   - PROFILE::PROFILE_LAB
00393          PROFILE (
00394             BUILTIN_PROFILE builtin
00395             ) :
00396             m_priv(0)
00397             {
00398                CreateBuiltInProfile(builtin);
00399             }
00400          
00401          //! Copy constructor
00402          //! Copy is "cheap" as the actual data is refcounted
00403          PROFILE (
00404             const PROFILE& rhs
00405             );
00406 
00407          //! Destructor 
00408          //! (note: not virtual.  No derived classes)
00409          ~PROFILE (
00410             );
00411 
00412          //! Assignment operator.
00413          //! Assignment is "cheap" as the actual data is refcounted
00414          PROFILE& operator= (
00415             const PROFILE& rhs
00416             );
00417 
00418          //! Comparison operator
00419          bool operator== (
00420             const PROFILE& rhs
00421             ) const;
00422 
00423          bool operator!= (
00424             const PROFILE& rhs
00425             ) const {
00426             return (!(*this == rhs));
00427             }
00428 
00429          //! Return a list of profiles for a given device class
00430          static ERRVALUE EnumerateProfiles (
00431             CLASS ProfileClass,
00432             MILIST<LISTENTRY>& List
00433             );
00434 
00435          //! Return a list of RGB primaries for custom RGB spaces.
00436          //! The order of entries in this list may change.  Do not depend on
00437          //! position within the list.  The COLORxyY values may change if
00438          //! more accurate values are found.  
00439          //! The names and numeric IDs will not change for a given entry and 
00440          //! may be safely written to a file to record which entry was selected.
00441          //! The numeric ID is also useful for populating ComboBoxes
00442          static ERRVALUE EnumeratePrimaries (
00443             MILIST<PRIMARIES>& List
00444             );
00445 
00446          //! Return the list of standard White points.
00447          //! The order of entries in this list may change.  Do not depend on
00448          //! position within the list.  The COLORxyY values may change if
00449          //! more accurate values are found.  
00450          //! The names and numeric IDs will not change for a given entry and 
00451          //! may be safely written to a file to record which entry was selected.
00452          //!
00453          //! For WhitePoints which are temperatures in degrees Kelvin, the
00454          //! numeric ID is actually the temperature. For the others, 
00455          //! (Illuminant A, etc), they're just arbitrary numbers.
00456          static ERRVALUE EnumerateWhitePoints (
00457             MILIST<WHITEPOINT>& List
00458             );
00459 
00460          //! Convert a tempature to a CIExyY color.
00461          //! Returns true if the whitepoint could be computed, or false if the
00462          //! tempeture is not valid.
00463          static bool WhitePointFromTemp (
00464             int tempK,              //!< Temperature in degrees Kelvin
00465             COLORxyY& WhitePoint //!< Color returned
00466             );
00467 
00468          //! Get the CIEXYZ values of R,G,and B
00469          bool GetColorants (
00470             COLORXYZ& red,
00471             COLORXYZ& green,
00472             COLORXYZ& blue
00473             ) const;
00474 
00475          //! Get the Iluminant
00476          bool GetIluminant (
00477             COLORXYZ& illuminant 
00478             ) const;
00479 
00480          //! Get the media Black Point
00481          bool GetMediaBlackPoint (
00482             COLORXYZ& blackpoint
00483             ) const;
00484 
00485          //! Get the media White Point
00486          bool GetMediaWhitePoint (
00487             COLORXYZ& whitepoint 
00488             ) const;
00489 
00490          //! Return the name of the profile
00491          void GetName (
00492             MISTRING&
00493             ) const;
00494 
00495          //! Return the description of the profile
00496          void GetDesc (
00497             MISTRING&
00498             ) const;
00499 
00500          //! Return the default rendering intent
00501          INTENT GetRenderingIntent (
00502             ) const;
00503 
00504          //! Get the PCS color space
00505          //! XXX (What is the PCS color space and how is it different from
00506          //! cmsGetColorSpace()?
00507          ICMCOLORSPACE GetPCS (
00508             ) const;
00509 
00510          ICMCOLORSPACE GetColorSpace (
00511             ) const;
00512          //! cmsGetColorSpace
00513 
00514          //! Return the device class (input, output, whatever)
00515          CLASS GetDeviceClass (
00516             ) const;
00517 
00518          //! returns true if the profile supports the given intent.
00519          bool SupportsIntent (
00520             INTENT intent,    
00521             USAGE use         
00522             ) const;
00523 
00524          void Free (
00525             );
00526 
00527          //! Return true if the profile contains the specified ICM tag
00528          bool HasTag (
00529             TAG sig
00530             ) const;
00531 
00532          bool IsEmpty (
00533             ) const {
00534             return (m_priv == 0);
00535             }
00536 
00537          //! Open an ICM profile file
00538          ERRVALUE Read (
00539             const FILEPATH& path
00540             );
00541          //! Actual implementation will call cmsOpenProfileFromFile(filaname, "r");
00542          ERRVALUE ReadFromMemory (
00543             const void* buf,  //!< XXX Actual cmsOpenProfileFromMem takes non-const but makes a copy
00544             int size
00545             );
00546 
00547          ERRVALUE Create (
00548             const PROFILEPARMS_RGB& parms
00549             );
00550 
00551          ERRVALUE Create (
00552             const PROFILEPARMS_PRINTER& parms
00553             );
00554 
00555          //! Create a profile which combines all the profiles in a transform
00556          //! into a single profile.  
00557          ERRVALUE CreateDeviceLinkProfile (
00558             TRANSFORM& transform,
00559             UINT32 flags   //!< XXX Define enum for whatever flags it wants
00560             );
00561          //! cmsTransfor2DeviceLink(transform, dwFlags)
00562          //!  flags: cmsFLAGS_HIGHRESPRECALC
00563          //!        cmsFLAGS_LOWRESPRECALD
00564 
00565          //! Create an ink-limiting device link profile.
00566          ERRVALUE CreateInkLimitingProfile (
00567             double limit,     //!< Ink limit (0 to 400%)
00568             COLORSPACE ColorSpace  //!< XXX default to CMYK
00569             );
00570 
00571          //! Create an sRGB or LAB profile, which can be hard-coded.
00572          ERRVALUE CreateBuiltInProfile (
00573             BUILTIN_PROFILE profile
00574             );
00575 
00576          //! Create an RGB profile from a whitepoint, 3 primaries
00577          //! and 3 gamma tables.  
00578          //! Some common primaries can be found using the function
00579          //! EnumeratePrimaries()
00580          ERRVALUE CreateRGBProfile (
00581             const COLORxyY& WhitePoint,
00582             const PRIMARIES& Primaries,
00583             const GAMMA& TransferFunctionRed,
00584             const GAMMA& TransferFunctionGreen,
00585             const GAMMA& TransferFunctionBlue
00586             );
00587 
00588          ERRVALUE CreateGrayProfile (
00589             const COLORxyY& WhitePoint,
00590             const GAMMA& TransferFunction 
00591             );
00592 
00593       private:
00594          #ifndef GENERATING_DOXYGEN_OUTPUT
00595          friend class TRANSFORM;
00596 
00597          class PRIVDATA;
00598 
00599          PRIVDATA* m_priv;
00600          cmsHPROFILE GetProfile() const;
00601 
00602          ERRVALUE CreateSimpleRGBProfile (
00603             int WhitePoint,
00604             double gamma,
00605             double rx,
00606             double ry,
00607             double gx,
00608             double gy,
00609             double bx,
00610             double by
00611             );
00612          #endif //!< GENERATING_DOXYGEN_OUTPUT
00613       };
00614 
00615    class PROFILEPARMS {
00616       public:
00617          enum MODE {
00618             MODE_None = 0,
00619             MODE_sRGB = 1,
00620             MODE_ICMFile = 2,
00621             MODE_UserDefined = 3
00622             };
00623 
00624          PROFILEPARMS();
00625          virtual ~PROFILEPARMS() {}
00626 
00627          //! Get the ITEMDEF array for serializing this class
00628          static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00629 
00630          ERRVALUE IniRead(const char*inikey = 0, INIHANDLE handle = 0);
00631          ERRVALUE IniWrite(const char*inikey = 0, INIHANDLE handle = 0) const;
00632          void XMLRead (const MGUI::XMLFORM_DATA&);
00633          void XMLWrite (MGUI::XMLFORM_DATA&) const;
00634 
00635          MODE m_mode;
00636          PROFILE::INTENT m_intent;
00637          PROFILE::BUILTIN_PROFILE m_BuiltInProfile;
00638          FILEPATH m_filepath;
00639          int m_WhitePoint;    //!< Degrees Kelvin
00640          double m_wx, m_wy;   //!< Actual whitepoint color (xyY with Y=1.0) (if m_WhitePoint == -1)
00641 
00642       private:
00643          virtual const char* v_GetDefaultINIKey() const = 0;
00644          //! Derived class only needs to read and write its own members.
00645          //! The base class already took care of reading and writing its
00646          //! members.  
00647          virtual ERRVALUE v_IniRead(const char*inikey, INIHANDLE handle = 0) = 0;
00648          virtual ERRVALUE v_IniWrite(const char*inikey, INIHANDLE handle = 0)  const = 0;
00649          virtual void v_XMLRead(const MGUI::XMLFORM_DATA&) = 0;
00650          virtual void v_XMLWrite(MGUI::XMLFORM_DATA&) const = 0;
00651 
00652          virtual void v_NotifyObservers() const {}
00653       };
00654 
00655    class PROFILEPARMS_RGB : public PROFILEPARMS {
00656       public:
00657          PROFILEPARMS_RGB ();
00658          ~PROFILEPARMS_RGB() {};
00659 
00660          //! Get the ITEMDEF array for serializing this class
00661          static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00662 
00663          double m_RedGamma, m_GreenGamma, m_BlueGamma;
00664          PROFILE::PRIMARIES m_primary;
00665 
00666       private:
00667          #ifndef GENERATING_DOXYGEN_OUTPUT
00668          virtual const char* v_GetDefaultINIKey() const { return "ICMScreen"; }
00669          virtual ERRVALUE v_IniRead(const char*inikey, INIHANDLE handle = 0);
00670          virtual ERRVALUE v_IniWrite(const char*inikey, INIHANDLE handle = 0) const;
00671          virtual void v_XMLRead(const MGUI::XMLFORM_DATA&);
00672          virtual void v_XMLWrite(MGUI::XMLFORM_DATA&) const;
00673          #endif // GENERATING_DOXYGEN_OUTPUT
00674       };
00675 
00676    //! Same as PROFILEPARMS_RGB, except when IniWrite is called on this one,
00677    //! it will call the callbacks of the things that want to know when it 
00678    //! changes.
00679    class PROFILEPARMS_SCREEN : public PROFILEPARMS_RGB {
00680       public:
00681          PROFILEPARMS_SCREEN ();
00682          ~PROFILEPARMS_SCREEN() {}
00683          static void AddChangeCallback (
00684             McbCallbackFunc func,
00685             void* cbdata
00686             );
00687          static void RemoveChangeCallback (
00688             McbCallbackFunc func,
00689             void* cbdata
00690             );
00691       private:
00692          #ifndef GENERATING_DOXYGEN_OUTPUT
00693          virtual void v_NotifyObservers() const ;
00694          #endif // GENERATING_DOXYGEN_OUTPUT
00695       };
00696          
00697    class PROFILEPARMS_PRINTER : public PROFILEPARMS {
00698       public:
00699          PROFILEPARMS_PRINTER ();
00700          ~PROFILEPARMS_PRINTER() {};
00701 
00702          //! Get the ITEMDEF array for serializing this class
00703          static const SERIALIZER::ITEMDEF* GetSerialItemDef();
00704 
00705          bool m_bProofToScreen;
00706          bool m_bOutOfGamutAlarm;
00707          COLOR m_AlarmColor;
00708          bool m_bUseProfileForProofingOnly;
00709          double m_InkLimit;
00710          double m_BlackInkLimit;
00711       private:
00712          #ifndef GENERATING_DOXYGEN_OUTPUT
00713          virtual const char* v_GetDefaultINIKey() const { return "PrinterICM"; }
00714          virtual ERRVALUE v_IniRead(const char*inikey, INIHANDLE handle = 0);
00715          virtual ERRVALUE v_IniWrite(const char*inikey, INIHANDLE handle = 0) const;
00716          virtual void v_XMLRead(const MGUI::XMLFORM_DATA&);
00717          virtual void v_XMLWrite(MGUI::XMLFORM_DATA&) const;
00718          #endif // GENERATING_DOXYGEN_OUTPUT
00719 
00720       };
00721 
00722    
00723    //! PROFILE::LISTENTRY used to retrieve a list of PROFILES available on the
00724    //! current system.  Use PROFILE::EnumerateProfiles() to get a list 
00725    class PROFILE::LISTENTRY {
00726       public:
00727          LISTENTRY () { }
00728 
00729          //! Copy constructor
00730          LISTENTRY (
00731             const LISTENTRY& rhs
00732             ) :
00733             m_filepath(rhs.m_filepath),
00734             m_desc(rhs.m_desc),
00735             m_bIsBuiltIn(rhs.m_bIsBuiltIn),
00736             m_BuiltInID(rhs.m_BuiltInID)
00737             {}
00738 
00739 
00740          ~LISTENTRY () {}
00741          
00742          //! Assignment operator.
00743          LISTENTRY& operator= (
00744             const LISTENTRY& rhs
00745             ) {
00746             if (&rhs != this) {
00747                m_filepath = rhs.m_filepath;
00748                m_desc = rhs.m_desc;
00749                m_bIsBuiltIn = rhs.m_bIsBuiltIn;
00750                m_BuiltInID = rhs.m_BuiltInID;
00751                }
00752             return (*this);
00753             }
00754 
00755          const MISTRING& GetDescription (
00756             ) const {
00757             return (m_desc);
00758             }
00759 
00760          const FILEPATH& GetFilePath (
00761             ) const {
00762             return (m_filepath);
00763             }
00764 
00765          bool IsBuiltIn (
00766             ) const {
00767             return (m_bIsBuiltIn);
00768             }
00769 
00770          BUILTIN_PROFILE GetBuiltInID (
00771             ) const {
00772             return (m_BuiltInID);
00773             }
00774 
00775       private:
00776          #ifndef GENERATING_DOXYGEN_OUTPUT
00777          FILEPATH m_filepath;
00778          MISTRING m_desc;
00779          bool m_bIsBuiltIn;
00780          BUILTIN_PROFILE m_BuiltInID;
00781 
00782          //! Private constructor
00783          LISTENTRY (
00784             const FILEPATH& fp, 
00785             const MISTRING& desc
00786             ) :
00787             m_desc(desc),
00788             m_filepath(fp),
00789             m_bIsBuiltIn(false),
00790             m_BuiltInID(PROFILE::PROFILE_NONE)
00791             {
00792             }
00793 
00794          LISTENTRY (
00795             PROFILE::BUILTIN_PROFILE id,
00796             const MISTRING& desc
00797             ) :
00798             m_desc(desc),
00799             m_bIsBuiltIn(true),
00800             m_BuiltInID(id)
00801             {
00802             }
00803 
00804          friend class PROFILE;   // PROFILE can use private constructor
00805          #endif // GENERATING_DOXYGEN_OUTPUT
00806       };
00807 
00808 
00809    //! In-memory representataion of an ICM profile
00810    class TRANSFORM {
00811       public:
00812 
00813          //! Default constructor
00814          //! Empty transform until Open or something else is called
00815          TRANSFORM (
00816             ) :
00817             m_priv(0)
00818             {
00819             }
00820 
00821          //! Shortcut construct simple transform
00822          TRANSFORM (
00823             const PROFILE& InputProfile,
00824             COLORSPACE InputColorSpace,
00825             const PROFILE& OutputProfile,
00826             COLORSPACE OutputColorSpace,  
00827             PROFILE::INTENT RenderingIntent = PROFILE::INTENT_Perceptual, 
00828             UINT32 flags = 0  // XXX Define an enum
00829             );
00830 
00831          //! cmsCreateProofingTransform (
00832          //!   input, inputformat,
00833          //!   output, outputformat
00834          //!   proofprofile,
00835          //!   intent,
00836          //!   proofingintent = INTENT_ABSOLUTE_COLORIMETRIC
00837          //!   dwFlags = cmsFLAGS_SOFTPROOFING
00838          //!      cmsFLAGS_GAMUTCHECK
00839          //!      cmsFLAGS_SOFTPROOFING
00840 
00841 
00842          //! cmsCreateMultiprofileTransform (
00843          //!   profile_array,
00844          //!   num_profiles,
00845          //!   inputformat, outputformat, intent, flags
00846          //!   )
00847 
00848          //! Copy constructor
00849          //! Copy is "cheap" as the actual data is refcounted
00850          TRANSFORM (
00851             const TRANSFORM& rhs
00852             );
00853 
00854          //! Destructor 
00855          //! (note: not virtual.  No derived classes)
00856          ~TRANSFORM (
00857             );
00858 
00859          //! Assignment operator.
00860          //! Assignment is "cheap" as the actual data is refcounted
00861          TRANSFORM& operator= (
00862             const TRANSFORM& rhs
00863             );
00864 
00865          //! Set the color to use if OutOfGamutAlarm is enabled.
00866          //! Due to the way it's implemented in the lcms library, this is a
00867          //! global setting, not per-transform.
00868          static void SetOutOfGamutAlarmColor (
00869             const COLOR& color
00870             );
00871 
00872          ERRVALUE Create (
00873             const PROFILE& InputProfile,
00874             COLORSPACE InputColorSpace,
00875             const PROFILE& OutputProfile,
00876             COLORSPACE OutputColorSpace,  
00877             PROFILE::INTENT RenderingIntent = PROFILE::INTENT_Perceptual, 
00878             UINT32 flags = 0  // XXX Define an enum
00879             );
00880 
00881          ERRVALUE Create (
00882             const PROFILE& InputProfile,
00883             COLORSPACE InputColorSpace,
00884             const PROFILEPARMS_PRINTER& ProofParms,
00885             const PROFILE& OutputProfile,
00886             COLORSPACE OutputColorSpace,  
00887             PROFILE::INTENT RenderingIntent = PROFILE::INTENT_Perceptual, 
00888             UINT32 flags = 0  // XXX Define an enum
00889             );
00890 
00891          COLORSPACE GetOutputColorSpace (
00892             ) const {
00893             return (m_DestColorSpace);
00894             }
00895 
00896          //! Returns a const reference to the input profile used to create
00897          //! this transform. 
00898          const PROFILE& GetInputProfile (
00899             ) const;
00900 
00901          //! Returns a const reference to the output profile used to create
00902          //! this transform
00903          const PROFILE& GetOutputProfile (
00904             ) const;
00905 
00906          //! Returns true if the transform does nothing.
00907          //! NOTE:  An empty transform will _really_ do nothing.  DoTransform
00908          //! won't even copy the source to the destination because it doesn't
00909          //! know how many bytes per pixel there are
00910          bool IsEmpty (
00911             ) const {
00912             return (m_priv == 0);
00913             }
00914 
00915          //! Transform an input buffer to an output buffer.
00916          //! The buffers are expected to match InputFormat and OutputFormat
00917          //! passed to CreateTransform() or CreateProofingTransform()
00918          //! It is safe for src to == dest as long as they're both the same
00919          //! number of bytes per pixel.
00920          void DoTransform (
00921             const void* src,
00922             void* dest,
00923             int size       //!< Size in pixels
00924             ) const;
00925 
00926          void DoTransform (
00927             const COLOR& src,
00928             COLOR& dest
00929             ) const;
00930 
00931          void Free();
00932 
00933       private:
00934          #ifndef GENERATING_DOXYGEN_OUTPUT
00935          class PRIVDATA;
00936 
00937          PRIVDATA* m_priv;
00938          COLORSPACE m_SrcColorSpace;
00939          COLORSPACE m_DestColorSpace;
00940 
00941          cmsHTRANSFORM GetTrans() const;
00942          #endif // GENERATING_DOXYGEN_OUTPUT
00943 
00944       }; //! End of TRANSFORM
00945    }     //! End of MGD namespace
00946 
00947 #endif // INC_MI32_MG2CMS_H

Generated on Tue Dec 14 13:18:26 2004 for TNTsdk by  doxygen 1.3.8-20040913