00344 {
00345
CMLutParam theLut={0};
00346
CMLutParam *theLutData;
00347
LHCombiData theCombi={0};
00348
LHCombiData *theCombiData;
00349
double *aDoublePtr;
00350
double aDouble;
00351
OSType theTag =
icSigAToB0Tag;
00352
00353
CMError err =
noErr;
00354
OSErr aOSerr =
noErr;
00355
Ptr profileLutPtr =
nil;
00356
UINT32 elementSize;
00357
double factor;
00358
UINT32 byteCount;
00359
CMCoreProfileHeader aHeader;
00360
00361
LH_START_PROC(
"MakeSessionFromLink")
00362
00363
00364 theLutData = &theLut;
00365 theCombiData = &theCombi;
00366 theCombiData->theProfile = profileSet->profileSet[0];
00367
00368
00369 err = CMGetProfileElement(theCombiData->theProfile, theTag, &elementSize, nil);
00370 if (err)
00371 goto CleanupAndExit;
00372
00373 byteCount = 52;
00374 profileLutPtr = SmartNewPtr(byteCount, &aOSerr);
00375 err = aOSerr;
00376 if (err)
00377 goto CleanupAndExit;
00378
00379 err = CMGetProfileElement( theCombiData->theProfile, theTag, &byteCount, profileLutPtr );
00380 if (err)
00381 goto CleanupAndExit;
00382 #ifdef IntelMode
00383 SwapLongOffset( &((
icLut16Type*)profileLutPtr)->base.sig, 0, 4 );
00384 SwapShortOffset( &((
icLut16Type*)profileLutPtr)->lut.inputEnt, 0, 2 );
00385 SwapShortOffset( &((
icLut16Type*)profileLutPtr)->lut.outputEnt, 0, 2 );
00386 #endif
00387
00388 theLutData->colorLutInDim = ((
icLut8Type*)profileLutPtr)->lut.inputChan;
00389 theLutData->colorLutOutDim = ((
icLut8Type*)profileLutPtr)->lut.outputChan;
00390 theLutData->colorLutGridPoints = ((
icLut8Type*)profileLutPtr)->lut.clutPoints;
00391
00392 switch( theLutData->colorLutInDim ){
00393
case 3:
00394
if( theLutData->
colorLutGridPoints != 16 && theLutData->
colorLutGridPoints != 32 ){
00395 err = 1;
00396
goto CleanupAndExit;
00397 }
00398
break;
00399
case 4:
00400
if( theLutData->
colorLutGridPoints != 8 && theLutData->
colorLutGridPoints != 16 ){
00401 err = 1;
00402
goto CleanupAndExit;
00403 }
00404
break;
00405 }
00406
00407 err =
CMGetProfileHeader( profileSet->
profileSet[0], &aHeader);
00408
if (err)
00409
goto CleanupAndExit;
00410 storage->firstColorSpace = aHeader.
colorSpace;
00411 storage->lastColorSpace = aHeader.
pcs;
00412 storage->srcProfileVersion =
icVersionNumber;
00413 storage->dstProfileVersion =
icVersionNumber;
00414
00415
if ( ( theLutData->
colorLutInDim == 3) &&
00416 ( aHeader.
pcs ==
icSigXYZData ) )
00417 {
00418 factor = 1.;
00419 err =
GetMatrixFromProfile(theLutData, theCombiData, theTag, factor);
00420
if( err )
goto CleanupAndExit;
00421 aDoublePtr = (
double *)theLutData->
matrixMFT;
00422
if( aDoublePtr != 0 ){
00423 aDouble = aDoublePtr[0] + aDoublePtr[4] + aDoublePtr[8];
00424
if( aDouble > 3.0 + 1E-6 || aDouble < 3.0 - 1E-6 ){
00425 err = 1;
00426
goto CleanupAndExit;
00427 }
00428 }
00429 }
00430 theCombiData->
maxProfileCount = 0;
00431
if( ((
icLut16Type*)profileLutPtr)->base.sig ==
icSigLut16Type ){
00432 theCombiData->
doCreate_16bit_Combi = 1;
00433 theCombiData->
doCreate_16bit_ELut = 0;
00434 theCombiData->
doCreate_16bit_XLut = 1;
00435 theCombiData->
doCreate_16bit_ALut = 0;
00436 }
00437
else{
00438 theCombiData->
doCreate_16bit_Combi = 0;
00439 theCombiData->
doCreate_16bit_ELut = 0;
00440 theCombiData->
doCreate_16bit_XLut = 0;
00441 theCombiData->
doCreate_16bit_ALut = 0;
00442 }
00443
00444
00445 err =
Extract_MFT_Alut( theLutData, theCombiData, profileLutPtr, theTag );
00446
if (err)
00447
goto CleanupAndExit;
00448
00449
00450 err =
Extract_MFT_Xlut ( theLutData, theCombiData, profileLutPtr, theTag );
00451
if (err)
00452
goto CleanupAndExit;
00453
00454
00455 err =
Extract_MFT_Elut( theLutData, theCombiData, profileLutPtr, theTag );
00456
if (err)
00457
goto CleanupAndExit;
00458
00459 storage->lutParam = *theLutData;
00460
00461
00462
00463
00464 CleanupAndExit:
00465 profileLutPtr =
DisposeIfPtr(profileLutPtr);
00466
LH_END_PROC(
"MakeSessionFromLink")
00467 return err;
00468 }