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
short step = numOfAlutEntries / 256;
00357
00358
for (i=0; i<(
long)lutPtr->
outputChan; i++)
00359 {
00360
for (j=0; j<256; j++)
00361 {
00362 byteAlut = (
UINT8*)theAlut + (j * (numOfAlutEntries-1)) / 255 ;
00363 lutPtr->
data[offset + i * 256 + j] = *byteAlut;
00364 }
00365 theAlut += numOfAlutEntries;
00366 }
00367
return err;
00368 }
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
CMError Fill_mft2_InputTable( Ptr theElut,
00388
icLut16* lutPtr,
00389 CMMModelPtr modelData);
00390
CMError Fill_mft2_InputTable( Ptr theElut,
00391
icLut16* lutPtr,
00392 CMMModelPtr modelData)
00393 {
00394
OSErr err =
noErr;
00395
unsigned long factor;
00396
unsigned long round;
00397
unsigned long shift;
00398
unsigned long ulAux;
00399
long i;
00400
long j;
00401
UINT16* wordElut = (
UINT16*)theElut;
00402
UINT16* wordData = (
UINT16*)lutPtr->
data;
00403
unsigned long newScale = 65535;
00404
00405
unsigned long oldScale = ( (1<<modelData->lutParam.inputLutWordSize) * (modelData->lutParam.colorLutGridPoints-1)) / modelData->lutParam.colorLutGridPoints;
00406
00407
if( modelData->currentCall ==
kCMMNewLinkProfile ){
00408 oldScale = 1<< modelData->lutParam.inputLutWordSize;
00409 }
00410 factor = (newScale << 15) / oldScale;
00411 round = (1<<(15-1))-1;
00412 shift = 15;
00413
00414
while (factor & 0xFFFF0000)
00415 {
00416 factor >>= 1;
00417 round >>= 1;
00418 shift -= 1;
00419 }
00420
00421
for (i=0; i<(
long)lutPtr->
inputChan; i++)
00422 {
00423
for (j=0; j< (
long)lutPtr->
inputEnt; j++)
00424 {
00425 ulAux = ((
unsigned long)*wordElut * factor + round) >> shift;
00426
CMHelperICC2int16Const( wordData, ulAux );
00427 wordData++;
00428 wordElut++;
00429 }
00430 }
00431
return err;
00432 }
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
CMError Fill_mft2_OutputTable( Ptr theAlut,
00453
icLut16* lutPtr,
00454
long offset,
00455 CMMModelPtr modelData );
00456
CMError Fill_mft2_OutputTable( Ptr theAlut,
00457
icLut16* lutPtr,
00458
long offset,
00459 CMMModelPtr modelData )
00460 {
00461
OSErr err =
noErr;
00462
long i;
00463
long j;
00464
UINT16* wordAlut = (
UINT16*)theAlut;
00465
UINT16* wordData = (
UINT16*)lutPtr->
data + offset;
00466
00467 modelData = modelData;
00468
for (i=0; i<(
long)lutPtr->
outputChan; i++)
00469 {
00470
for (j=0; j<(
long)lutPtr->
outputEnt; j++)
00471 {
00472
CMHelperICC2int16Const( wordData, *wordAlut );
00473 wordData++;
00474 wordAlut++;
00475 }
00476 }
00477
return err;
00478 }
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
CMError Fill_mft2_ColorTable( Ptr theClut,
00500
icLut16* lutPtr,
00501
long offset,
00502
long count );
00503
CMError Fill_mft2_ColorTable( Ptr theClut,
00504
icLut16* lutPtr,
00505
long offset,
00506
long count )
00507 {
00508
OSErr err =
noErr;
00509
long i;
00510
UINT16* wordClut = (
UINT16*)theClut;
00511
UINT16* wordData = (
UINT16*)lutPtr->
data + offset;
00512
00513
for ( i=0; i<count; i++)
00514 {
00515
CMHelperICC2int16Const( wordData, *wordClut );
00516 wordData++;
00517 wordClut++;
00518 }
00519
return err;
00520 }
00521
00522 CMError MyAdd_NL_AToB0Tag_mft1( CMMModelPtr cw,
icLut8Type *lutPtr,
long colorLutSize )
00523 {
00524
CMError err;
00525
icLut8 *tempLutPtr;
00526
long offset;
00527
UINT16 inputChannels;
00528
UINT16 outputChannels;
00529
UINT16 gridPoints;
00530
00531
LH_START_PROC(
"Add_NL_AToB0Tag_mft1")
00532
00533
LOCK_DATA(cw->lutParam.inputLut);
00534
LOCK_DATA(cw->lutParam.colorLut);
00535
LOCK_DATA(cw->lutParam.outputLut);
00536
00537 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00538 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00539 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00540
00541 tempLutPtr = &lutPtr->
lut;
00542
CMHelperICC2int32Const(&(lutPtr->
base ),
icSigLut8Type);
00543
CMHelperICC2int32Const((
OSType*)&(lutPtr->
base )+1, 0);
00544 tempLutPtr->
inputChan = (
UINT8)inputChannels;
00545 tempLutPtr->
outputChan = (
UINT8)outputChannels;
00546 tempLutPtr->
clutPoints = (
UINT8)gridPoints;
00547 tempLutPtr->
e00 = tempLutPtr->
e01 = tempLutPtr->
e02 = 0;
00548 tempLutPtr->
e10 = tempLutPtr->
e11 = tempLutPtr->
e12 = 0;
00549 tempLutPtr->
e20 = tempLutPtr->
e21 = tempLutPtr->
e22 = 0;
00550
CMHelperICC2int32Const(&(tempLutPtr->
e00 ), 0x10000);
00551
CMHelperICC2int32Const(&(tempLutPtr->
e11 ), 0x10000);
00552
CMHelperICC2int32Const(&(tempLutPtr->
e22 ), 0x10000);
00553
00554 err =
Fill_mft1_InputTable((
Ptr)
DATA_2_PTR(cw->lutParam.inputLut), tempLutPtr, cw);
00555
if (err)
00556
goto CleanupAndExit;
00557
00558 offset = 256 * inputChannels;
00559
BlockMoveData(
DATA_2_PTR(cw->lutParam.colorLut), & tempLutPtr->
data[0] + offset, colorLutSize);
00560
00561 offset = offset + colorLutSize;
00562 err =
Fill_mft1_OutputTable((
Ptr)
DATA_2_PTR(cw->lutParam.outputLut), tempLutPtr, offset, cw);
00563
if (err)
00564
goto CleanupAndExit;
00565
00566 CleanupAndExit:
00567
00568
#ifdef DEBUG_OUTPUT
00569
if ( err )
00570
DebugPrint(
"¥ MyAdd_NL_AToB0Tag_mft1-Error: result = %d\n",err);
00571
#endif
00572
UNLOCK_DATA(cw->lutParam.inputLut);
00573
UNLOCK_DATA(cw->lutParam.colorLut);
00574
UNLOCK_DATA(cw->lutParam.outputLut);
00575
LH_END_PROC(
"Add_NL_AToB0Tag_mft1")
00576
return err;
00577 }
00578
00579
UINT32 GetSizes( CMMModelPtr cw, UINT32 *clutSize );
00580
UINT32 GetSizes( CMMModelPtr cw, UINT32 *clutSize )
00581 {
00582
UINT16 inputChannels;
00583
UINT16 outputChannels;
00584
UINT16 gridPoints;
00585
SINT32 colorLutSize;
00586
UINT32 i,theSize;
00587
00588
LOCK_DATA(cw->lutParam.inputLut);
00589
LOCK_DATA(cw->lutParam.colorLut);
00590
LOCK_DATA(cw->lutParam.outputLut);
00591
00592 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00593 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00594 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00595
00596 colorLutSize = outputChannels;
00597
for(i = 0; i < inputChannels; i++)
00598 colorLutSize *= gridPoints;
00599
00600
if ( cw->lutParam.colorLutWordSize != 8){
00601 theSize =
sizeof(
OSType) +
sizeof(
UINT32) + (4 *
sizeof(
UINT8)) + (9 *
sizeof(
Fixed))
00602 + 2 *
sizeof(
icUInt16Number)
00603 + (inputChannels * cw->lutParam.inputLutEntryCount *
sizeof(
UINT16))
00604 + (outputChannels * cw->lutParam.outputLutEntryCount *
sizeof(
UINT16))
00605 + colorLutSize *
sizeof(
UINT16);
00606 }
00607
else{
00608 theSize =
sizeof(
OSType) +
sizeof(
UINT32) + (4 *
sizeof(
UINT8)) + (9 *
sizeof(
Fixed))
00609 + (inputChannels * 256 *
sizeof(
UINT8))
00610 + (outputChannels * 256 *
sizeof(
UINT8))
00611 + colorLutSize;
00612 }
00613 *clutSize = colorLutSize;
00614
UNLOCK_DATA(cw->lutParam.inputLut);
00615
UNLOCK_DATA(cw->lutParam.colorLut);
00616
UNLOCK_DATA(cw->lutParam.outputLut);
00617
return theSize;
00618 }
00619
00620 CMError MyAdd_NL_AToB0Tag_mft2( CMMModelPtr cw,
icLut16Type *lutPtr,
long colorLutSize )
00621 {
00622
CMError err;
00623
icLut16 *tempLutPtr;
00624
long offset;
00625
UINT16 inputChannels;
00626
UINT16 outputChannels;
00627
UINT16 gridPoints;
00628
00629
LH_START_PROC(
"Add_NL_AToB0Tag_mft2")
00630
00631
LOCK_DATA(cw->lutParam.inputLut);
00632
LOCK_DATA(cw->lutParam.colorLut);
00633
LOCK_DATA(cw->lutParam.outputLut);
00634
00635 inputChannels = (
UINT16)cw->lutParam.colorLutInDim;
00636 outputChannels = (
UINT16)cw->lutParam.colorLutOutDim;
00637 gridPoints = (
UINT16)cw->lutParam.colorLutGridPoints;
00638
00639 tempLutPtr = &lutPtr->
lut;
00640
CMHelperICC2int32Const(&(lutPtr->
base ),
icSigLut16Type);
00641
CMHelperICC2int32Const((
OSType*)&(lutPtr->
base )+1, 0);
00642 tempLutPtr->
inputChan = (
UINT8)inputChannels;
00643 tempLutPtr->
outputChan = (
UINT8)outputChannels;
00644 tempLutPtr->
clutPoints = (
UINT8)((gridPoints>255)?255:gridPoints);
00645 tempLutPtr->
e00 = tempLutPtr->
e01 = tempLutPtr->
e02 = 0;
00646 tempLutPtr->
e10 = tempLutPtr->
e11 = tempLutPtr->
e12 = 0;
00647 tempLutPtr->
e20 = tempLutPtr->
e21 = tempLutPtr->
e22 = 0;
00648
CMHelperICC2int32Const(&(tempLutPtr->
e00 ), 0x10000);
00649
CMHelperICC2int32Const(&(tempLutPtr->
e11 ), 0x10000);
00650
CMHelperICC2int32Const(&(tempLutPtr->
e22 ), 0x10000);
00651
00652 tempLutPtr->
inputEnt = (
UINT16)cw->lutParam.inputLutEntryCount;
00653 tempLutPtr->
outputEnt = (
UINT16)cw->lutParam.outputLutEntryCount;
00654 err =
Fill_mft2_InputTable((
Ptr)
DATA_2_PTR(cw->lutParam.inputLut), tempLutPtr, cw);
00655
if (err)
00656
goto CleanupAndExit;
00657
00658 offset = cw->lutParam.inputLutEntryCount * inputChannels;
00659
Fill_mft2_ColorTable( (
Ptr)
DATA_2_PTR(cw->lutParam.colorLut), tempLutPtr, offset, colorLutSize);
00660
00661 offset = offset + colorLutSize;
00662 err =
Fill_mft2_OutputTable((
Ptr)
DATA_2_PTR(cw->lutParam.outputLut), tempLutPtr, offset, cw);
00663
if (err)
00664
goto CleanupAndExit;
00665
00666
CMHelperICC2int16Const(&(tempLutPtr->
inputEnt ), (
UINT16)cw->lutParam.inputLutEntryCount);
00667
CMHelperICC2int16Const(&(tempLutPtr->
outputEnt ), (
UINT16)cw->lutParam.outputLutEntryCount);
00668
00669 CleanupAndExit:
00670
00671
#ifdef DEBUG_OUTPUT
00672
if ( err )
00673
DebugPrint(
"¥ MyAdd_NL_AToB0Tag_mft2-Error: result = %d\n",err);
00674
#endif
00675
UNLOCK_DATA(cw->lutParam.inputLut);
00676
UNLOCK_DATA(cw->lutParam.colorLut);
00677
UNLOCK_DATA(cw->lutParam.outputLut);
00678
LH_END_PROC(
"Add_NL_AToB0Tag_mft2")
00679
return err;
00680 }
00681
00682
CMError MyGetColorSpaces(
CMConcatProfileSet *profileSet,
00683 UINT32 *sCS,
00684 UINT32 *dCS );
00685
CMError MyGetColorSpaces(
CMConcatProfileSet *profileSet,
00686 UINT32 *sCS,
00687 UINT32 *dCS )
00688 {
00689
CMError err;
00690
icHeader profHeader;
00691
00692
LH_START_PROC(
"MyGetColorSpaces")
00693
00694 err = CMGetProfileHeader(profileSet->profileSet[0], (
CMCoreProfileHeader *)&profHeader);
00695 if (err)
00696 goto CleanupAndExit;
00697 *sCS = profHeader.colorSpace;
00698
00699 err = CMGetProfileHeader(profileSet->profileSet[profileSet->count-1], (
CMCoreProfileHeader *)&profHeader);
00700 if (err)
00701 goto CleanupAndExit;
00702 *dCS = profHeader.colorSpace;
00703
00704 CleanupAndExit:
00705 LH_END_PROC("MyAdd_NL_SequenceDescTag")
00706 return err;
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 CMError MyAdd_NL_SequenceDescTag(
CMConcatProfileSet *profileSet,
00726
icProfileSequenceDescType *pSeqPtr,
00727
long *aSize )
00728 {
00729
CMError err;
00730
OSErr aOSerr;
00731
00732
Ptr thePtr =
nil;
00733
icHeader profHeader;
00734
SINT32 loop;
00735
OSType technology;
00736
UINT32 elementSize;
00737
icSignatureType theSignature;
00738
icTextDescriptionType* descPtr =
nil;
00739
char descPtrNull[90]={0};
00740
00741
LH_START_PROC(
"MyAdd_NL_SequenceDescTag")
00742
00743
CMHelperICC2int32Const(&(((
icTextDescriptionType*)descPtrNull)->base ),
icSigTextDescriptionType );
00744
CMHelperICC2int32Const(((
OSType*)&((
icTextDescriptionType*)descPtrNull)->base )+1, 0);
00745
CMHelperICC2int32Const(&(((icTextDescriptionType*)descPtrNull)->desc.count ), 1 );
00746
00747
00748
00749
00750
CMHelperICC2int32Const(&(pSeqPtr->base ),
icSigProfileSequenceDescType);
00751
CMHelperICC2int32Const((
OSType*)&(pSeqPtr->base )+1, 0);
00752
CMHelperICC2int32Const(&(pSeqPtr->desc.count ), profileSet->count );
00753 thePtr = (
Ptr)( (SIZE_T)&(pSeqPtr->desc.count) +
sizeof(
SINT32) ) ;
00754
00755
for (loop = 0; loop < (
SINT32)profileSet->count; loop++)
00756 {
00757 err =
CMGetProfileHeader(profileSet->profileSet[loop], (
CMCoreProfileHeader *)&profHeader);
00758
if (err)
00759
goto CleanupAndExit;
00760
CMHelperICC2int32Const(thePtr, profHeader.
manufacturer);
00761 thePtr +=
sizeof(
OSType);
00762
CMHelperICC2int32Const(thePtr, profHeader.
model);
00763 thePtr +=
sizeof(
OSType);
00764
CMHelperICC2int32Const(thePtr, profHeader.
attributes[0]);
00765 thePtr +=
sizeof(
UINT32);
00766
CMHelperICC2int32Const(thePtr, profHeader.
attributes[1]);
00767 thePtr +=
sizeof(
UINT32);
00768
00769
00770 technology = 0;
00771
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigTechnologyTag, &elementSize,
nil) ==
noErr)
00772 {
00773
if (elementSize ==
sizeof(
icSigTechnologyTag))
00774 {
00775
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigTechnologyTag, &elementSize, &theSignature) ==
noErr)
00776 technology = theSignature.
signature;
00777 }
00778 }
00779 *((
OSType*)thePtr) = technology;
00780 thePtr +=
sizeof(
OSType);
00781
00782
00783
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigDeviceMfgDescTag, &elementSize,
nil) ==
noErr)
00784 {
00785 descPtr = (icTextDescriptionType*)
SmartNewPtr(elementSize,&aOSerr);
00786 err = aOSerr;
00787
if (err)
00788
goto CleanupAndExit;
00789
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigDeviceMfgDescTag, &elementSize, descPtr) ==
noErr)
00790 {
00791
BlockMoveData( descPtr, thePtr, elementSize);
00792 thePtr += elementSize;
00793 }
00794 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00795 }
else
00796 {
00797
BlockMoveData( descPtrNull, thePtr,
sizeof(descPtrNull));
00798 thePtr +=
sizeof(descPtrNull);
00799 }
00800
00801
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigDeviceModelDescTag, &elementSize,
nil) ==
noErr)
00802 {
00803 descPtr = (icTextDescriptionType*)
SmartNewPtr(elementSize,&aOSerr);
00804 err = aOSerr;
00805
if (err)
00806
goto CleanupAndExit;
00807
if (
CMGetProfileElement(profileSet->profileSet[loop],
icSigDeviceModelDescTag, &elementSize, descPtr) ==
noErr)
00808 {
00809
BlockMoveData( descPtr, thePtr, elementSize);
00810 thePtr += elementSize;
00811 }
00812 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00813 }
else
00814 {
00815
BlockMoveData( descPtrNull, thePtr,
sizeof(descPtrNull));
00816 thePtr +=
sizeof(descPtrNull);
00817 }
00818
00819 }
00820
00821
00822 *aSize = (LONG)((ULONG_PTR)thePtr - (ULONG_PTR)pSeqPtr);
00823
00824 CleanupAndExit:
00825 descPtr = (icTextDescriptionType*)
DisposeIfPtr((
Ptr)descPtr);
00826
LH_END_PROC(
"MyAdd_NL_SequenceDescTag")
00827
return err;
00828 }
00829
00830
00831
MyXYZNumber MakeXYZNumber(
MyXYZNumber *x );
00832
MyXYZNumber MakeXYZNumber(
MyXYZNumber *x )
00833 {
00834
MyXYZNumber ret;
00835 ret.
X = x->
X>>14;
00836 ret.
Y = x->
Y>>14;
00837 ret.
Z = x->
Z>>14;
00838
return ret;
00839 }
00840
00841
void MakeMyDoubleXYZ(
MyXYZNumber *x,
MyDoubleXYZ *ret );
00842
void MakeMyDoubleXYZ(
MyXYZNumber *x,
MyDoubleXYZ *ret )
00843 {
00844 ret->
X = x->
X/(
double)(1<<30);
00845 ret->
Y = x->
Y/(
double)(1<<30);
00846 ret->
Z = x->
Z/(
double)(1<<30);
00847 }
00848
Boolean doubMatrixInvert(
double inpMat[3][3],
00849
double outMat[3][3] );
00850
void TransposeMatrix(
double inpMat[3][3] );
00851
void TransposeMatrix(
double inpMat[3][3] )
00852 {
00853
long i,j;
00854
double sav;
00855
for( i=0; i< 3; i++ ){
00856
for( j=i+1; j< 3; j++ ){
00857 sav = inpMat[i][j];
00858 inpMat[i][j] = inpMat[j][i];
00859 inpMat[j][i] = sav;
00860 }
00861 }
00862
00863 }
00864 #define Round(a) (((a)>0.)?((a)+.5):((a)-.5))
00865
00866
double GetMatrixedVal(
double m[3][3],
long color,
MyDoubleXYZ *aXYZ );
00867
double GetMatrixedVal(
double m[3][3],
long color,
MyDoubleXYZ *aXYZ )
00868 {
00869
double tmp;
00870 tmp = m[color][0] * aXYZ->
X;
00871 tmp+= m[color][1] * aXYZ->
Y;
00872 tmp+= m[color][2] * aXYZ->
Z;
00873
return tmp;
00874 }
00875
00876
void NormalizeColor(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB );
00877
void NormalizeColor(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB )
00878 {
00879
double factorX,factorY,factorZ;
00880
double inMat[3][3];
00881
00882
MakeMyDoubleXYZ( r, (
MyDoubleXYZ*)&inMat[0][0] );
00883
MakeMyDoubleXYZ( g, (
MyDoubleXYZ*)&inMat[1][0] );
00884
MakeMyDoubleXYZ( b, (
MyDoubleXYZ*)&inMat[2][0] );
00885
00886 factorX = inMat[0][0] + inMat[1][0] + inMat[2][0];
00887 factorY = inMat[0][1] + inMat[1][1] + inMat[2][1];
00888 factorZ = inMat[0][2] + inMat[1][2] + inMat[2][2];
00889
00890 factorX = Illuminant->
X / factorX * 65536;
00891 factorY = Illuminant->
Y / factorY * 65536;
00892 factorZ = Illuminant->
Z / factorZ * 65536;
00893
00894 resR->
X = (
long)
Round(inMat[0][0] * factorX);
00895 resR->
Y = (
long)
Round(inMat[0][1] * factorY);
00896 resR->
Z = (
long)
Round(inMat[0][2] * factorZ);
00897 resG->
X = (
long)
Round(inMat[1][0] * factorX);
00898 resG->
Y = (
long)
Round(inMat[1][1] * factorY);
00899 resG->
Z = (
long)
Round(inMat[1][2] * factorZ);
00900 resB->
X = (
long)
Round(inMat[2][0] * factorX);
00901 resB->
Y = (
long)
Round(inMat[2][1] * factorY);
00902 resB->
Z = (
long)
Round(inMat[2][2] * factorZ);
00903 }
00904
00905
void NormalizeWithWhiteAdaption(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB );
00906
void NormalizeWithWhiteAdaption(
MyXYZNumber *r,
MyXYZNumber *g,
MyXYZNumber *b,
MyDoubleXYZ *Illuminant,
MyXYZNumber *resR,
MyXYZNumber *resG,
MyXYZNumber *resB )
00907 {
00908
double factorR,factorG,factorB;
00909
double inMat[3][3];
00910
double outMat[3][3];
00911
00912
MakeMyDoubleXYZ( r, (
MyDoubleXYZ*)&inMat[0][0] );
00913
MakeMyDoubleXYZ( g, (
MyDoubleXYZ*)&inMat[1][0] );
00914
MakeMyDoubleXYZ( b, (
MyDoubleXYZ*)&inMat[2][0] );
00915
00916
if( !
doubMatrixInvert(inMat, outMat) )
00917 {
00918
return ;
00919 }
00920
00921
TransposeMatrix( outMat );
00922
00923 factorR =
GetMatrixedVal( outMat, 0, Illuminant )*65536;
00924 factorG =
GetMatrixedVal( outMat, 1, Illuminant )*65536;
00925 factorB =
GetMatrixedVal( outMat, 2, Illuminant )*65536;
00926
00927 resR->
X = (
long)
Round(inMat[0][0] * factorR);
00928 resR->
Y = (
long)
Round(inMat[0][1] * factorR);
00929 resR->
Z = (
long)
Round(inMat[0][2] * factorR);
00930 resG->
X = (
long)
Round(inMat[1][0] * factorG);
00931 resG->
Y = (
long)
Round(inMat[1][1] * factorG);
00932 resG->
Z = (
long)
Round(inMat[1][2] * factorG);
00933 resB->
X = (
long)
Round(inMat[2][0] * factorB);
00934 resB->
Y = (
long)
Round(inMat[2][1] * factorB);
00935 resB->
Z = (
long)
Round(inMat[2][2] * factorB);
00936 }
00937
00938
#ifdef WRITE_PROFILE
00939
void WriteProf( Ptr name,
icProfile *theProf,
long currentSize );
00940
#endif
00941
00942 #define MyTagCount 9
00943
00944
#if __IS_MSDOS && defined(RenderInt)
00945
CMError MyNewAbstract( LPLOGCOLORSPACEA lpColorSpace,
icProfile **theProf )
00946 {
00947
CMError err =
unimpErr;
00948
OSErr aOSerr =
unimpErr;
00949
#ifdef __MWERKS__
00950
unsigned char theText[] =
"\pLogColorSpProfile ";
00951
char copyrightText[] =
"\p©1996 by Heidelberger Druckmaschinen AG U.J.K.";
00952
#elif __IS_MSDOS
00953
char theText[] =
"\030LogColorSpProfile ";
00954
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
00955
#else
00956
char theText[] =
"\030LogColorSpProfile ";
00957
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
00958
#endif
00959
icProfile *aProf=0;
00960
long theTagTabSize;
00961
long theHeaderSize;
00962
long theDescSize;
00963
long theMediaSize;
00964
long theEndPointSize;
00965
long theTRCSize;
00966
long theCopyRightSize;
00967
long currentSize=0;
00968
long theTotalSize=0;
00969
icTag aTag;
00970
unsigned long aIntent;
00971
00972
MyXYZNumber rXYZ,gXYZ,bXYZ;
00973
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
00974
MyXYZNumber D50 = { (
unsigned long)(D50XYZ.
X * 65536), (
unsigned long)(D50XYZ.
Y * 65536), (
unsigned long)(D50XYZ.
Z * 65536)};
00975 theHeaderSize =
sizeof(
icHeader);
00976 theDescSize =
sizeof(
OSType)
00977 +
sizeof(
unsigned long)
00978 +
sizeof(
unsigned long)
00979 + theText[0]
00980 +
sizeof(
unsigned long)
00981 +
sizeof(
unsigned long)
00982 +
sizeof(
unsigned short)
00983 +
sizeof(
unsigned char)
00984 + 67
00985 ;
00986 theCopyRightSize =
sizeof(
OSType)
00987 +
sizeof(
unsigned long)
00988 + copyrightText[0]
00989 ;
00990 theMediaSize =
sizeof(
icXYZType );;
00991 theEndPointSize =
sizeof(
icXYZType );;
00992 theTRCSize = 4*((
sizeof(
icCurveType ) +3)/4);
00993
00994 theTagTabSize =
MyTagCount *
sizeof(
icTag ) +
sizeof(
unsigned long );
00995
00996 theTotalSize = theHeaderSize + theTagTabSize + theDescSize + theCopyRightSize
00997 + theMediaSize + 3*theEndPointSize + 3*theTRCSize;
00998 aProf = (
icProfile *)GlobalAllocPtr( GHND, theTotalSize );
00999
if( aProf == 0 ){
01000 err = GetLastError();
01001
goto CleanupAndExit;
01002 }
01003
01004
switch( lpColorSpace->lcsIntent ){
01005
case LCS_GM_BUSINESS:
01006 aIntent =
icSaturation;
01007
break;
01008
case LCS_GM_GRAPHICS:
01009 aIntent =
icRelativeColorimetric;
01010
break;
01011
case LCS_GM_ABS_COLORIMETRIC:
01012 aIntent =
icAbsoluteColorimetric;
01013
break;
01014
default:
01015 aIntent =
icPerceptual;
01016
break;
01017 }
01018 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((
Ptr)aProf+currentSize), aIntent,
icSigInputClass,
icSigRgbData,
icSigXYZData );
01019
if (err)
01020
goto CleanupAndExit;
01021
01022
01023 currentSize = theHeaderSize + theTagTabSize;
01024
CMHelperICC2int32Const(&(aProf->
tagList.
count ),
MyTagCount);
01025
01026
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileDescriptionTag);
01027
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01028
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01029 aProf->
tagList.
tags[0] = aTag;
01030 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((
Ptr)aProf+currentSize), (
unsigned char *)theText );
01031
if (err)
01032
goto CleanupAndExit;
01033 currentSize += theDescSize;
01034
01035
CMHelperICC2int32Const(&(aTag.
sig ),
icSigMediaWhitePointTag);
01036
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01037
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01038 aProf->
tagList.
tags[1] = aTag;
01039
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &D50);
01040 currentSize += theMediaSize;
01041
01042
NormalizeColor( (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzRed,
01043 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzGreen,
01044 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzBlue,
01045 &D50XYZ,
01046 &rXYZ,
01047 &gXYZ,
01048 &bXYZ );
01049
CMHelperICC2int32Const(&(aTag.
sig ),
icSigRedColorantTag);
01050
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01051
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01052 aProf->
tagList.
tags[2] = aTag;
01053
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &rXYZ );
01054 currentSize += theEndPointSize;
01055
01056
CMHelperICC2int32Const(&(aTag.
sig ),
icSigGreenColorantTag);
01057
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01058
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01059 aProf->
tagList.
tags[3] = aTag;
01060
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &gXYZ );
01061 currentSize += theEndPointSize;
01062
01063
CMHelperICC2int32Const(&(aTag.
sig ),
icSigBlueColorantTag);
01064
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01065
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01066 aProf->
tagList.
tags[4] = aTag;
01067
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &bXYZ );
01068 currentSize += theEndPointSize;
01069
01070
CMHelperICC2int32Const(&(aTag.
sig ),
icSigRedTRCTag);
01071
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01072
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01073 aProf->
tagList.
tags[5] = aTag;
01074
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaRed>>8) );
01075 currentSize += theTRCSize;
01076
01077
CMHelperICC2int32Const(&(aTag.
sig ),
icSigGreenTRCTag);
01078
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01079
CMHelperICC2int32Const(&(aTag.
size ),
sizeof( icCurveType ));
01080 aProf->
tagList.
tags[6] = aTag;
01081
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaGreen>>8) );
01082 currentSize += theTRCSize;
01083
01084
CMHelperICC2int32Const(&(aTag.
sig ),
icSigBlueTRCTag);
01085
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01086
CMHelperICC2int32Const(&(aTag.
size ),
sizeof( icCurveType ));
01087 aProf->
tagList.
tags[7] = aTag;
01088
MyAdd_NL_CurveTag((icCurveType *)((
Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaBlue>>8) );
01089 currentSize += theTRCSize;
01090
01091
CMHelperICC2int32Const(&(aTag.
sig ),
icSigCopyrightTag);
01092
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01093
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01094 aProf->
tagList.
tags[8] = aTag;
01095 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((
Ptr)aProf+currentSize));
01096
if (err)
01097
goto CleanupAndExit;
01098 currentSize += theCopyRightSize;
01099
01100 *theProf = aProf;
01101
#ifdef WRITE_PROFILE
01102
WriteProf(
"MyNewAbstract.pf", aProf, currentSize );
01103
#endif
01104
return noErr;
01105
01106 CleanupAndExit:
01107
if( aProf )GlobalFreePtr( aProf );
01108
return err;
01109 }
01110
01111
01112
CMError MyNewAbstractW( LPLOGCOLORSPACEW lpColorSpace,
icProfile **theProf )
01113 {
01114
CMError err =
unimpErr;
01115
OSErr aOSerr =
unimpErr;
01116
#ifdef __MWERKS__
01117
unsigned char theText[] =
"\pLogColorSpProfile ";
01118
char copyrightText[] =
"\p©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01119
#elif __IS_MSDOS
01120
char theText[] =
"\030LogColorSpProfile ";
01121
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01122
#else
01123
char theText[] =
"\030LogColorSpProfile ";
01124
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01125
#endif
01126
icProfile *aProf=0;
01127
long theTagTabSize;
01128
long theHeaderSize;
01129
long theDescSize;
01130
long theMediaSize;
01131
long theEndPointSize;
01132
long theTRCSize;
01133
long theCopyRightSize;
01134
long currentSize=0;
01135
long theTotalSize=0;
01136
icTag aTag;
01137
unsigned long aIntent;
01138
01139
MyXYZNumber rXYZ,gXYZ,bXYZ;
01140
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
01141
MyXYZNumber D50 = { (
unsigned long)(D50XYZ.
X * 65536), (
unsigned long)(D50XYZ.
Y * 65536), (
unsigned long)(D50XYZ.
Z * 65536)};
01142 theHeaderSize =
sizeof(
icHeader);
01143 theDescSize =
sizeof(
OSType)
01144 +
sizeof(
unsigned long)
01145 +
sizeof(
unsigned long)
01146 + theText[0]
01147 +
sizeof(
unsigned long)
01148 +
sizeof(
unsigned long)
01149 +
sizeof(
unsigned short)
01150 +
sizeof(
unsigned char)
01151 + 67
01152 ;
01153 theCopyRightSize =
sizeof(
OSType)
01154 +
sizeof(
unsigned long)
01155 + copyrightText[0]
01156 ;
01157 theMediaSize =
sizeof(
icXYZType );;
01158 theEndPointSize =
sizeof(
icXYZType );;
01159 theTRCSize = 4*((
sizeof(
icCurveType ) +3)/4);
01160
01161 theTagTabSize =
MyTagCount *
sizeof(
icTag ) +
sizeof(
unsigned long );
01162
01163 theTotalSize = theHeaderSize + theTagTabSize + theDescSize + theCopyRightSize
01164 + theMediaSize + 3*theEndPointSize + 3*theTRCSize;
01165 aProf = (
icProfile *)GlobalAllocPtr( GHND, theTotalSize );
01166
if( aProf == 0 ){
01167 err = GetLastError();
01168
goto CleanupAndExit;
01169 }
01170
01171
switch( lpColorSpace->lcsIntent ){
01172
case LCS_GM_BUSINESS:
01173 aIntent =
icSaturation;
01174
break;
01175
case LCS_GM_GRAPHICS:
01176 aIntent =
icRelativeColorimetric;
01177
break;
01178
case LCS_GM_GRAPHICS+1:
01179 aIntent =
icAbsoluteColorimetric;
01180
break;
01181
default:
01182 aIntent =
icPerceptual;
01183
break;
01184 }
01185 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((Ptr)aProf+currentSize), aIntent, icSigInputClass, icSigRgbData, icSigXYZData );
01186
if (err)
01187
goto CleanupAndExit;
01188
01189
01190 currentSize = theHeaderSize + theTagTabSize;
01191
CMHelperICC2int32Const(&(aProf->
tagList.
count ), MyTagCount);
01192
01193
CMHelperICC2int32Const(&(aTag.
sig ), icSigProfileDescriptionTag);
01194
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01195
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01196 aProf->
tagList.
tags[0] = aTag;
01197 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((Ptr)aProf+currentSize), (
unsigned char *)theText );
01198
if (err)
01199
goto CleanupAndExit;
01200 currentSize += theDescSize;
01201
01202
CMHelperICC2int32Const(&(aTag.
sig ), icSigMediaWhitePointTag);
01203
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01204
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01205 aProf->
tagList.
tags[1] = aTag;
01206
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &D50);
01207 currentSize += theMediaSize;
01208
01209
NormalizeColor( (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzRed,
01210 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzGreen,
01211 (
icXYZNumber*)&lpColorSpace->lcsEndpoints.ciexyzBlue,
01212 &D50XYZ,
01213 &rXYZ,
01214 &gXYZ,
01215 &bXYZ );
01216
CMHelperICC2int32Const(&(aTag.
sig ), icSigRedColorantTag);
01217
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01218
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01219 aProf->
tagList.
tags[2] = aTag;
01220
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &rXYZ );
01221 currentSize += theEndPointSize;
01222
01223
CMHelperICC2int32Const(&(aTag.
sig ), icSigGreenColorantTag);
01224
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01225
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01226 aProf->
tagList.
tags[3] = aTag;
01227
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &gXYZ );
01228 currentSize += theEndPointSize;
01229
01230
CMHelperICC2int32Const(&(aTag.
sig ), icSigBlueColorantTag);
01231
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01232
CMHelperICC2int32Const(&(aTag.
size ), theEndPointSize);
01233 aProf->
tagList.
tags[4] = aTag;
01234
MyAdd_NL_ColorantTag((
icXYZType *)((Ptr)aProf+currentSize), &bXYZ );
01235 currentSize += theEndPointSize;
01236
01237
CMHelperICC2int32Const(&(aTag.
sig ), icSigRedTRCTag);
01238
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01239
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01240 aProf->
tagList.
tags[5] = aTag;
01241
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaRed>>8) );
01242 currentSize += theTRCSize;
01243
01244
CMHelperICC2int32Const(&(aTag.
sig ), icSigGreenTRCTag);
01245
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01246
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01247 aProf->
tagList.
tags[6] = aTag;
01248
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaGreen>>8) );
01249 currentSize += theTRCSize;
01250
01251
CMHelperICC2int32Const(&(aTag.
sig ), icSigBlueTRCTag);
01252
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01253
CMHelperICC2int32Const(&(aTag.
size ),
sizeof(
icCurveType ));
01254 aProf->
tagList.
tags[7] = aTag;
01255
MyAdd_NL_CurveTag((
icCurveType *)((Ptr)aProf+currentSize), (
unsigned short)(lpColorSpace->lcsGammaBlue>>8) );
01256 currentSize += theTRCSize;
01257
01258
CMHelperICC2int32Const(&(aTag.
sig ), icSigCopyrightTag);
01259
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01260
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01261 aProf->
tagList.
tags[8] = aTag;
01262 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((Ptr)aProf+currentSize));
01263
if (err)
01264
goto CleanupAndExit;
01265 currentSize += theCopyRightSize;
01266
01267 *theProf = aProf;
01268
#ifdef WRITE_PROFILE
01269
WriteProf(
"MyNewAbstractW.pf", aProf, currentSize );
01270
#endif
01271
return noErr;
01272
01273 CleanupAndExit:
01274
if( aProf )GlobalFreePtr( aProf );
01275
return err;
01276 }
01277
#endif
01278
01279 #define MyTagCountLink 5
01280 #define LINK_BUFFER_MAX 3000
01281
01282 CMError DeviceLinkFill( CMMModelPtr cw,
01283
CMConcatProfileSet *profileSet,
01284
icProfile **theProf,
01285
unsigned long aIntent )
01286 {
01287
CMError err =
unimpErr;
01288
OSErr aOSerr =
unimpErr;
01289
#ifdef __MWERKS__
01290
unsigned char theText[] =
"\pDeviceLink profile ";
01291
char copyrightText[] =
"\p©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01292
#elif __IS_MSDOS
01293
char theText[] =
"\030DeviceLink profile ";
01294
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01295
#else
01296
char theText[] =
"\030DeviceLink profile ";
01297
char copyrightText[] =
"\060©1996 by Heidelberger Druckmaschinen AG U.J.K.";
01298
#endif
01299
icProfile *aProf=0;
01300
long theTagTabSize;
01301
long theHeaderSize;
01302
long theDescSize;
01303
long theMediaSize;
01304
long theSequenceDescSize;
01305
long theA2B0Size;
01306
long theCopyRightSize;
01307
long currentSize=0;
01308
long theTotalSize=0;
01309
icTag aTag;
01310
UINT32 sCS,dCS,clutSize;
01311
Ptr aPtr=0;
01312
01313
MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
01314
MyXYZNumber D50 = { (
unsigned long)(0.9642 * 65536), (
unsigned long)(1.0000 * 65536), (
unsigned long)(0.8249 * 65536)};
01315 theHeaderSize =
sizeof(
icHeader);
01316 theDescSize =
sizeof(
OSType)
01317 +
sizeof(
unsigned long)
01318 +
sizeof(
unsigned long)
01319 + theText[0]
01320 +
sizeof(
unsigned long)
01321 +
sizeof(
unsigned long)
01322 +
sizeof(
unsigned short)
01323 +
sizeof(
unsigned char)
01324 + 67
01325 ;
01326 theCopyRightSize =
sizeof(
OSType)
01327 +
sizeof(
unsigned long)
01328 + copyrightText[0]
01329 ;
01330 theMediaSize =
sizeof(
icXYZType );;
01331
01332 theTagTabSize =
MyTagCountLink *
sizeof(
icTag ) +
sizeof(
unsigned long );
01333
01334 *theProf = 0;
01335
01336
if( cw->hasNamedColorProf !=
NoNamedColorProfile ){
01337 err =
cmProfileError;
01338
goto CleanupAndExit;
01339 }
01340 err =
MyGetColorSpaces( profileSet, &sCS, &dCS );
01341
if (err)
01342
goto CleanupAndExit;
01343
01344 aProf = (
icProfile *)
SmartNewPtrClear(
LINK_BUFFER_MAX, &aOSerr );
01345 err = aOSerr;
01346
if (err)
01347
goto CleanupAndExit;
01348
01349 err =
MyAdd_NL_Header(theTotalSize, (
icHeader*)((
Ptr)aProf+currentSize), aIntent,
icSigLinkClass, sCS, dCS );
01350
if (err)
01351
goto CleanupAndExit;
01352
01353
01354 currentSize = theHeaderSize + theTagTabSize;
01355
CMHelperICC2int32Const(&(aProf->
tagList.
count ),
MyTagCountLink);
01356
01357
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileDescriptionTag);
01358
CMHelperICC2int32Const(&(aTag.
offset ), currentSize);
01359
CMHelperICC2int32Const(&(aTag.
size ), theDescSize);
01360 aProf->
tagList.
tags[0] = aTag;
01361 err =
MyAdd_NL_DescriptionTag ( (
LHTextDescriptionType *)((
Ptr)aProf+currentSize), (
unsigned char *)theText );
01362
if (err)
01363
goto CleanupAndExit;
01364 currentSize += theDescSize;
01365 currentSize = ( currentSize + 3 ) & ~ 3;
01366
01367
CMHelperICC2int32Const(&(aTag.
sig ),
icSigMediaWhitePointTag);
01368
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01369
CMHelperICC2int32Const(&(aTag.
size ), theMediaSize);
01370 aProf->
tagList.
tags[1] = aTag;
01371
MyAdd_NL_ColorantTag((
icXYZType *)((
Ptr)aProf+currentSize), &D50);
01372 currentSize += theMediaSize;
01373 currentSize = ( currentSize + 3 ) & ~ 3;
01374
01375
CMHelperICC2int32Const(&(aTag.
sig ),
icSigCopyrightTag);
01376
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01377
CMHelperICC2int32Const(&(aTag.
size ), theCopyRightSize);
01378 aProf->
tagList.
tags[2] = aTag;
01379 err =
MyAdd_NL_CopyrightTag( (
unsigned char *)copyrightText, (
LHTextType *)((
Ptr)aProf+currentSize));
01380
if (err)
01381
goto CleanupAndExit;
01382 currentSize += theCopyRightSize;
01383 currentSize = ( currentSize + 3 ) & ~ 3;
01384
01385 err =
MyAdd_NL_SequenceDescTag( profileSet, (
icProfileSequenceDescType *)((
Ptr)aProf+currentSize), &theSequenceDescSize );
01386
CMHelperICC2int32Const(&(aTag.
sig ),
icSigProfileSequenceDescTag);
01387
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01388
CMHelperICC2int32Const(&(aTag.
size ), theSequenceDescSize);
01389 aProf->
tagList.
tags[3] = aTag;
01390 currentSize += theSequenceDescSize;
01391 currentSize = ( currentSize + 3 ) & ~ 3;
01392
01393 theA2B0Size =
GetSizes( (
CMMModelPtr)cw, &clutSize );
01394
01395
CMHelperICC2int32Const(&(aTag.
sig ),
icSigAToB0Tag);
01396
CMHelperICC2int32Const(&(aTag.
offset ), currentSize );
01397
CMHelperICC2int32Const(&(aTag.
size ), theA2B0Size);
01398 aProf->
tagList.
tags[4] = aTag;
01399
01400
#if __IS_MSDOS
01401
aPtr = GlobalAllocPtr( GHND, theA2B0Size+currentSize );
01402
if( aPtr == 0 ){
01403 err = GetLastError();
01404
goto CleanupAndExit;
01405 }
01406
#else
01407
aPtr =
SmartNewPtr( theA2B0Size+currentSize, &aOSerr );
01408 err = aOSerr;
01409
if( err ){
01410
goto CleanupAndExit;
01411 }
01412
#endif
01413
01414
01415
if ( cw->lutParam.colorLutWordSize == 8 )
01416 err =
MyAdd_NL_AToB0Tag_mft1( (
CMMModelPtr)cw, (
icLut8Type *)(aPtr+currentSize), clutSize );
01417
else
01418 err =
MyAdd_NL_AToB0Tag_mft2( (
CMMModelPtr)cw, (
icLut16Type *)(aPtr+currentSize), clutSize );
01419
01420
if (err)
01421
goto CleanupAndExit;
01422
01423
BlockMove( (
Ptr)aProf, aPtr, currentSize );
01424 aProf = (
icProfile *)
DisposeIfPtr( (
Ptr)aProf );
01425
01426
CMHelperICC2int32Const( aPtr, theA2B0Size+currentSize );
01427
01428 *theProf = (
icProfile *)aPtr;
01429
#ifdef WRITE_PROFILE
01430
WriteProf(
"DeviceLinkFill.pf", (
icProfile *)aPtr, theA2B0Size+currentSize );
01431
#endif
01432
return noErr;
01433
01434 CleanupAndExit:
01435 *theProf = (
icProfile *)
DisposeIfPtr( (
Ptr)aProf );
01436
#if __IS_MSDOS
01437
if( aPtr )GlobalFreePtr( aPtr );
01438
#else
01439
aPtr =
DisposeIfPtr( (
Ptr)aPtr );
01440
#endif
01441
return err;
01442 }
01443
01444