00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00072
00073
00074
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
00118 icUInt8Number ICCPROFLIB_API icFtoU8(icFloatNumber num);
00119 icFloatNumber ICCPROFLIB_API icU8toF(icUInt8Number num);
00120
00121
00122 icUInt16Number ICCPROFLIB_API icFtoU16(icFloatNumber num);
00123 icFloatNumber ICCPROFLIB_API icU16toF(icUInt16Number num);
00124
00125
00126 icUInt8Number ICCPROFLIB_API icABtoU8(icFloatNumber num);
00127 icFloatNumber ICCPROFLIB_API icU8toAB(icUInt8Number num);
00128
00129
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
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
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 }
00315 #endif
00316
00317 #endif