SampleICC Main srcforge
Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

IccUtil.h

Go to the documentation of this file.
00001 
00011 /*
00012  * The ICC Software License, Version 0.1
00013  *
00014  *
00015  * Copyright (c) 2003-2006 The International Color Consortium. All rights 
00016  * reserved.
00017  *
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions
00020  * are met:
00021  *
00022  * 1. Redistributions of source code must retain the above copyright
00023  *    notice, this list of conditions and the following disclaimer. 
00024  *
00025  * 2. Redistributions in binary form must reproduce the above copyright
00026  *    notice, this list of conditions and the following disclaimer in
00027  *    the documentation and/or other materials provided with the
00028  *    distribution.
00029  *
00030  * 3. The end-user documentation included with the redistribution,
00031  *    if any, must include the following acknowledgment:  
00032  *       "This product includes software developed by the
00033  *        The International Color Consortium (www.color.org)"
00034  *    Alternately, this acknowledgment may appear in the software itself,
00035  *    if and wherever such third-party acknowledgments normally appear.
00036  *
00037  * 4. In the absence of prior written permission, the names "ICC" and "The
00038  *    International Color Consortium" must not be used to imply that the
00039  *    ICC organization endorses or promotes products derived from this
00040  *    software.
00041  *
00042  *
00043  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00044  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00045  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00046  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
00047  * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00048  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00049  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00050  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00051  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00052  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00053  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00054  * SUCH DAMAGE.
00055  * ====================================================================
00056  *
00057  * This software consists of voluntary contributions made by many
00058  * individuals on behalf of the The International Color Consortium. 
00059  *
00060  *
00061  * Membership in the ICC is encouraged when this software is used for
00062  * commercial purposes. 
00063  *
00064  *  
00065  * For more information on The International Color Consortium, please
00066  * see <http://www.color.org/>.
00067  *  
00068  * 
00069  */
00070 
00072 // HISTORY:
00073 //
00074 // -Initial implementation by Max Derhak 5-15-2003
00075 //
00077 
00078 #ifndef _ICCUTIL_H
00079 #define _ICCUTIL_H
00080 
00081 #include "IccDefs.h"
00082 #include "IccProfLibConf.h"
00083 #include <string>
00084 
00085 #ifdef USESAMPLEICCNAMESPACE
00086 namespace sampleICC {
00087 #endif
00088 
00089 icValidateStatus ICCPROFLIB_API icMaxStatus(icValidateStatus s1, icValidateStatus s2);
00090 bool ICCPROFLIB_API icIsSpaceCLR(icColorSpaceSignature sig);
00091 
00092 void ICCPROFLIB_API icColorIndexName(icChar *szName, icColorSpaceSignature csSig,
00093                       int nIndex, int nColors, const icChar *szUnknown);
00094 void ICCPROFLIB_API icColorValue(icChar *szValue, icFloatNumber nValue,
00095                   icColorSpaceSignature csSig, int nIndex);
00096 
00097 bool ICCPROFLIB_API icMatrixInvert3x3(icFloatNumber *matrix);
00098 void ICCPROFLIB_API icMatrixMultiply3x3(icFloatNumber *result,
00099                                         const icFloatNumber *l,
00100                                         const icFloatNumber *r);
00101 void ICCPROFLIB_API icVectorApplyMatrix3x3(icFloatNumber *result,
00102                                            const icFloatNumber *m,
00103                                            const icFloatNumber *v);
00104 
00105 icS15Fixed16Number ICCPROFLIB_API icDtoF(icFloatNumber num);
00106 icFloatNumber ICCPROFLIB_API icFtoD(icS15Fixed16Number num);
00107 
00108 icU16Fixed16Number ICCPROFLIB_API icDtoUF(icFloatNumber num);
00109 icFloatNumber ICCPROFLIB_API icUFtoD(icU16Fixed16Number num);
00110 
00111 icU1Fixed15Number ICCPROFLIB_API icDtoUSF(icFloatNumber num);
00112 icFloatNumber ICCPROFLIB_API icUSFtoD(icU1Fixed15Number num);
00113 
00114 icU8Fixed8Number ICCPROFLIB_API icDtoUCF(icFloatNumber num);
00115 icFloatNumber ICCPROFLIB_API icUCFtoD(icU8Fixed8Number num);
00116 
00117 /*0 to 255 <-> 0.0 to 1.0*/
00118 icUInt8Number ICCPROFLIB_API icFtoU8(icFloatNumber num);
00119 icFloatNumber ICCPROFLIB_API icU8toF(icUInt8Number num);
00120 
00121 /*0 to 65535 <-> 0.0 to 1.0*/
00122 icUInt16Number ICCPROFLIB_API icFtoU16(icFloatNumber num);
00123 icFloatNumber ICCPROFLIB_API icU16toF(icUInt16Number num);
00124 
00125 /*0 to 255 <-> -128.0 to 127.0*/
00126 icUInt8Number ICCPROFLIB_API icABtoU8(icFloatNumber num);
00127 icFloatNumber ICCPROFLIB_API icU8toAB(icUInt8Number num);
00128 
00129 /*0 to 65535 <-> -128.0 to 127.0*/
00130 icUInt16Number ICCPROFLIB_API icABtoU16(icFloatNumber num);
00131 icFloatNumber ICCPROFLIB_API icU16toAB(icUInt16Number num);
00132 
00133 extern ICCPROFLIB_API icFloatNumber icD50XYZ[3];
00134 extern ICCPROFLIB_API icFloatNumber icD50XYZxx[3];
00135 
00136 void ICCPROFLIB_API icNormXYZ(icFloatNumber *XYZ, icFloatNumber *WhiteXYZ=NULL);
00137 void ICCPROFLIB_API icDeNormXYZ(icFloatNumber *XYZ, icFloatNumber *WhiteXYZ=NULL);
00138 
00139 void ICCPROFLIB_API icXYZtoLab(icFloatNumber *Lab, icFloatNumber *XYZ=NULL, icFloatNumber *WhiteXYZ=NULL);
00140 void ICCPROFLIB_API icLabtoXYZ(icFloatNumber *XYZ, icFloatNumber *Lab=NULL, icFloatNumber *WhiteXYZ=NULL);
00141 
00142 void ICCPROFLIB_API icLab2Lch(icFloatNumber *Lch, icFloatNumber *Lab=NULL);
00143 void ICCPROFLIB_API icLch2Lab(icFloatNumber *Lab, icFloatNumber *Lch=NULL);
00144 
00145 icFloatNumber ICCPROFLIB_API icMin(icFloatNumber v1, icFloatNumber v2);
00146 icFloatNumber ICCPROFLIB_API icMax(icFloatNumber v1, icFloatNumber v2);
00147 
00148 icUInt32Number ICCPROFLIB_API icIntMin(icUInt32Number v1, icUInt32Number v2);
00149 icUInt32Number ICCPROFLIB_API icIntMax(icUInt32Number v1, icUInt32Number v2);
00150 
00152 
00153 void ICCPROFLIB_API icLabFromPcs(icFloatNumber *Lab);
00154 void ICCPROFLIB_API icLabToPcs(icFloatNumber *Lab);
00155 
00158 
00159 void ICCPROFLIB_API icXyzFromPcs(icFloatNumber *XYZ);
00160 void ICCPROFLIB_API icXyzToPcs(icFloatNumber *XYZ);
00161 
00162 
00163 void ICCPROFLIB_API icMemDump(std::string &sDump, void *pBuf, icUInt32Number nNum);
00164 void ICCPROFLIB_API icMatrixDump(std::string &sDump, icS15Fixed16Number *pMatrix);
00165 ICCPROFLIB_API const icChar* icGetSig(icChar *pBuf, icUInt32Number sig, bool bGetHexVal=true);
00166 ICCPROFLIB_API const icChar* icGetSigStr(icChar *pBuf, icUInt32Number nSig);
00167 
00168 icUInt32Number ICCPROFLIB_API icGetSigVal(const icChar *pBuf);
00169 icUInt32Number ICCPROFLIB_API icGetSpaceSamples(icColorSpaceSignature sig);
00170 
00171 ICCPROFLIB_API extern const char *icValidateWarningMsg;
00172 ICCPROFLIB_API extern const char *icValidateNonCompliantMsg;
00173 ICCPROFLIB_API extern const char *icValidateCriticalErrorMsg;
00174 
00175 #ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
00176 inline void icSwab16Ptr(void *pVoid)
00177 {
00178   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00179   icUInt8Number tmp;
00180 
00181   tmp = ptr[0]; ptr[0] = ptr[1]; ptr[1] = tmp;
00182 }
00183 
00184 inline void icSwab16Array(void *pVoid, int num)
00185 {
00186   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00187   icUInt8Number tmp;
00188 
00189   while (num>0) {
00190     tmp = ptr[0]; ptr[0] = ptr[1]; ptr[1] = tmp;
00191     ptr += 2;
00192     num--;
00193   }
00194 }
00195 
00196 inline void icSwab32Ptr(void *pVoid)
00197 {
00198   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00199   icUInt8Number tmp;
00200 
00201   tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
00202   tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
00203 }
00204 
00205 inline void icSwab32Array(void *pVoid, int num)
00206 {
00207   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00208   icUInt8Number tmp;
00209 
00210   while (num>0) {
00211     tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
00212     tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
00213     ptr += 4;
00214     num--;
00215   }
00216 
00217 }
00218 
00219 inline void icSwab64Ptr(void *pVoid)
00220 {
00221   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00222   icUInt8Number tmp;
00223 
00224   tmp = ptr[0]; ptr[0] = ptr[7]; ptr[7] = tmp;
00225   tmp = ptr[1]; ptr[1] = ptr[6]; ptr[6] = tmp;
00226   tmp = ptr[2]; ptr[2] = ptr[5]; ptr[5] = tmp;
00227   tmp = ptr[3]; ptr[3] = ptr[4]; ptr[4] = tmp;
00228 }
00229 
00230 inline void icSwab64Array(void *pVoid, int num)
00231 {
00232   icUInt8Number *ptr = (icUInt8Number*)pVoid;
00233   icUInt8Number tmp;
00234 
00235   while (num>0) {
00236     tmp = ptr[0]; ptr[0] = ptr[7]; ptr[7] = tmp;
00237     tmp = ptr[1]; ptr[1] = ptr[6]; ptr[6] = tmp;
00238     tmp = ptr[2]; ptr[2] = ptr[5]; ptr[5] = tmp;
00239     tmp = ptr[3]; ptr[3] = ptr[4]; ptr[4] = tmp;
00240     ptr += 8;
00241     num--;
00242   }
00243 
00244 }
00245 #else 
00246 #define icSwab16Ptr(x)
00247 #define icSwab16Array(x, n)
00248 #define icSwab32Ptr(x)
00249 #define icSwab32Array(x, n)
00250 #define icSwab64Ptr(x)
00251 #define icSwab64Array(x, n)
00252 #endif
00253 
00254 #define icSwab16(x) icSwab16Ptr(&x)
00255 #define icSwab32(x) icSwab32Ptr(&x)
00256 #define icSwab64(x) icSwab64Ptr(&x)
00257 
00258 
00269 class ICCPROFLIB_API  CIccInfo {
00270 public:
00271   //Signature values
00272   const icChar *GetVersionName(icUInt32Number val);
00273   const icChar *GetDeviceAttrName(icUInt64Number val);
00274   const icChar *GetProfileFlagsName(icUInt32Number val);
00275 
00276   const icChar *GetTagSigName(icTagSignature sig);
00277   const icChar *GetTechnologySigName(icTechnologySignature sig);
00278   const icChar *GetTagTypeSigName(icTagTypeSignature sig);
00279   const icChar *GetColorSpaceSigName(icColorSpaceSignature sig);
00280   const icChar *GetProfileClassSigName(icProfileClassSignature sig);
00281   const icChar *GetPlatformSigName(icPlatformSignature sig);
00282   const icChar *GetReferenceMediumGamutSigNameName(icReferenceMediumGamutSignature sig);
00283   const icChar *GetColorimetricIntentImageStateName(icColorimetricIntentImageStateSignature sig);
00284 
00285   const icChar *GetSigName(icUInt32Number val);
00286 
00287   //Other values
00288   const icChar *GetMeasurementFlareName(icMeasurementFlare val);
00289   const icChar *GetMeasurementGeometryName(icMeasurementGeometry val);
00290   const icChar *GetRenderingIntentName(icRenderingIntent val);
00291   const icChar *GetSpotShapeName(icSpotShape val);
00292   const icChar *GetStandardObserverName(icStandardObserver val);
00293   const icChar *GetIlluminantName(icIlluminant val);
00294 
00295   const icChar *GetUnknownName(icUInt32Number val);
00296   const icChar *GetMeasurementUnit(icSignature sig);
00297   const icChar *GetProfileID(icProfileID *profileID);
00298   const icChar *GetColorantEncoding(icColorantEncoding colorant);
00299   
00300   bool IsProfileIDCalculated(icProfileID *profileID);
00301   icValidateStatus CheckData(std::string &sReport, const icDateTimeNumber &dateTime);
00302   icValidateStatus CheckData(std::string &sReport, const icXYZNumber &XYZ);
00303 
00304   bool IsValidSpace(icColorSpaceSignature sig);
00305 
00306 protected:
00307   icChar m_szStr[128];
00308   icChar m_szSigStr[128];
00309 };
00310 
00311 extern ICCPROFLIB_API CIccInfo icInfo;
00312 
00313 #ifdef USESAMPLEICCNAMESPACE
00314 } //namespace sampleICC
00315 #endif
00316 
00317 #endif

Generated on Tue Jun 26 17:51:43 2007 for IccProfLib by  doxygen 1.3.9.1