00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#ifndef LHGeneralIncs_h
00014
#include "General.h"
00015
#endif
00016
00017
#ifndef PI_ColorWorld_h
00018
#include "PI_Color.h"
00019
#endif
00020
00021
#ifndef realThing
00022
#ifdef DEBUG_OUTPUT
00023
#define kThisFile kLHCMDo3DID
00024
#define __TYPES__
00025
00026
00027
#endif
00028
#endif
00029
00030
#ifndef PI_CMMInitialization_h
00031
#include "PI_CMM.h"
00032
#endif
00033
00034
#ifndef MemLink_h
00035
#include "MemLink.h"
00036
#endif
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 CMError LHColorWorldOpen (Ptr* storage)
00056 {
00057
Ptr myStorage;
00058
OSErr err;
00059
00060 myStorage = (
Ptr)
SmartNewPtrClear(
sizeof(
CMMModelData ) , &err);
00061
if (err)
00062
goto CleanupAndExit;
00063
else
00064 {
00065 *storage = myStorage;
00066 }
00067
00068 CleanupAndExit:
00069
return err;
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 CMError LHColorWorldClose( Ptr storage )
00089 {
00090
CMMModelPtr modelData = (
CMMModelPtr)storage;
00091
00092
if (storage)
00093 {
00094
DISPOSE_IF_DATA((modelData)->lutParam.inputLut);
00095
DISPOSE_IF_DATA((modelData)->lutParam.outputLut);
00096
DISPOSE_IF_DATA((modelData)->lutParam.colorLut);
00097
00098
DISPOSE_IF_DATA((modelData)->gamutLutParam.inputLut);
00099
DISPOSE_IF_DATA((modelData)->gamutLutParam.outputLut);
00100
DISPOSE_IF_DATA((modelData)->gamutLutParam.colorLut);
00101
00102
DISPOSE_IF_DATA((modelData)->theNamedColorTagData);
00103
#if __IS_MAC
00104
DisposeIfHandle((modelData)->Monet);
00105
#endif
00106
00107
DisposeIfPtr(storage);
00108 }
00109
return(
noErr );
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
CMError
00141 CWNewColorWorld ( CMWorldRef* storage,
00142 CMProfileRef srcProfile,
00143 CMProfileRef dstProfile)
00144 {
00145
Ptr myStorage;
00146
CMError err;
00147
00148
#ifdef DEBUG_OUTPUT
00149
00150
#endif
00151
err =
LHColorWorldOpen(&myStorage);
00152
#ifdef DEBUG_OUTPUT
00153
00154
#endif
00155
if ( !err )
00156 {
00157 ((
CMMModelPtr)myStorage)->aIntentArr = 0;
00158 ((
CMMModelPtr)myStorage)->dwFlags = 0xffffffff;
00159 err =
CMMInitPrivate((
CMMModelPtr)myStorage,
00160 srcProfile,
00161 dstProfile);
00162
#ifdef DEBUG_OUTPUT
00163
00164
#endif
00165
}
00166
00167
00168
if ( !err )
00169 {
00170 *storage = (
CMWorldRef)myStorage;
00171 }
00172
else{
00173 *storage = (
CMWorldRef)0;
00174
LHColorWorldClose( myStorage );
00175 }
00176
00177
return err;
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
CMError
00209 CWConcatColorWorld ( CMWorldRef* storage,
00210
CMConcatProfileSet* profileSet)
00211 {
00212
Ptr myStorage;
00213
CMError err;
00214
00215 err =
LHColorWorldOpen(&myStorage);
00216
00217
if ( !err )
00218 {
00219 ((
CMMModelPtr)myStorage)->aIntentArr = 0;
00220 ((
CMMModelPtr)myStorage)->dwFlags = 0xffffffff;
00221 err =
CMMConcatInitPrivate ((
CMMModelPtr)myStorage, profileSet );
00222 }
00223
00224
00225
if ( !err )
00226 {
00227 *storage = (
CMWorldRef)myStorage;
00228 }
00229
else{
00230 *storage = (
CMWorldRef)0;
00231
LHColorWorldClose( myStorage );
00232 }
00233
00234
return err;
00235 }
00236
00237
#if WRITE_PROFILE
00238
void WriteProf( Ptr name,
icProfile *theProf,
long currentSize );
00239
#endif
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 CMError CWConcatColorWorld4MS ( CMWorldRef *storage,
00284
CMConcatProfileSet *profileSet,
00285 UINT32 *aIntentArr,
00286 UINT32 nIntents,
00287 UINT32 dwFlags
00288 )
00289 {
00290
Ptr myStorage;
00291
CMError err;
00292
#if WRITE_PROFILE
00293
icProfile *theLinkProfile;
00294
long l;
00295
#endif
00296
00297 err =
LHColorWorldOpen(&myStorage);
00298
00299
if ( !err )
00300 {
00301 ((
CMMModelPtr)myStorage)->aIntentArr = aIntentArr;
00302 ((
CMMModelPtr)myStorage)->nIntents = nIntents;
00303 ((
CMMModelPtr)myStorage)->dwFlags =
dwFlags;
00304 err =
CMMConcatInitPrivate ((
CMMModelPtr)myStorage, profileSet );
00305 }
00306
00307
00308
if ( !err )
00309 {
00310 *storage = (
CMWorldRef)myStorage;
00311 }
00312
else{
00313 *storage = (
CMWorldRef)0;
00314
LHColorWorldClose( myStorage );
00315 }
00316
00317
#if WRITE_PROFILE
00318
err =
DeviceLinkFill( (
CMMModelPtr)myStorage, profileSet, &theLinkProfile, 0 );
00319
if( !err ){
00320 l = *(
unsigned long *)theLinkProfile;
00321 SwapLong(&l);
00322
WriteProf(
"test", theLinkProfile, l );
00323 }
00324
#endif
00325
return err;
00326 }
00327
00328
CMError
00329 CWLinkColorWorld ( CMWorldRef* storage,
00330
CMConcatProfileSet* profileSet)
00331 {
00332
Ptr myStorage;
00333
CMError err;
00334
00335 err =
LHColorWorldOpen(&myStorage);
00336
00337
if ( !err )
00338 {
00339 ((
CMMModelPtr)myStorage)->currentCall =
kCMMNewLinkProfile;
00340 ((
CMMModelPtr)myStorage)->aIntentArr = 0;
00341 ((
CMMModelPtr)myStorage)->dwFlags = 0xffffffff;
00342 err =
CMMConcatInitPrivate ((
CMMModelPtr)myStorage, profileSet );
00343 }
00344
00345
00346
if ( !err )
00347 {
00348 *storage = (
CMWorldRef)myStorage;
00349 }
00350
else{
00351 *storage = (
CMWorldRef)0;
00352
LHColorWorldClose( myStorage );
00353 }
00354
00355
return err;
00356 }
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
void
00375 CWDisposeColorWorld ( CMWorldRef storage )
00376 {
00377
LHColorWorldClose ( (
Ptr)storage );
00378 }
00379
00380 void CMSetLookupOnlyMode( CMWorldRef Storage,
00381 PI_Boolean Mode )
00382 {
00383
CMMModelPtr aPtr;
00384
00385
if( Storage == 0 )
return;
00386
LOCK_DATA( Storage );
00387 aPtr = (
CMMModelPtr)(
DATA_2_PTR( Storage ));
00388 aPtr->lookup = Mode;
00389
UNLOCK_DATA( Storage );
00390
return;
00391 }
00392
00393 void CMFullColorRemains( CMWorldRef Storage,
00394
long ColorMask )
00395 {
00396
CMMModelPtr aPtr;
00397
CMLutParamPtr lutParamPtr;
00398
long Address,
Size,i,j;
00399
00400
if( Storage == 0 )
return;
00401
LOCK_DATA( Storage );
00402 aPtr = (
CMMModelPtr)(
DATA_2_PTR( Storage ));
00403 lutParamPtr = &aPtr->lutParam;
00404
00405
Size = lutParamPtr->
colorLutWordSize / 8;
00406
if( !(lutParamPtr->
colorLutInDim == 4 && lutParamPtr->
colorLutOutDim == 4 ))
return;
00407
00408
for( i=0; i<4; i++ ){
00409
if( (ColorMask & (1<<i)) == 0 )
continue;
00410 Address = lutParamPtr->
colorLutGridPoints - 1;
00411
for( j=3-i+1; j<4; j++ )Address *= lutParamPtr->
colorLutGridPoints;
00412 Address = Address * lutParamPtr->
colorLutOutDim;
00413
for( j=0; j<4; j++){
00414
if( i == j ){
00415
if(
Size == 1 ){
00416 *( ((
unsigned char*)lutParamPtr->
colorLut)+Address+3-j ) = (
unsigned char)255;
00417 }
00418
else{
00419 *( ((
unsigned short*)lutParamPtr->
colorLut)+Address+3-j ) = (
unsigned short)65535;
00420 }
00421 }
00422
else{
00423
if(
Size == 1 ){
00424 *( ((
unsigned char*)lutParamPtr->
colorLut)+Address+3-j ) = (
unsigned char)0;
00425 }
00426
else{
00427 *( ((
unsigned short*)lutParamPtr->
colorLut)+Address+3-j ) = (
unsigned short)0;
00428 }
00429 }
00430 }
00431 }
00432
UNLOCK_DATA( Storage );
00433
return;
00434 }
00435
00436 CMError CWCreateLink4MS ( CMWorldRef storage,
00437
CMConcatProfileSet *profileSet,
00438 UINT32 aIntent,
00439
icProfile **theLinkProfile )
00440 {
00441
CMError err;
00442
00443 *theLinkProfile = 0;
00444
00445 err =
DeviceLinkFill( (
CMMModelPtr)storage, profileSet, theLinkProfile, aIntent );
00446
00447
return err;
00448 }