00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#ifndef LHGeneralIncs_h
00014
#include "General.h"
00015
#endif
00016
00017
PI_Boolean CMValInput( CMProfileRef prof,
00018
icHeader* aHeader );
00019
PI_Boolean CMValDisplay( CMProfileRef prof,
00020
icHeader* aHeader );
00021
PI_Boolean CMValOutput( CMProfileRef prof,
00022
icHeader* aHeader );
00023
PI_Boolean CMValLink( CMProfileRef prof );
00024
PI_Boolean CMValColorSpace( CMProfileRef prof,
00025
icHeader* aHeader );
00026
PI_Boolean CMValAbstract( CMProfileRef prof,
00027
icHeader* aHeader );
00028
PI_Boolean CMValNamed( CMProfileRef prof,
00029
icHeader* aHeader );
00030
00031
PI_Boolean CMValGray( CMProfileRef prof );
00032
PI_Boolean CMValRGB( CMProfileRef prof );
00033
PI_Boolean CMValAToB( CMProfileRef prof );
00034
PI_Boolean CMValBToA( CMProfileRef prof );
00035
PI_Boolean CMValMftOutput( CMProfileRef prof );
00036
00037
PI_Boolean CMValInput( CMProfileRef prof,
00038
icHeader* aHeader )
00039 {
00040
PI_Boolean valid;
00041
switch ( aHeader->
colorSpace)
00042 {
00043
00044
case icSigGrayData:
00045 valid =
CMValGray(prof);
00046
break;
00047
00048
case icSigRgbData:
00049
if (aHeader->
pcs ==
icSigLabData)
00050 {
00051 valid =
CMValAToB(prof);
00052 }
00053
else
00054 {
00055 valid =
CMValRGB(prof);
00056 }
00057
break;
00058
00059
case icSigCmyData:
00060
case icSigCmykData:
00061
case icSigMCH2Data:
00062
case icSigMCH3Data:
00063
case icSigMCH4Data:
00064
case icSigMCH5Data:
00065
case icSigMCH6Data:
00066
case icSigMCH7Data:
00067
case icSigMCH8Data:
00068
case icSigMCH9Data:
00069
case icSigMCHAData:
00070
case icSigMCHBData:
00071
case icSigMCHCData:
00072
case icSigMCHDData:
00073
case icSigMCHEData:
00074
case icSigMCHFData:
00075 valid =
CMValAToB(prof);
00076
break;
00077
00078
default:
00079 valid =
FALSE;
00080 }
00081
00082
if (aHeader->
pcs !=
icSigXYZData && aHeader->
pcs !=
icSigLabData){
00083 valid =
FALSE;
00084 }
00085
return (valid);
00086 }
00087
00088
PI_Boolean CMValDisplay( CMProfileRef prof,
00089
icHeader* aHeader )
00090 {
00091
PI_Boolean valid;
00092
switch (aHeader->
colorSpace)
00093 {
00094
00095
case icSigGrayData:
00096 valid =
CMValGray(prof);
00097
break;
00098
00099
case icSigRgbData:
00100
if (aHeader->
pcs ==
icSigLabData){
00101 valid =
CMValBToA(prof);
00102 }
00103
else{
00104 valid =
CMValRGB(prof);
00105 }
00106
break;
00107
case icSigMCH3Data:
00108
case icSigMCH4Data:
00109
case icSigCmyData:
00110
case icSigCmykData:
00111 valid =
CMValBToA(prof);
00112
break;
00113
00114
default:
00115 valid =
FALSE;
00116 }
00117
00118
if (aHeader->
pcs !=
icSigXYZData && aHeader->
pcs !=
icSigLabData){
00119 valid =
FALSE;
00120 }
00121
return (valid);
00122 }
00123
00124
PI_Boolean CMValOutput( CMProfileRef prof,
00125
icHeader* aHeader )
00126 {
00127
PI_Boolean valid;
00128
switch (aHeader->
colorSpace)
00129 {
00130
00131
case icSigGrayData:
00132 valid =
CMValGray(prof);
00133
break;
00134
00135
case icSigRgbData:
00136
case icSigCmyData:
00137
case icSigCmykData:
00138
case icSigMCH2Data:
00139
case icSigMCH3Data:
00140
case icSigMCH4Data:
00141
case icSigMCH5Data:
00142
case icSigMCH6Data:
00143
case icSigMCH7Data:
00144
case icSigMCH8Data:
00145
case icSigMCH9Data:
00146
case icSigMCHAData:
00147
case icSigMCHBData:
00148
case icSigMCHCData:
00149
case icSigMCHDData:
00150
case icSigMCHEData:
00151
case icSigMCHFData:
00152 valid =
CMValMftOutput(prof);
00153
break;
00154
00155
default:
00156 valid =
FALSE;
00157 }
00158
00159
if (aHeader->
pcs !=
icSigXYZData && aHeader->
pcs !=
icSigLabData){
00160 valid =
FALSE;
00161 }
00162
return (valid);
00163 }
00164
00165
PI_Boolean CMValLink( CMProfileRef prof )
00166 {
00167
PI_Boolean valid;
00168 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00169
00170
if (valid)
00171 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB0Tag);
00172
00173
if (valid)
00174 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileSequenceDescTag);
00175
00176
if (valid)
00177 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00178
00179
return (valid);
00180 }
00181
00182
PI_Boolean CMValColorSpace( CMProfileRef prof,
00183
icHeader* aHeader )
00184 {
00185
PI_Boolean valid;
00186
if (aHeader->
pcs !=
icSigXYZData && aHeader->
pcs !=
icSigLabData){
00187 valid =
FALSE;
00188
return (valid);
00189 }
00190
00191 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00192
00193
if (valid)
00194 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB0Tag);
00195
00196
if (valid)
00197 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBToA0Tag);
00198
00199
if (valid)
00200 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00201
00202
if (valid)
00203 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00204
00205
return (valid);
00206 }
00207
00208
00209
PI_Boolean CMValAbstract( CMProfileRef prof,
00210
icHeader* aHeader )
00211 {
00212
PI_Boolean valid;
00213
switch (aHeader->
pcs)
00214 {
00215
00216
case icSigXYZData:
00217
case icSigLabData:
00218 valid =
CMValAToB(prof);
00219
break;
00220
00221
default:
00222 valid =
FALSE;
00223 }
00224
00225
return (valid);
00226 }
00227
00228
PI_Boolean CMValNamed( CMProfileRef prof,
00229
icHeader* aHeader )
00230 {
00231
PI_Boolean valid;
00232
if (aHeader->
pcs !=
icSigXYZData && aHeader->
pcs !=
icSigLabData){
00233 valid =
FALSE;
00234
return (valid);
00235 }
00236
00237 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00238
00239
if (valid)
00240 valid =
CMProfileElementExists((CMProfileRef)prof, icSigNamedColor2Tag);
00241
00242
if (valid)
00243 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00244
00245
if (valid)
00246 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00247
00248
return (valid);
00249 }
00250
00251
PI_Boolean CMValGray( CMProfileRef prof )
00252 {
00253
PI_Boolean valid;
00254 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00255
00256
if (valid)
00257 valid =
CMProfileElementExists((CMProfileRef)prof, icSigGrayTRCTag);
00258
00259
if (valid)
00260 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00261
00262
if (valid)
00263 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00264
00265
return (valid);
00266 }
00267
00268
PI_Boolean CMValAToB( CMProfileRef prof )
00269 {
00270
PI_Boolean valid;
00271 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00272
00273
if (valid)
00274 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB0Tag);
00275
00276
if (valid)
00277 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00278
00279
if (valid)
00280 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00281
00282
return (valid);
00283 }
00284
00285
PI_Boolean CMValBToA( CMProfileRef prof )
00286 {
00287
PI_Boolean valid;
00288 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00289
00290
if (valid)
00291 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBToA0Tag);
00292
00293
if (valid)
00294 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00295
00296
if (valid)
00297 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00298
00299
return (valid);
00300 }
00301
00302 CMError CMValidateProfile( CMProfileRef prof,
00303 PI_Boolean *valid )
00304 {
00305
CMError err =
noErr;
00306
icHeader aHeader;
00307
00308 *valid =
FALSE;
00309 err =
CMGetProfileHeader((
CMProfileRef)prof, &aHeader);
00310
00311
if (!err)
00312 {
00313
if ((aHeader.
version & 0xff000000) >=
icVersionNumber ){
00314
switch (aHeader.
deviceClass)
00315 {
00316
case icSigInputClass:
00317 *valid =
CMValInput(prof, &aHeader );
00318
break;
00319
00320
case icSigDisplayClass:
00321 *valid =
CMValDisplay(prof, &aHeader );
00322
break;
00323
00324
case icSigOutputClass:
00325 *valid =
CMValOutput(prof, &aHeader );
00326
break;
00327
00328
case icSigLinkClass:
00329 *valid =
CMValLink(prof);
00330
break;
00331
00332
case icSigColorSpaceClass:
00333 *valid =
CMValColorSpace(prof, &aHeader );
00334
break;
00335
00336
case icSigAbstractClass:
00337 *valid =
CMValAbstract(prof, &aHeader );
00338
break;
00339
00340
case icSigNamedColorClass:
00341 *valid =
CMValNamed(prof, &aHeader );
00342
break;
00343
00344
default:
00345 *valid =
FALSE;
00346 }
00347
00348 }
00349
else
00350 {
00351 *valid =
FALSE;
00352
return (
cmProfileError);
00353 }
00354 }
00355
00356
return (err);
00357 }
00358
00359
PI_Boolean CMValMftOutput ( CMProfileRef prof )
00360 {
00361
PI_Boolean valid;
00362 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00363
00364
if (valid)
00365 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB0Tag);
00366
00367
if (valid)
00368 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB1Tag);
00369
00370
if (valid)
00371 valid =
CMProfileElementExists((CMProfileRef)prof, icSigAToB2Tag);
00372
00373
if (valid)
00374 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBToA0Tag);
00375
00376
if (valid)
00377 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBToA1Tag);
00378
00379
if (valid)
00380 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBToA2Tag);
00381
00382
if (valid)
00383 valid =
CMProfileElementExists((CMProfileRef)prof, icSigGamutTag);
00384
00385
if (valid)
00386 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00387
00388
if (valid)
00389 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00390
00391
return (valid);
00392 }
00393
00394
PI_Boolean CMValRGB( CMProfileRef prof )
00395 {
00396
PI_Boolean valid;
00397 valid =
CMProfileElementExists((CMProfileRef)prof, icSigProfileDescriptionTag);
00398
00399
if (valid)
00400 valid =
CMProfileElementExists((CMProfileRef)prof, icSigRedColorantTag);
00401
00402
if (valid)
00403 valid =
CMProfileElementExists((CMProfileRef)prof, icSigGreenColorantTag);
00404
00405
if (valid)
00406 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBlueColorantTag);
00407
00408
if (valid)
00409 valid =
CMProfileElementExists((CMProfileRef)prof, icSigRedTRCTag);
00410
00411
if (valid)
00412 valid =
CMProfileElementExists((CMProfileRef)prof, icSigGreenTRCTag);
00413
00414
if (valid)
00415 valid =
CMProfileElementExists((CMProfileRef)prof, icSigBlueTRCTag);
00416
00417
if (valid)
00418 valid =
CMProfileElementExists((CMProfileRef)prof, icSigMediaWhitePointTag);
00419
00420
if (valid)
00421 valid =
CMProfileElementExists((CMProfileRef)prof, icSigCopyrightTag);
00422
00423
return (valid);
00424 }
00425