00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#ifndef LHGeneralIncs_h
00015
#include "General.h"
00016
#endif
00017
00018
#if __IS_MSDOS
00019
#include <wtypes.h>
00020
#include <winbase.h>
00021
#include <windowsX.h>
00022
#ifdef RenderInt
00023
#include "Windef.h"
00024
#endif
00025
#endif
00026
00027
#ifndef MemLink_h
00028
#include "MemLink.h"
00029
#endif
00030
00031
#if !__IS_MSDOS && !__IS_MAC
00032
#include <time.h>
00033
#endif
00034
00035
#ifdef DEBUG_OUTPUT
00036
#define kThisFile kLHCMRuntimeID
00037
#endif
00038
00039
00040
#ifndef IntelMode
00041 #define CMHelperICC2int16Const(a, b) \
00042
(*((UINT16 *)(a))) = (UINT16)(b);
00043 #define CMHelperICC2int32Const(a, b) \
00044
(*((UINT32 *)(a))) = (UINT32)(b);
00045
#else
00046
#define CMHelperICC2int16Const(a, b) \
00047
(*((UINT16 *)(a))) = (((UINT16)(b)>>8) | ((UINT16)((UINT8 )(b)) << 8));
00048
#define CMHelperICC2int32Const(a, b) \
00049
(*((UINT32 *)(a))) = (((UINT32)(b)>>24) | ((UINT32)(0x0ff0000&(UINT32)(b)) >> 8) | \
00050
((UINT32)(0x0ff00&(UINT32)(b)) << 8) | ((UINT32)(0x0ff&(UINT32)(b)) << 24));
00051
#endif
00052
00053 CMError MyAdd_NL_Header( UINT32 theSize,
icHeader *linkHeader,
00054 UINT32 aIntent, UINT32 aClass, UINT32 aColorSpace, UINT32 aConnectionSpace )
00055 {
00056
OSErr err =
noErr;
00057
#if ! __IS_MSDOS
00058
unsigned long secs;
00059
#endif
00060
DateTimeRec datetimeRec;
00061
00062
00063
#if __IS_MSDOS
00064
SYSTEMTIME aSystemTime;
00065 GetLocalTime( (SYSTEMTIME *)&aSystemTime);
00066 datetimeRec.
year = aSystemTime.wYear; datetimeRec.
month = aSystemTime.wMonth;
00067 datetimeRec.
day = aSystemTime.wDay; datetimeRec.
hour = aSystemTime.wHour;
00068 datetimeRec.
minute = aSystemTime.wMinute; datetimeRec.
second = aSystemTime.wSecond;
00069
#else
00070
#if __IS_MAC
00071
GetDateTime(&secs);
00072
SecondsToDate(secs, &datetimeRec);
00073
#else
00074
struct tm* loctime;
00075 time_t long_time;
00076 time( &long_time );
00077 loctime = localtime(&long_time);
00078 datetimeRec.
year = loctime->tm_year; datetimeRec.
month = loctime->tm_mon+1;
00079 datetimeRec.
day = loctime->tm_mday; datetimeRec.
hour = loctime->tm_hour;
00080 datetimeRec.
minute = loctime->tm_min; datetimeRec.
second = loctime->tm_sec;
00081
#endif
00082
#endif
00083
00084
CMHelperICC2int32Const(&(linkHeader->
size ), theSize);
00085
CMHelperICC2int32Const(&(linkHeader->
cmmId ), 'Win ');
00086
CMHelperICC2int32Const(&(linkHeader->
version ),
icVersionNumber);
00087
CMHelperICC2int32Const(&(linkHeader->
deviceClass ), aClass);
00088
00089
CMHelperICC2int32Const(&(linkHeader->
colorSpace ), aColorSpace);
00090
00091
CMHelperICC2int32Const(&(linkHeader->
pcs ), aConnectionSpace);
00092
00093
CMHelperICC2int16(&(linkHeader->
date.
year ), &datetimeRec.
year);
00094
CMHelperICC2int16(&(linkHeader->
date.
month ), &datetimeRec.
month);
00095
CMHelperICC2int16(&(linkHeader->
date.
day ), &datetimeRec.
day);
00096
CMHelperICC2int16(&(linkHeader->
date.
hours ), &datetimeRec.
hour);
00097
CMHelperICC2int16(&(linkHeader->
date.
minutes ), &datetimeRec.
minute);
00098
CMHelperICC2int16(&(linkHeader->
date.
seconds ), &datetimeRec.
second);
00099
CMHelperICC2int32Const(&(linkHeader->
magic ),
icMagicNumber);
00100
CMHelperICC2int32Const(&(linkHeader->
platform ),
icSigMicrosoft);
00101
CMHelperICC2int32Const(&(linkHeader->
flags ), 0);
00102
CMHelperICC2int32Const(&(linkHeader->
manufacturer ),
icSigMicrosoft);
00103
CMHelperICC2int32Const(&(linkHeader->
model ), 0);
00104
CMHelperICC2int32Const(&(linkHeader->
attributes[0] ), 0);
00105
CMHelperICC2int32Const(&(linkHeader->
attributes[1] ), 0);
00106
CMHelperICC2int32Const(&(linkHeader->
renderingIntent ), aIntent );
00107
CMHelperICC2int32Const(&(linkHeader->
illuminant.
X ), 0.9642 * 65536);
00108
CMHelperICC2int32Const(&(linkHeader->
illuminant.
Y ), 1.0000 * 65536);
00109
CMHelperICC2int32Const(&(linkHeader->
illuminant.
Z ), 0.8249 * 65536);
00110
CMHelperICC2int32Const(&(linkHeader->
creator ), 'UJK ');
00111
00112
return err;
00113 }
00114
00115
CMError MyAdd_NL_HeaderMS ( UINT32 theSize,
icHeader *linkHeader,
unsigned long aIntent, icColorSpaceSignature sCS, icColorSpaceSignature dCS );
00116 CMError MyAdd_NL_HeaderMS ( UINT32 theSize,
icHeader *linkHeader,
unsigned long aIntent, icColorSpaceSignature sCS, icColorSpaceSignature dCS )
00117 {
00118
OSErr err =
noErr;
00119
#if ! __IS_MSDOS
00120
unsigned long secs;
00121
#endif
00122
DateTimeRec datetimeRec;
00123
00124
00125
#if __IS_MSDOS
00126
SYSTEMTIME aSystemTime;
00127 GetLocalTime( (SYSTEMTIME *)&aSystemTime);
00128 datetimeRec.
year = aSystemTime.wYear; datetimeRec.
month = aSystemTime.wMonth;
00129 datetimeRec.
day = aSystemTime.wDay; datetimeRec.
hour = aSystemTime.wHour;
00130 datetimeRec.
minute = aSystemTime.wMinute; datetimeRec.
second = aSystemTime.wSecond;
00131
#else
00132
#if __IS_MAC
00133
GetDateTime(&secs);
00134
SecondsToDate(secs, &datetimeRec);
00135
#else
00136
struct tm* loctime;
00137 time_t long_time;
00138 time( &long_time );
00139 loctime = localtime(&long_time);
00140 datetimeRec.
year = loctime->tm_year; datetimeRec.
month = loctime->tm_mon+1;
00141 datetimeRec.
day = loctime->tm_mday; datetimeRec.
hour = loctime->tm_hour;
00142 datetimeRec.
minute = loctime->tm_min; datetimeRec.
second = loctime->tm_sec;
00143
#endif
00144
#endif
00145
00146
00147 linkHeader->
size = theSize;
00148 linkHeader->
cmmId = 'Win ';
00149 linkHeader->
version =
icVersionNumber;
00150 linkHeader->
deviceClass =
icSigLinkClass;
00151
00152 linkHeader->
colorSpace = sCS;
00153
00154 linkHeader->
pcs = dCS;
00155
00156 linkHeader->
date.
year = datetimeRec.
year;
00157 linkHeader->
date.
month = datetimeRec.
month;
00158 linkHeader->
date.
day = datetimeRec.
day;
00159 linkHeader->
date.
hours = datetimeRec.
hour;
00160 linkHeader->
date.
minutes = datetimeRec.
minute;
00161 linkHeader->
date.
seconds = datetimeRec.
second;
00162 linkHeader->
magic =
icMagicNumber;
00163 linkHeader->
platform =
icSigMicrosoft;
00164 linkHeader->
flags = 0;
00165 linkHeader->
manufacturer =
icSigMicrosoft;
00166 linkHeader->
model = 0;
00167 linkHeader->
attributes[0] = 0;
00168 linkHeader->
attributes[1] = 0;
00169 linkHeader->
renderingIntent = aIntent ;
00170 linkHeader->
illuminant.
X = (
long)(0.9642 * 65536);
00171 linkHeader->
illuminant.
Y = (
long)(1.0000 * 65536);
00172 linkHeader->
illuminant.
Z = (
long)(0.8249 * 65536);
00173 linkHeader->
creator = 'UJK ';
00174
00175
return err;
00176 }
00177
00178 CMError MyAdd_NL_DescriptionTag (
LHTextDescriptionType *descPtr,
unsigned char *theText )
00179 {
00180
Ptr thePtr;
00181
OSErr err =
noErr;
00182
00183 theText[theText[0]] = 0x00;
00184
00185
00186
if (descPtr == 0)
00187
return -1;
00188
00189
00190
CMHelperICC2int32Const(&(descPtr->
typeDescriptor ),
icSigTextDescriptionType);
00191
CMHelperICC2int32Const(&(descPtr->
reserved ), 0);
00192
CMHelperICC2int32Const(&(descPtr->
ASCIICount ), (
long)theText[0]);
00193 thePtr = (
Ptr) &descPtr->
ASCIIName[0];
00194
BlockMove(&theText[1], thePtr, theText[0]);
00195 thePtr += theText[0];
00196
00197
00199
00200 *thePtr++ = 0;
00201 *thePtr++ = 0;
00202 *thePtr++ = 0;
00203 *thePtr++ = 0;
00205
00206 *thePtr++ = 0;
00207 *thePtr++ = 0;
00208 *thePtr++ = 0;
00209 *thePtr++ = 0;
00210
00211
00212
00213
00216 *thePtr++ = 0;
00217 *thePtr++ = 0;
00218
BlockMove(&theText[0], thePtr, theText[0]+1);
00219
return err;
00220 }
00221
00222 CMError MyAdd_NL_ColorantTag (
icXYZType *descPtr,
MyXYZNumber *aColor )
00223 {
00224
OSErr err =
noErr;
00225
00226
CMHelperICC2int32Const(&(descPtr->
base ),
icSigXYZType);
00227
CMHelperICC2int32Const((
OSType*)&(descPtr->
base )+1, 0);
00228
CMHelperICC2int32(&(descPtr->
data.
data[0].
X ), &aColor->
X);
00229
CMHelperICC2int32(&(descPtr->
data.
data[0].
Y ), &aColor->
Y);
00230
CMHelperICC2int32(&(descPtr->
data.
data[0].
Z ), &aColor->
Z);
00231
return err;
00232 }
00233
00234 CMError MyAdd_NL_CurveTag (
icCurveType *descPtr,
unsigned short Gamma )
00235 {
00236
OSErr err =
noErr;
00237
00238
CMHelperICC2int32Const(&(descPtr->
base ),
icSigCurveType);
00239
CMHelperICC2int32Const((
OSType*)&(descPtr->
base )+1, 0);
00240
CMHelperICC2int32Const(&(descPtr->
curve.
count ), 1);
00241
CMHelperICC2int16(&(descPtr->
curve.
data[0] ), &Gamma );
00242
return err;
00243 }
00244
00245 CMError MyAdd_NL_CopyrightTag (
unsigned char *copyrightText,
LHTextType *aLHTextType )
00246 {
00247
OSErr err=
noErr;
00248
00249 copyrightText[copyrightText[0]] = 0x00;
00250
CMHelperICC2int32Const(&(aLHTextType->
base ),
icSigTextType);
00251
CMHelperICC2int32Const((
OSType*)&(aLHTextType->
base )+1, 0);
00252
BlockMove(©rightText[1], &aLHTextType->
text[0], copyrightText[0]);
00253
00254
#ifdef DEBUG_OUTPUT
00255
if ( err && DebugCheck(kThisFile, kDebugErrorInfo) )
00256
DebugPrint(
"� MyAdd_NL_CopyrightTag-Error: result = %d\n",err);
00257
#endif
00258
return err;
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
CMError Fill_mft1_InputTable( Ptr theElut,
00279
icLut8* lutPtr,
00280 CMMModelPtr modelData);
00281 CMError Fill_mft1_InputTable( Ptr theElut,
00282
icLut8* lutPtr,
00283 CMMModelPtr modelData)
00284 {
00285
OSErr err =
noErr;
00286
long i;
00287
long j;
00288
unsigned long factor;
00289
unsigned long round;
00290
unsigned long shift;
00291
unsigned long ulAux;
00292
unsigned short *wordElut = (
unsigned short*)theElut;
00293
unsigned long newScale = 255;
00294
unsigned long oldScale = ((1U<< modelData->lutParam.inputLutWordSize) * (lutPtr->
clutPoints-1)) / lutPtr->
clutPoints;
00295
00296
if( modelData->currentCall ==
kCMMNewLinkProfile ){
00297 oldScale = 1<< modelData->lutParam.inputLutWordSize;
00298 }
00299 factor = (newScale << 24) / oldScale;
00300 round = (1<<(24-1))-1;
00301 shift = 24;
00302
00303 ulAux = ~( (1<< (32-modelData->lutParam.inputLutWordSize))-1);
00304
while (factor & ulAux )
00305 {
00306 factor >>= 1;
00307 round >>= 1;
00308 shift -= 1;
00309 }
00310
00311
for (i=0; i<(
long)lutPtr->
inputChan; i++)
00312 {
00313
for (j=0; j< 256; j++)
00314 {
00315 ulAux = ((
unsigned long)*wordElut * factor + round) >> shift;
00316 lutPtr->
data[i * 256 + j] = (
UINT8)(ulAux );
00317 wordElut++;
00318 }
00319 }
00320
return err;
00321 }
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
CMError Fill_mft1_OutputTable( Ptr theAlut,
00343
icLut8* lutPtr,
00344
long offset,
00345 CMMModelPtr modelData);
00346 CMError Fill_mft1_OutputTable( Ptr theAlut,
00347
icLut8* lutPtr,
00348
long offset,
00349 CMMModelPtr modelData)
00350 {
00351
OSErr err =
noErr;
00352
long i;
00353
long j;
00354
UINT8* byteAlut = (
UINT8*)theAlut;
00355
long numOfAlutEntries = modelData->lutParam.outputLutEntryCount;
00356
00357
for (i=0; i<(
long)lutPtr->
outputChan; i++)
00358 {
00359
for (j=0; j<256; j++)
00360 {
00361 byteAlut = (
UINT8*)theAlut + (j * (numOfAlutEntries-1)) / 255 ;
00362 lutPtr->
data[offset + i * 256 + j] = *byteAlut;
00363 }
00364 theAlut += numOfAlutEntries;
00365 }
00366
return err;
00367 }
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
CMError Fill_mft2_InputTable( Ptr theElut,
00387
icLut16* lutPtr,
00388 CMMModelPtr modelData);
00389 CMError Fill_mft2_InputTable( Ptr theElut,
00390
icLut16* lutPtr,
00391 CMMModelPtr modelData)
00392 {
00393
OSErr err =
noErr;
00394
unsigned long factor;
00395
unsigned long round;
00396
unsigned long shift;
00397
unsigned long ulAux;
00398
long i;
00399
long j;
00400
UINT16* wordElut = (
UINT16*)theElut;
00401
UINT16* wordData = (
UINT16*)lutPtr->
data;
00402
unsigned long newScale = 65535;
00403
00404
unsigned long oldScale = ( (1<<modelData->lutParam.inputLutWordSize) * (modelData->lutParam.colorLutGridPoints-1)) / modelData->lutParam.colorLutGridPoints;
00405
00406
if( modelData->currentCall ==
kCMMNewLinkProfile ){
00407 oldScale = 1<< modelData->lutParam.inputLutWordSize;
00408 }
00409 factor = (newScale << 15) / oldScale;
00410 round = (1<<(15-1))-1;
00411 shift = 15;
00412
00413
while (factor & 0xFFFF0000)
00414 {
00415 factor >>= 1;
00416 round >>= 1;
00417 shift -= 1;
00418 }
00419
00420
for (i=0; i<(
long)lutPtr->
inputChan; i++)
00421 {
00422
for (j=0; j< (
long)lutPtr->
inputEnt; j++)
00423 {
00424 ulAux = ((
unsigned long)*wordElut * factor + round) >> shift;
00425
CMHelperICC2int16Const( wordData, ulAux );
00426 wordData++;
00427 wordElut++;
00428 }
00429 }
00430
return err;
00431 }
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
CMError Fill_mft2_OutputTable( Ptr theAlut,
00452
icLut16* lutPtr,
00453
long offset,
00454 CMMModelPtr modelData );
00455 CMError Fill_mft2_OutputTable( Ptr theAlut,
00456
icLut16* lutPtr,
00457
long offset,
00458 CMMModelPtr modelData )
00459 {
00460
OSErr err =
noErr;
00461
long i;
00462
long j;
00463
UINT16* wordAlut = (
UINT16*)theAlut;
00464
UINT16* wordData = (
UINT16*)lutPtr->
data + offset;
00465
00466 modelData = modelData;
00467
for (i=0; i<(
long)lutPtr->
outputChan; i++)
00468 {
00469
for (j=0; j<(
long)lutPtr->
outputEnt; j++)
00470 {
00471
CMHelperICC2int16Const( wordData, *wordAlut );
00472 wordData++;
00473 wordAlut++;
00474 }
00475 }
00476
return err;
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
CMError Fill_mft2_ColorTable( Ptr theClut,
00499
icLut16* lutPtr,
00500
long offset,
00501
long count );
00502 CMError Fill_mft2_ColorTable( Ptr theClut,
00503
icLut16* lutPtr,
00504
long offset,
00505
long count )
00506 {
00507
OSErr err =
noErr;
00508
long i;
00509
UINT16* wordClut = (
UINT16*)theClut;
00510
UINT16* wordData = (
UINT16*)lutPtr->
data + offset;
00511
00512
for ( i=0; i<count; i++)
00513 {
00514
CMHelperICC2int16Const( wordData, *wordClut );
00515 wordData++;
00516 wordClut++;
00517 }
00518
return err;
00519 }
00520
00521 CMError MyAdd_NL_AToB0Tag_mft1( CMMModelPtr cw,
icLut8Type *lutPtr,
long colorLutSize )
00522 {
00523
CMError err;
00524
icLut8 *tempLutPtr;
00525
long offset;
00526
UINT16 inputChannels;
00527
UINT16 outputChannels;
00528
UINT16 gridPoints;
00529
00530
LH_START_PROC(
"Add_NL_AToB0Tag_mft1")
00531
00532
LOCK_DATA(cw->lutParam.inputLut);
00533
LOCK_DATA(cw->lutParam.colorLut);
00534
LOCK_DATA(cw->lutParam.outputLut);
00535
00536 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00537 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00538 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00539
00540 tempLutPtr = &lutPtr->
lut;
00541
CMHelperICC2int32Const(&(lutPtr->
base ),
icSigLut8Type);
00542
CMHelperICC2int32Const((
OSType*)&(lutPtr->
base )+1, 0);
00543 tempLutPtr->
inputChan = (
UINT8)inputChannels;
00544 tempLutPtr->
outputChan = (
UINT8)outputChannels;
00545 tempLutPtr->
clutPoints = (
UINT8)gridPoints;
00546 tempLutPtr->
e00 = tempLutPtr->
e01 = tempLutPtr->
e02 = 0;
00547 tempLutPtr->
e10 = tempLutPtr->
e11 = tempLutPtr->
e12 = 0;
00548 tempLutPtr->
e20 = tempLutPtr->
e21 = tempLutPtr->
e22 = 0;
00549
CMHelperICC2int32Const(&(tempLutPtr->
e00 ), 0x10000);
00550
CMHelperICC2int32Const(&(tempLutPtr->
e11 ), 0x10000);
00551
CMHelperICC2int32Const(&(tempLutPtr->
e22 ), 0x10000);
00552
00553 err =
Fill_mft1_InputTable((
Ptr)
DATA_2_PTR(cw->lutParam.inputLut), tempLutPtr, cw);
00554
if (err)
00555
goto CleanupAndExit;
00556
00557 offset = 256 * inputChannels;
00558
BlockMoveData(
DATA_2_PTR(cw->lutParam.colorLut), & tempLutPtr->
data[0] + offset, colorLutSize);
00559
00560 offset = offset + colorLutSize;
00561 err =
Fill_mft1_OutputTable((
Ptr)
DATA_2_PTR(cw->lutParam.outputLut), tempLutPtr, offset, cw);
00562
if (err)
00563
goto CleanupAndExit;
00564
00565 CleanupAndExit:
00566
00567
#ifdef DEBUG_OUTPUT
00568
if ( err )
00569
DebugPrint(
"� MyAdd_NL_AToB0Tag_mft1-Error: result = %d\n",err);
00570
#endif
00571
UNLOCK_DATA(cw->lutParam.inputLut);
00572
UNLOCK_DATA(cw->lutParam.colorLut);
00573
UNLOCK_DATA(cw->lutParam.outputLut);
00574
LH_END_PROC(
"Add_NL_AToB0Tag_mft1")
00575
return err;
00576 }
00577
00578
UINT32 GetSizes( CMMModelPtr cw, UINT32 *clutSize );
00579 UINT32 GetSizes( CMMModelPtr cw, UINT32 *clutSize )
00580 {
00581
UINT16 inputChannels;
00582
UINT16 outputChannels;
00583
UINT16 gridPoints;
00584
SINT32 colorLutSize;
00585
UINT32 i,theSize;
00586
00587
LOCK_DATA(cw->lutParam.inputLut);
00588
LOCK_DATA(cw->lutParam.colorLut);
00589
LOCK_DATA(cw->lutParam.outputLut);
00590
00591 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00592 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00593 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00594
00595 colorLutSize = outputChannels;
00596
for(i = 0; i < inputChannels; i++)
00597 colorLutSize *= gridPoints;
00598
00599
if ( cw->lutParam.colorLutWordSize != 8){
00600 theSize =
sizeof(
OSType) +
sizeof(
UINT32) + (4 *
sizeof(
UINT8)) + (9 *
sizeof(
Fixed))
00601 + 2 *
sizeof(
icUInt16Number)
00602 + (inputChannels * cw->lutParam.inputLutEntryCount *
sizeof(
UINT16))
00603 + (outputChannels * cw->lutParam.outputLutEntryCount *
sizeof(
UINT16))
00604 + colorLutSize *
sizeof(
UINT16);
00605 }
00606
else{
00607 theSize =
sizeof(
OSType) +
sizeof(
UINT32) + (4 *
sizeof(
UINT8)) + (9 *
sizeof(
Fixed))
00608 + (inputChannels * 256 *
sizeof(
UINT8))
00609 + (outputChannels * 256 *
sizeof(
UINT8))
00610 + colorLutSize;
00611 }
00612 *clutSize = colorLutSize;
00613
UNLOCK_DATA(cw->lutParam.inputLut);
00614
UNLOCK_DATA(cw->lutParam.colorLut);
00615
UNLOCK_DATA(cw->lutParam.outputLut);
00616
return theSize;
00617 }
00618
00619 CMError MyAdd_NL_AToB0Tag_mft2( CMMModelPtr cw,
icLut16Type *lutPtr,
long colorLutSize )
00620 {
00621
CMError err;
00622
icLut16 *tempLutPtr;
00623
long offset;
00624
UINT16 inputChannels;
00625
UINT16 outputChannels;
00626
UINT16 gridPoints;
00627
00628
LH_START_PROC(
"Add_NL_AToB0Tag_mft2")
00629
00630
LOCK_DATA(cw->lutParam.inputLut);
00631
LOCK_DATA(cw->lutParam.colorLut);
00632
LOCK_DATA(cw->lutParam.outputLut);
00633
00634 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00635 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00636 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00637
00638 tempLutPtr = &lutPtr->
lut;
00639
CMHelperICC2int32Const(&(lutPtr->
base ),
icSigLut16Type);
00640
CMHelperICC2int32Const((
OSType*)&(lutPtr->
base )+1, 0);
00641 tempLutPtr->
inputChan = (
UINT8)inputChannels;
00642 tempLutPtr->
outputChan = (
UINT8)outputChannels;
00643 tempLutPtr->
clutPoints = (
UINT8)((gridPoints>255)?255:gridPoints);
00644 tempLutPtr->
e00 = tempLutPtr->
e01 = tempLutPtr->
e02 = 0;
00645 tempLutPtr->
e10 = tempLutPtr->
e11 = tempLutPtr->
e12 = 0;
00646 tempLutPtr->
e20 = tempLutPtr->
e21 = tempLutPtr->
e22 = 0;
00647
CMHelperICC2int32Const(&(tempLutPtr->
e00 ), 0x10000);
00648
CMHelperICC2int32Const(&(tempLutPtr->
e11 ), 0x10000);
00649
CMHelperICC2int32Const(&(tempLutPtr->
e22 ), 0x10000);
00650
00651 tempLutPtr->
inputEnt = (
UINT16)cw->lutParam.inputLutEntryCount;
00652 tempLutPtr->
outputEnt = (
UINT16)cw->lutParam.outputLutEntryCount;
00653 err =
Fill_mft2_InputTable((
Ptr)
DATA_2_PTR(cw->lutParam.inputLut), tempLutPtr, cw);
00654
if (err)
00655
goto CleanupAndExit;
00656
00657 offset = cw->lutParam.inputLutEntryCount * inputChannels;
00658
Fill_mft2_ColorTable( (
Ptr)
DATA_2_PTR(cw->lutParam.colorLut), tempLutPtr, offset, colorLutSize);
00659
00660 offset = offset + colorLutSize;
00661 err =
Fill_mft2_OutputTable((
Ptr)
DATA_2_PTR(cw->lutParam.outputLut), tempLutPtr, offset, cw);
00662
if (err)
00663
goto CleanupAndExit;
00664
00665
CMHelperICC2int16Const(&(tempLutPtr->
inputEnt ), (
UINT16)cw->lutParam.inputLutEntryCount);
00666
CMHelperICC2int16Const(&(tempLutPtr->
outputEnt ), (
UINT16)cw->lutParam.outputLutEntryCount);
00667
00668 CleanupAndExit:
00669
00670
#ifdef DEBUG_OUTPUT
00671
if ( err )
00672
DebugPrint(
"� MyAdd_NL_AToB0Tag_mft2-Error: result = %d\n",err);
00673
#endif
00674
UNLOCK_DATA(cw->lutParam.inputLut);
00675
UNLOCK_DATA(cw->lutParam.colorLut);
00676
UNLOCK_DATA(cw->lutParam.outputLut);
00677
LH_END_PROC(
"Add_NL_AToB0Tag_mft2")
00678
return err;
00679 }
00680
00681
CMError MyGetColorSpaces(
CMConcatProfileSet *profileSet,
00682 UINT32 *sCS,
00683 UINT32 *dCS );
00684 CMError MyGetColorSpaces(
CMConcatProfileSet *profileSet,
00685 UINT32 *sCS,
00686 UINT32 *dCS )
00687 {
00688
CMError err;
00689
icHeader profHeader;
00690
00691
LH_START_PROC(
"MyGetColorSpaces")
00692
00693 err =
CMGetProfileHeader(profileSet->
profileSet[0], (
CMCoreProfileHeader *)&profHeader);
00694
if (err)
00695
goto CleanupAndExit;
00696 *sCS = profHeader.
colorSpace;
00697
00698 err =
CMGetProfileHeader(profileSet->
profileSet[profileSet->
count-1], (
CMCoreProfileHeader *)&profHeader);
00699
if (err)
00700
goto CleanupAndExit;
00701 *dCS = profHeader.
colorSpace;
00702
00703 CleanupAndExit:
00704
LH_END_PROC(
"MyAdd_NL_SequenceDescTag")
00705
return err;
00706 }
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724 CMError MyAdd_NL_SequenceDescTag(
CMConcatProfileSet *profileSet,
00725
icProfileSequenceDescType *pSeqPtr,
00726
long *aSize )
00727 {
00728
CMError err;
00729
OSErr aOSerr;
00730
00731
Ptr thePtr =
nil;
00732
icHeader profHeader;
00733
SINT32 loop;
00734
OSType technology;
00735
UINT32 elementSize;
00736
icSignatureType theSignature;
00737
icTextDescriptionType* descPtr =
nil;
00738
char descPtrNull[90]={0};
00739
00740
LH_START_PROC(
"MyAdd_NL_SequenceDescTag")
00741
00742
CMHelperICC2int32Const(&(((
icTextDescriptionType*)descPtrNull)->base ),
icSigTextDescriptionType );
00743
CMHelperICC2int32Const(((
OSType*)&((
icTextDescriptionType*)descPtrNull)->base )+1, 0);
00744
CMHelperICC2int32Const(&(((icTextDescriptionType*)descPtrNull)->desc.count ), 1 );
00745
00746
00747
00748
00749
CMHelperICC2int32Const(&(pSeqPtr->
base ),
icSigProfileSequenceDescType);
00750
CMHelperICC2int32Const((
OSType*)&(pSeqPtr->
base )+1, 0);
00751
CMHelperICC2int32Const(&(pSeqPtr->
desc.
count ), profileSet->
count );
00752 thePtr = (
Ptr)( (SIZE_T)&(pSeqPtr->
desc.
count) +
sizeof(
SINT32) ) ;
00753
00754
for (loop = 0; loop < (
SINT32)profileSet->
count; loop++)
00755 {
00756 err =
CMGetProfileHeader(profileSet->
profileSet[loop], (
CMCoreProfileHeader *)&profHeader);
00757
if (err)
00758
goto CleanupAndExit;
00759
CMHelperICC2int32Const(thePtr, profHeader.
manufacturer);
00760 thePtr +=
sizeof(
OSType);
00761
CMHelperICC2int32Const(thePtr, profHeader.
model);
00762 thePtr +=
sizeof(
OSType);
00763
CMHelperICC2int32Const(thePtr, profHeader.
attributes[0]);
00764 thePtr +=
sizeof(
UINT32);
00765
CMHelperICC2int32Const(thePtr, profHeader.
attributes[1]);
00766 thePtr +=
sizeof(
UINT32);
00767
00768
00769 technology = 0;
00770
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigTechnologyTag, &elementSize,
nil) ==
noErr)
00771 {
00772
if (elementSize ==
sizeof(
icSigTechnologyTag))
00773 {
00774
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigTechnologyTag, &elementSize, &theSignature) ==
noErr)
00775 technology = theSignature.
signature;
00776 }
00777 }
00778 *((
OSType*)thePtr) = technology;
00779 thePtr +=
sizeof(
OSType);
00780
00781
00782
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigDeviceMfgDescTag, &elementSize,
nil) ==
noErr)
00783 {
00784 descPtr = (icTextDescriptionType*)
SmartNewPtr(elementSize,&aOSerr);
00785 err = aOSerr;
00786
if (err)
00787
goto CleanupAndExit;
00788
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigDeviceMfgDescTag, &elementSize, descPtr) ==
noErr)
00789 {
00790
BlockMoveData( descPtr, thePtr, elementSize);
00791 thePtr += elementSize;
00792 }
00793 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00794 }
else
00795 {
00796
BlockMoveData( descPtrNull, thePtr,
sizeof(descPtrNull));
00797 thePtr +=
sizeof(descPtrNull);
00798 }
00799
00800
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigDeviceModelDescTag, &elementSize,
nil) ==
noErr)
00801 {
00802 descPtr = (icTextDescriptionType*)
SmartNewPtr(elementSize,&aOSerr);
00803 err = aOSerr;
00804
if (err)
00805
goto CleanupAndExit;
00806
if (
CMGetProfileElement(profileSet->
profileSet[loop],
icSigDeviceModelDescTag, &elementSize, descPtr) ==
noErr)
00807 {
00808
BlockMoveData( descPtr, thePtr, elementSize);
00809 thePtr += elementSize;
00810 }
00811 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00812 }
else
00813 {
00814
BlockMoveData( descPtrNull, thePtr,
sizeof(descPtrNull));
00815 thePtr +=
sizeof(descPtrNull);
00816 }
00817
00818 }
00819
00820
00821 *aSize = (LONG)((ULONG_PTR)thePtr - (ULONG_PTR)pSeqPtr);
00822
00823 CleanupAndExit:
00824 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00825
LH_END_PROC(
"MyAdd_NL_SequenceDescTag")
00826
return err;
00827 }
00828
00829
00830
MyXYZNumber MakeXYZNumber(
MyXYZNumber *x );
00831 MyXYZNumber MakeXYZNumber(
MyXYZNumber *x )
00832 {
00833
MyXYZNumber ret;
00834 ret.
X = x->
X>>14;
00835 ret.
Y = x->
Y>>14;
00836 ret.
Z = x->
Z>>14;
00837
return ret;
00838 }
00839
00840
void MakeMyDoubleXYZ(
MyXYZNumber *x,
MyDoubleXYZ *ret );
00841 void MakeMyDoubleXYZ(
MyXYZNumber *x,
MyDoubleXYZ *ret )
00842 {
00843 ret->
X = x->
X/(
double)(1<<30);
00844 ret->
Y = x->
Y/(
double)(1<<30);
00845 ret->
Z = x->
Z/(
double)(1<<30);
00846 }
00847
Boolean doubMatrixInvert(
double inpMat[3][3],
00848
double outMat[3][3] );
00849
void TransposeMatrix(
double inpMat[3][3] );
00850 void TransposeMatrix(
double inpMat[3][3] )
00851 {
00852
long i,j;
00853
double sav;
00854
for( i=0; i< 3; i++ ){
00855
for( j=i+1; j< 3; j++ ){
00856 sav = inpMat[i][j];
00857 inpMat[i][j] = inpMat[j][i];
00858 inpMat[j][i] = sav;
00859 }
00860 }
00861
00862 }
00863 #define Round(a) (((a)>0.)?((a)+.5):((a)-.5))
00864
00865
double GetMatrixedVal(
double m[3][3],
long color,
MyDoubleXYZ *aXYZ );
00866 double GetMatrixedVal(
double m[3][3],
long color,
MyDoubleXYZ *aXYZ )
00867 {
00868
double tmp;
00869 tmp = m[color][0] * aXYZ->
X;
00870 tmp+= m[color][1] * aXYZ->
Y;
00871 tmp+= m[color][2] * aXYZ->
Z;
00872
return tmp;
00873 }
00874
00875
void NormalizeColor(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB );
00876 void NormalizeColor(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB )
00877 {
00878
double factorX,factorY,factorZ;
00879
double inMat[3][3];
00880
00881
MakeMyDoubleXYZ( r, (
MyDoubleXYZ*)&inMat[0][0] );
00882
MakeMyDoubleXYZ(
g, (
MyDoubleXYZ*)&inMat[1][0] );
00883
MakeMyDoubleXYZ( b, (
MyDoubleXYZ*)&inMat[2][0] );
00884
00885 factorX = inMat[0][0] + inMat[1][0] + inMat[2][0];
00886 factorY = inMat[0][1] + inMat[1][1] + inMat[2][1];
00887 factorZ = inMat[0][2] + inMat[1][2] + inMat[2][2];
00888
00889 factorX = Illuminant->
X / factorX * 65536;
00890 factorY = Illuminant->
Y / factorY * 65536;
00891 factorZ = Illuminant->
Z / factorZ * 65536;
00892
00893 resR->
X = (
long)
Round(inMat[0][0] * factorX);
00894 resR->
Y = (
long)
Round(inMat[0][1] * factorY);
00895 resR->
Z = (
long)
Round(inMat[0][2] * factorZ);
00896 resG->
X = (
long)
Round(inMat[1][0] * factorX);
00897 resG->
Y = (
long)
Round(inMat[1][1] * factorY);
00898 resG->
Z = (
long)
Round(inMat[1][2] * factorZ);
00899 resB->
X = (
long)
Round(inMat[2][0] * factorX);
00900 resB->
Y = (
long)
Round(inMat[2][1] * factorY);
00901 resB->
Z = (
long)
Round(inMat[2][2] * factorZ);
00902 }
00903
00904
void NormalizeWithWhiteAdaption(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB );
00905 void NormalizeWithWhiteAdaption(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB )
00906 {
00907
double factorR,factorG,factorB;
00908
double inMat[3][3];
00909
double outMat[3][3];
00910
00911
MakeMyDoubleXYZ( r, (
MyDoubleXYZ*)&inMat[0][0] );
00912
MakeMyDoubleXYZ(
g, (
MyDoubleXYZ*)&inMat[1][0] );
00913
MakeMyDoubleXYZ( b, (
MyDoubleXYZ*)&inMat[2][0] );
00914
00915
if( !
doubMatrixInvert(inMat, outMat) )
00916 {
00917
return ;
00918 }
00919
00920
TransposeMatrix( outMat );
00921
00922 factorR =
GetMatrixedVal( outMat, 0, Illuminant )*65536;
00923 factorG =
GetMatrixedVal( outMat, 1, Illuminant )*65536;
00924 factorB =
GetMatrixedVal( outMat, 2, Illuminant )*65536;
00925
00926 resR->
X = (
long)
Round(inMat[0][0] * factorR);
00927 resR->
Y = (
long)
Round(inMat[0][1] * factorR);
00928 resR->
Z = (
long)
Round(inMat[0][2] * factorR);
00929 resG->
X = (
long)
Round(inMat[1][0] * factorG);
00930 resG->
Y = (
long)
Round(inMat[1][1] * factorG);
00931 resG->
Z = (
long)
Round(inMat[1][2] * factorG);
00932 resB->
X = (
long)
Round(inMat[2][0] * factorB);
00933 resB->
Y = (
long)
Round(inMat[2][1] * factorB);
00934 resB->
Z = (
long)
Round(inMat[2][2] * factorB);
00935 }
00936
00937
#ifdef WRITE_PROFILE
00938
void WriteProf( Ptr name,
icProfile *theProf,
long currentSize );
00939
#endif
00940
00941 #define MyTagCount 9
00942
00943
#if __IS_MSDOS && defined(RenderInt)
00944
CMError MyNewAbstract( LPLOGCOLORSPACEA lpColorSpace,
icProfile **theProf )
00945 {
00946
CMError err =
unimpErr;
00947
OSErr aOSerr =
unimpErr;
00948
#ifdef __MWERKS__
00949
unsigned char theText[] =
"\pLogColorSpProfile ";
00950
char copyrightText[] =
"\p�1996 by Heidelberger Druckmaschinen AG U.J.K.";
00951
#elif __IS_MSDOS
00952
char theText[] =
"\030LogColorSpProfile ";
00953
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
00954
#else
00955
char theText[] =
"\030LogColorSpProfile ";
00956
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
00957
#endif
00958
icProfile *aProf=0;
00959
long theTagTabSize;
00960
long theHeaderSize;
00961
long theDescSize;
00962
long theMediaSize;
00963
long theEndPointSize;
00964
long theTRCSize;
00965
long theCopyRightSize;
00966
long currentSize=0;
00967
long theTotalSize=0;
00968
icTag aTag;
00969
unsigned long aIntent;
00970
00971
MyXYZNumber rXYZ,gXYZ,bXYZ;
00972
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
00973
MyXYZNumber D50 = { (
unsigned long)(D50XYZ.
X * 65536), (
unsigned long)(D50XYZ.
Y * 65536), (
unsigned long)(D50XYZ.
Z * 65536)};
00974 theHeaderSize =
sizeof(
icHeader);
00975 theDescSize =
sizeof(
OSType)
00976 +
sizeof(
unsigned long)
00977 +
sizeof(
unsigned long)
00978 + theText[0]
00979 +
sizeof(
unsigned long)
00980 +
sizeof(
unsigned long)
00981 +
sizeof(
unsigned short)
00982 +
sizeof(
unsigned char)
00983 + 67
00984 ;
00985 theCopyRightSize =
sizeof(
OSType)
00986 +
sizeof(
unsigned long)
00987 + copyrightText[0]
00988 ;
00989 theMediaSize =
sizeof(
icXYZType );;
00990 theEndPointSize =
sizeof(
icXYZType );;
00991 theTRCSize = 4*((
sizeof(
icCurveType ) +3)/4);
00992
00993 theTagTabSize =
MyTagCount *
sizeof(
icTag ) +
sizeof(
unsigned long );
00994
00995 theTotalSize = theHeaderSize + theTagTabSize + theDescSize + theCopyRightSize
00996 + theMediaSize + 3*theEndPointSize + 3*theTRCSize;
00997 aProf = (
icProfile *)GlobalAllocPtr( GHND, theTotalSize );
00998
if( aProf == 0 ){
00999 err = GetLastError();
01000
goto CleanupAndExit;
01001 }
01002
01003
switch( lpColorSpace->lcsIntent ){
01004
case LCS_GM_BUSINESS:
01005 aIntent =
icSaturation;
01006
break;
01007
case LCS_GM_GRAPHICS:
01008 aIntent =
icRelativeColorimetric;
01009
break;
01010
case LCS_GM_ABS_COLORIMETRIC:
01011 aIntent =
icAbsoluteColorimetric;
01012
break;
01013
default:
01014 aIntent =
icPerceptual;
01015
break;
01016 }
01017 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((
Ptr)aProf+currentSize), aIntent,
icSigInputClass,
icSigRgbData,
icSigXYZData );
01018
if (err)
01019
goto CleanupAndExit;
01020
01021
01022 currentSize = theHeaderSize + theTagTabSize;
01023
CMHelperICC2int32Const(&(aProf->
tagList.
count ),
MyTagCount);
01024
01025
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileDescriptionTag);
01026
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01027
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01028 aProf->
tagList.
tags[0] = aTag;
01029 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((
Ptr)aProf+currentSize), (
unsigned char *)theText );
01030
if (err)
01031
goto CleanupAndExit;
01032 currentSize += theDescSize;
01033
01034
CMHelperICC2int32Const(&(aTag.
sig ),
icSigMediaWhitePointTag);
01035
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01036
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01037 aProf->
tagList.
tags[1] = aTag;
01038
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &D50);
01039 currentSize += theMediaSize;
01040
01041
NormalizeColor( (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzRed,
01042 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzGreen,
01043 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzBlue,
01044 &D50XYZ,
01045 &rXYZ,
01046 &gXYZ,
01047 &bXYZ );
01048
CMHelperICC2int32Const(&(aTag.
sig ),
icSigRedColorantTag);
01049
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01050
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01051 aProf->
tagList.
tags[2] = aTag;
01052
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &rXYZ );
01053 currentSize += theEndPointSize;
01054
01055
CMHelperICC2int32Const(&(aTag.
sig ),
icSigGreenColorantTag);
01056
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01057
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01058 aProf->
tagList.
tags[3] = aTag;
01059
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &gXYZ );
01060 currentSize += theEndPointSize;
01061
01062
CMHelperICC2int32Const(&(aTag.
sig ),
icSigBlueColorantTag);
01063
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01064
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01065 aProf->
tagList.
tags[4] = aTag;
01066
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &bXYZ );
01067 currentSize += theEndPointSize;
01068
01069
CMHelperICC2int32Const(&(aTag.
sig ),
icSigRedTRCTag);
01070
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01071
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01072 aProf->
tagList.
tags[5] = aTag;
01073
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaRed>>8) );
01074 currentSize += theTRCSize;
01075
01076
CMHelperICC2int32Const(&(aTag.
sig ),
icSigGreenTRCTag);
01077
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01078
CMHelperICC2int32Const(&(aTag.
size ),
sizeof( icCurveType ));
01079 aProf->
tagList.
tags[6] = aTag;
01080
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaGreen>>8) );
01081 currentSize += theTRCSize;
01082
01083
CMHelperICC2int32Const(&(aTag.
sig ),
icSigBlueTRCTag);
01084
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01085
CMHelperICC2int32Const(&(aTag.
size ),
sizeof( icCurveType ));
01086 aProf->
tagList.
tags[7] = aTag;
01087
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaBlue>>8) );
01088 currentSize += theTRCSize;
01089
01090
CMHelperICC2int32Const(&(aTag.
sig ),
icSigCopyrightTag);
01091
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01092
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01093 aProf->
tagList.
tags[8] = aTag;
01094 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((
Ptr)aProf+currentSize));
01095
if (err)
01096
goto CleanupAndExit;
01097 currentSize += theCopyRightSize;
01098
01099 *theProf = aProf;
01100
#ifdef WRITE_PROFILE
01101
WriteProf(
"MyNewAbstract.pf", aProf, currentSize );
01102
#endif
01103
return noErr;
01104
01105 CleanupAndExit:
01106
if( aProf )GlobalFreePtr( aProf );
01107
return err;
01108 }
01109
01110
01111
CMError MyNewAbstractW( LPLOGCOLORSPACEW lpColorSpace,
icProfile **theProf )
01112 {
01113
CMError err =
unimpErr;
01114
OSErr aOSerr =
unimpErr;
01115
#ifdef __MWERKS__
01116
unsigned char theText[] =
"\pLogColorSpProfile ";
01117
char copyrightText[] =
"\p�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01118
#elif __IS_MSDOS
01119
char theText[] =
"\030LogColorSpProfile ";
01120
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01121
#else
01122
char theText[] =
"\030LogColorSpProfile ";
01123
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01124
#endif
01125
icProfile *aProf=0;
01126
long theTagTabSize;
01127
long theHeaderSize;
01128
long theDescSize;
01129
long theMediaSize;
01130
long theEndPointSize;
01131
long theTRCSize;
01132
long theCopyRightSize;
01133
long currentSize=0;
01134
long theTotalSize=0;
01135
icTag aTag;
01136
unsigned long aIntent;
01137
01138
MyXYZNumber rXYZ,gXYZ,bXYZ;
01139
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
01140
MyXYZNumber D50 = { (
unsigned long)(D50XYZ.
X * 65536), (
unsigned long)(D50XYZ.
Y * 65536), (
unsigned long)(D50XYZ.
Z * 65536)};
01141 theHeaderSize =
sizeof(
icHeader);
01142 theDescSize =
sizeof(
OSType)
01143 +
sizeof(
unsigned long)
01144 +
sizeof(
unsigned long)
01145 + theText[0]
01146 +
sizeof(
unsigned long)
01147 +
sizeof(
unsigned long)
01148 +
sizeof(
unsigned short)
01149 +
sizeof(
unsigned char)
01150 + 67
01151 ;
01152 theCopyRightSize =
sizeof(
OSType)
01153 +
sizeof(
unsigned long)
01154 + copyrightText[0]
01155 ;
01156 theMediaSize =
sizeof(
icXYZType );;
01157 theEndPointSize =
sizeof(
icXYZType );;
01158 theTRCSize = 4*((
sizeof(
icCurveType ) +3)/4);
01159
01160 theTagTabSize =
MyTagCount *
sizeof(
icTag ) +
sizeof(
unsigned long );
01161
01162 theTotalSize = theHeaderSize + theTagTabSize + theDescSize + theCopyRightSize
01163 + theMediaSize + 3*theEndPointSize + 3*theTRCSize;
01164 aProf = (
icProfile *)GlobalAllocPtr( GHND, theTotalSize );
01165
if( aProf == 0 ){
01166 err = GetLastError();
01167
goto CleanupAndExit;
01168 }
01169
01170
switch( lpColorSpace->lcsIntent ){
01171
case LCS_GM_BUSINESS:
01172 aIntent =
icSaturation;
01173
break;
01174
case LCS_GM_GRAPHICS:
01175 aIntent =
icRelativeColorimetric;
01176
break;
01177
case LCS_GM_GRAPHICS+1:
01178 aIntent =
icAbsoluteColorimetric;
01179
break;
01180
default:
01181 aIntent =
icPerceptual;
01182
break;
01183 }
01184 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((Ptr)aProf+currentSize), aIntent, icSigInputClass, icSigRgbData, icSigXYZData );
01185
if (err)
01186
goto CleanupAndExit;
01187
01188
01189 currentSize = theHeaderSize + theTagTabSize;
01190
CMHelperICC2int32Const(&(aProf->
tagList.
count ), MyTagCount);
01191
01192
CMHelperICC2int32Const(&(aTag.
sig ), icSigProfileDescriptionTag);
01193
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01194
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01195 aProf->
tagList.
tags[0] = aTag;
01196 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((Ptr)aProf+currentSize), (
unsigned char *)theText );
01197
if (err)
01198
goto CleanupAndExit;
01199 currentSize += theDescSize;
01200
01201
CMHelperICC2int32Const(&(aTag.
sig ), icSigMediaWhitePointTag);
01202
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01203
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01204 aProf->
tagList.
tags[1] = aTag;
01205
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &D50);
01206 currentSize += theMediaSize;
01207
01208
NormalizeColor( (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzRed,
01209 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzGreen,
01210 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzBlue,
01211 &D50XYZ,
01212 &rXYZ,
01213 &gXYZ,
01214 &bXYZ );
01215
CMHelperICC2int32Const(&(aTag.
sig ), icSigRedColorantTag);
01216
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01217
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01218 aProf->
tagList.
tags[2] = aTag;
01219
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &rXYZ );
01220 currentSize += theEndPointSize;
01221
01222
CMHelperICC2int32Const(&(aTag.
sig ), icSigGreenColorantTag);
01223
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01224
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01225 aProf->
tagList.
tags[3] = aTag;
01226
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &gXYZ );
01227 currentSize += theEndPointSize;
01228
01229
CMHelperICC2int32Const(&(aTag.
sig ), icSigBlueColorantTag);
01230
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01231
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01232 aProf->
tagList.
tags[4] = aTag;
01233
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &bXYZ );
01234 currentSize += theEndPointSize;
01235
01236
CMHelperICC2int32Const(&(aTag.
sig ), icSigRedTRCTag);
01237
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01238
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01239 aProf->
tagList.
tags[5] = aTag;
01240
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaRed>>8) );
01241 currentSize += theTRCSize;
01242
01243
CMHelperICC2int32Const(&(aTag.
sig ), icSigGreenTRCTag);
01244
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01245
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01246 aProf->
tagList.
tags[6] = aTag;
01247
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaGreen>>8) );
01248 currentSize += theTRCSize;
01249
01250
CMHelperICC2int32Const(&(aTag.
sig ), icSigBlueTRCTag);
01251
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01252
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01253 aProf->
tagList.
tags[7] = aTag;
01254
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaBlue>>8) );
01255 currentSize += theTRCSize;
01256
01257
CMHelperICC2int32Const(&(aTag.
sig ), icSigCopyrightTag);
01258
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01259
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01260 aProf->
tagList.
tags[8] = aTag;
01261 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((Ptr)aProf+currentSize));
01262
if (err)
01263
goto CleanupAndExit;
01264 currentSize += theCopyRightSize;
01265
01266 *theProf = aProf;
01267
#ifdef WRITE_PROFILE
01268
WriteProf(
"MyNewAbstractW.pf", aProf, currentSize );
01269
#endif
01270
return noErr;
01271
01272 CleanupAndExit:
01273
if( aProf )GlobalFreePtr( aProf );
01274
return err;
01275 }
01276
#endif
01277
01278 #define MyTagCountLink 5
01279 #define LINK_BUFFER_MAX 3000
01280
01281 CMError DeviceLinkFill( CMMModelPtr cw,
01282
CMConcatProfileSet *profileSet,
01283
icProfile **theProf,
01284
unsigned long aIntent )
01285 {
01286
CMError err =
unimpErr;
01287
OSErr aOSerr =
unimpErr;
01288
#ifdef __MWERKS__
01289
unsigned char theText[] =
"\pDeviceLink profile ";
01290
char copyrightText[] =
"\p�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01291
#elif __IS_MSDOS
01292
char theText[] =
"\030DeviceLink profile ";
01293
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01294
#else
01295
char theText[] =
"\030DeviceLink profile ";
01296
char copyrightText[] =
"\060�1996 by Heidelberger Druckmaschinen AG U.J.K.";
01297
#endif
01298
icProfile *aProf=0;
01299
long theTagTabSize;
01300
long theHeaderSize;
01301
long theDescSize;
01302
long theMediaSize;
01303
long theSequenceDescSize;
01304
long theA2B0Size;
01305
long theCopyRightSize;
01306
long currentSize=0;
01307
long theTotalSize=0;
01308
icTag aTag;
01309
UINT32 sCS,dCS,clutSize;
01310
Ptr aPtr=0;
01311
01312
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
01313
MyXYZNumber D50 = { (
unsigned long)(0.9642 * 65536), (
unsigned long)(1.0000 * 65536), (
unsigned long)(0.8249 * 65536)};
01314 theHeaderSize =
sizeof(
icHeader);
01315 theDescSize =
sizeof(
OSType)
01316 +
sizeof(
unsigned long)
01317 +
sizeof(
unsigned long)
01318 + theText[0]
01319 +
sizeof(
unsigned long)
01320 +
sizeof(
unsigned long)
01321 +
sizeof(
unsigned short)
01322 +
sizeof(
unsigned char)
01323 + 67
01324 ;
01325 theCopyRightSize =
sizeof(
OSType)
01326 +
sizeof(
unsigned long)
01327 + copyrightText[0]
01328 ;
01329 theMediaSize =
sizeof(
icXYZType );;
01330
01331 theTagTabSize =
MyTagCountLink *
sizeof(
icTag ) +
sizeof(
unsigned long );
01332
01333 *theProf = 0;
01334
01335
if( cw->hasNamedColorProf !=
NoNamedColorProfile ){
01336 err =
cmProfileError;
01337
goto CleanupAndExit;
01338 }
01339 err =
MyGetColorSpaces( profileSet, &sCS, &dCS );
01340
if (err)
01341
goto CleanupAndExit;
01342
01343 aProf = (
icProfile *)
SmartNewPtrClear(
LINK_BUFFER_MAX, &aOSerr );
01344 err = aOSerr;
01345
if (err)
01346
goto CleanupAndExit;
01347
01348 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((
Ptr)aProf+currentSize), aIntent,
icSigLinkClass, sCS, dCS );
01349
if (err)
01350
goto CleanupAndExit;
01351
01352
01353 currentSize = theHeaderSize + theTagTabSize;
01354
CMHelperICC2int32Const(&(aProf->
tagList.
count ),
MyTagCountLink);
01355
01356
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileDescriptionTag);
01357
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01358
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01359 aProf->
tagList.
tags[0] = aTag;
01360 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((
Ptr)aProf+currentSize), (
unsigned char *)theText );
01361
if (err)
01362
goto CleanupAndExit;
01363 currentSize += theDescSize;
01364 currentSize = ( currentSize + 3 ) & ~ 3;
01365
01366
CMHelperICC2int32Const(&(aTag.
sig ),
icSigMediaWhitePointTag);
01367
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01368
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01369 aProf->
tagList.
tags[1] = aTag;
01370
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &D50);
01371 currentSize += theMediaSize;
01372 currentSize = ( currentSize + 3 ) & ~ 3;
01373
01374
CMHelperICC2int32Const(&(aTag.
sig ),
icSigCopyrightTag);
01375
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01376
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01377 aProf->
tagList.
tags[2] = aTag;
01378 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((
Ptr)aProf+currentSize));
01379
if (err)
01380
goto CleanupAndExit;
01381 currentSize += theCopyRightSize;
01382 currentSize = ( currentSize + 3 ) & ~ 3;
01383
01384 err =
MyAdd_NL_SequenceDescTag( profileSet, (
icProfileSequenceDescType *)((
Ptr)aProf+currentSize), &theSequenceDescSize );
01385
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileSequenceDescTag);
01386
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01387
CMHelperICC2int32Const(&(aTag.
size ), theSequenceDescSize);
01388 aProf->
tagList.
tags[3] = aTag;
01389 currentSize += theSequenceDescSize;
01390 currentSize = ( currentSize + 3 ) & ~ 3;
01391
01392 theA2B0Size =
GetSizes( (
CMMModelPtr)cw, &clutSize );
01393
01394
CMHelperICC2int32Const(&(aTag.
sig ),
icSigAToB0Tag);
01395
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01396
CMHelperICC2int32Const(&(aTag.
size ), theA2B0Size);
01397 aProf->
tagList.
tags[4] = aTag;
01398
01399
#if __IS_MSDOS
01400
aPtr = GlobalAllocPtr( GHND, theA2B0Size+currentSize );
01401
if( aPtr == 0 ){
01402 err = GetLastError();
01403
goto CleanupAndExit;
01404 }
01405
#else
01406
aPtr =
SmartNewPtr( theA2B0Size+currentSize, &aOSerr );
01407 err = aOSerr;
01408
if( err ){
01409
goto CleanupAndExit;
01410 }
01411
#endif
01412
01413
01414
if ( cw->lutParam.colorLutWordSize == 8 )
01415 err =
MyAdd_NL_AToB0Tag_mft1( (
CMMModelPtr)cw, (
icLut8Type *)(aPtr+currentSize), clutSize );
01416
else
01417 err =
MyAdd_NL_AToB0Tag_mft2( (
CMMModelPtr)cw, (
icLut16Type *)(aPtr+currentSize), clutSize );
01418
01419
if (err)
01420
goto CleanupAndExit;
01421
01422
BlockMove( (
Ptr)aProf, aPtr, currentSize );
01423 aProf = (
icProfile *)
DisposeIfPtr( (
Ptr)aProf );
01424
01425
CMHelperICC2int32Const( aPtr, theA2B0Size+currentSize );
01426
01427 *theProf = (
icProfile *)aPtr;
01428
#ifdef WRITE_PROFILE
01429
WriteProf(
"DeviceLinkFill.pf", (
icProfile *)aPtr, theA2B0Size+currentSize );
01430
#endif
01431
return noErr;
01432
01433 CleanupAndExit:
01434 *theProf = (
icProfile *)
DisposeIfPtr( (
Ptr)aProf );
01435
#if __IS_MSDOS
01436
if( aPtr )GlobalFreePtr( aPtr );
01437
#else
01438
aPtr =
DisposeIfPtr( (
Ptr)aPtr );
01439
#endif
01440
return err;
01441 }
01442
01443