00001
#include "generic.h"
00002
00003
#pragma code_seg(_ICM2SEG)
00004
#pragma optimize("",off)
00005
00006 #define TempBfSize 128
00007 #define LINELENG 128
00008
#ifdef ICMDLL
00009
#define ICM2SEG
00010
#endif
00011
00012 static char ICM2SEG
NewLine[] =
"\n" ;
00013 static char ICM2SEG
ASCII85DecodeBegine[] =
"<~";
00014 static char ICM2SEG
ASCII85DecodeEnd[] =
"~> cvx exec ";
00015
00016
00017
00018
00019 static SINT CPLastError;
00020
00021 BOOL EXTERN SetCPLastError(SINT LastError)
00022 {
00023
CPLastError = LastError;
00024
return(
TRUE);
00025 }
00026
00027 SINT EXTERN GetCPLastError()
00028 {
00029
return(
CPLastError);
00030 }
00031
00032 BOOL EXTERN MemAlloc(SINT Size, HGLOBAL FAR *hMemory, LPMEMPTR lpMH)
00033 {
00034 HGLOBAL hMem;
00035
LPVOID lpMem;
00036
00037 *hMemory = 0;
00038
if(lpMH ==
NULL )
00039 {
00040
SetCPLastError(
CP_NULL_POINTER_ERR);
00041
return(
FALSE);
00042 }
00043
00044 hMem = GlobalAlloc(GHND,
Size) ;
00045
if(hMem == 0 )
00046 {
00047
SetCPLastError(
CP_MEMORY_ALLOC_ERR);
00048
return(
FALSE);
00049 }
00050
00051 lpMem = GlobalLock(hMem);
00052
if(lpMem ==
NULL )
00053 {
00054 GlobalFree(hMem);
00055
SetCPLastError(
CP_MEMORY_ALLOC_ERR);
00056
return(
FALSE);
00057 }
00058 *lpMH = (
MEMPTR)lpMem ;
00059 *hMemory = hMem;
00060
return (
TRUE);
00061 }
00062
00063 BOOL EXTERN MemFree(HGLOBAL hMem)
00064 {
00065
if(hMem ==
NULL )
00066 {
00067
SetCPLastError(
CP_NULL_POINTER_ERR);
00068
return(
FALSE);
00069 }
00070
00071 GlobalUnlock(hMem);
00072 GlobalFree(hMem) ;
00073
return(
TRUE);
00074 }
00075
00076
00077
00078
00079
#ifndef ICMDLL
00080 BOOL EXTERN LoadCP(LPCSTR filename, HGLOBAL FAR *phMem, LPCHANDLE lpCP)
00081 {
00082
icHeader CPHeader;
00083 HFILE hFile;
00084
SINT Res, CPSize;
00085
MEMPTR mpCP;
00086
DWORD dwFileSize;
00087
00088 *phMem = 0;
00089
if (lpCP ==
NULL)
00090 {
00091
SetCPLastError(
CP_NULL_POINTER_ERR);
00092
return(
FALSE);
00093 }
00094
00095 hFile = _lopen(filename, READ );
00096
if( hFile == HFILE_ERROR )
00097 {
00098
SetCPLastError(
CP_FILE_OPEN_ERR);
00099
return(
FALSE);
00100 }
00101
00102
dwFileSize = _lseek(hFile, 0, SEEK_END);
00103 _lseek(hFile, 0, SEEK_SET);
00104
00105 Res = _lread(hFile, (
LPVOID) &CPHeader,
sizeof(CPHeader));
00106
if( (Res == HFILE_ERROR) ||
00107 (Res !=
sizeof(CPHeader)) )
00108 {
00109 _lclose(hFile);
00110
SetCPLastError(
CP_FILE_READ_ERR);
00111
return(
FALSE);
00112 }
00113
00114
00115
if(
SigtoCSIG(CPHeader.magic) !=
icMagicNumber )
00116 {
00117 _lclose(hFile);
00118
SetCPLastError(
CP_FORMAT_ERR);
00119
return(
FALSE);
00120 }
00121
00122
if (
dwFileSize == 0xFFFFFFFF)
00123 CPSize =
ui32toSINT(CPHeader.size);
00124
else
00125 CPSize = (
SINT)
dwFileSize;
00126
00127
if(
MemAlloc(CPSize, phMem, (
LPMEMPTR) &mpCP) )
00128 {
00129
00130 *lpCP = (
CHANDLE) mpCP;
00131
00132 _lseek(hFile, 0
L, SEEK_SET);
00133
00134
while(CPSize)
00135 {
00136 Res = _lread(hFile, (
LPVOID) mpCP, 4096);
00137
if (Res == HFILE_ERROR)
00138 {
00139 _lclose(hFile);
00140
SetCPLastError(
CP_FILE_READ_ERR);
00141
return(
FALSE);
00142 }
00143 mpCP += Res;
00144 CPSize -= Res;
00145 }
00146 }
else
00147 {
00148 *phMem = 0;
00149 _lclose(hFile);
00150
return(
FALSE);
00151 }
00152 _lclose(hFile);
00153
return (
TRUE);
00154 }
00155
00156
#else
00157
00158
00159
00160
BOOL EXTERN LoadCP32(LPCSTR filename, HGLOBAL *phMem, LPCHANDLE lpCP)
00161 {
00162
icHeader CPHeader;
00163 HANDLE hFile;
00164
SINT Res, CPSize;
00165
MEMPTR mpCP;
00166
BOOL Success;
00167
DWORD dwFileSize;
00168
00169
if (lpCP ==
NULL)
00170 {
00171
SetCPLastError(CP_NULL_POINTER_ERR);
00172
return(
FALSE);
00173 }
00174 hFile = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
00175
if( hFile ==
INVALID_HANDLE_VALUE )
00176 {
00177
SetCPLastError(CP_FILE_OPEN_ERR);
00178
return(
FALSE);
00179 }
00180
00181
dwFileSize = GetFileSize(hFile, NULL);
00182
00183 Success = ReadFile(hFile, (LPVOID) &CPHeader,
sizeof(CPHeader), &Res, NULL);
00184
if( ( !Success ) || (Res !=
sizeof(CPHeader)) )
00185 {
00186 CloseHandle(hFile);
00187
SetCPLastError(CP_FILE_READ_ERR);
00188
return(
FALSE);
00189 }
00190
00191
00192
if(
SigtoCSIG(CPHeader.magic) !=
icMagicNumber )
00193 {
00194 CloseHandle(hFile);
00195
SetCPLastError(CP_FORMAT_ERR);
00196
return(
FALSE);
00197 }
00198
00199
if (
dwFileSize == 0xFFFFFFFF)
00200 CPSize =
ui32toSINT(CPHeader.size);
00201
else
00202 CPSize = (
SINT)
dwFileSize;
00203
00204
if(
MemAlloc(CPSize, phMem, (LPMEMPTR) &mpCP) )
00205 {
00206
00207 *lpCP = (
CHANDLE) mpCP;
00208
00209 SetFilePointer(hFile, 0L, NULL, FILE_BEGIN);
00210 Success = ReadFile(hFile, (LPVOID) (LPVOID)mpCP, CPSize, &Res, NULL);
00211
if (!Success)
00212 {
00213 CloseHandle(hFile);
00214
SetCPLastError(CP_FILE_READ_ERR);
00215
return(
FALSE);
00216 }
00217 }
else
00218 {
00219 CloseHandle(hFile);
00220
return(
FALSE);
00221 }
00222 CloseHandle(hFile);
00223
return (
TRUE);
00224 }
00225
#endif
00226
00227 BOOL EXTERN FreeCP(HGLOBAL hMem)
00228 {
00229
return(
MemFree(hMem) );
00230 }
00231
00232
00233 BOOL EXTERN GetCPElementCount(CHANDLE CP, LPSINT lpCount)
00234 {
00235
lpcpTagList lpTL;
00236
if (lpCount ==
NULL)
00237 {
00238
SetCPLastError(
CP_NULL_POINTER_ERR);
00239
return(
FALSE);
00240 }
00241 lpTL = (
lpcpTagList) &(((
lpcpProfile)CP)->count);
00242 *lpCount =
ui32toSINT(lpTL->count);
00243
return(
TRUE);
00244 }
00245
00246
00247 BOOL EXTERN GetCPElementInfo(CHANDLE CP, SINT Index,
00248 LPMEMPTR lpTagData, LPMEMPTR lpElemData)
00249 {
00250
SINT Count;
00251
lpcpTagList lpTL;
00252
00253
if ( (lpTagData ==
NULL) || (lpElemData ==
NULL) )
00254 {
00255
SetCPLastError(
CP_NULL_POINTER_ERR);
00256
return(
FALSE);
00257 }
00258
00259 lpTL = (
lpcpTagList) &(((
lpcpProfile)CP)->count);
00260
Count =
ui32toSINT(lpTL->count);
00261
if (
Count <=
Index )
00262 {
00263
SetCPLastError(
CP_OUT_OF_RANGE_ERR);
00264
return(
FALSE);
00265 }
00266 *lpTagData = ((
MEMPTR) &(lpTL->tags[0])) + (
Index *
sizeof(
icTag)) ;
00267 *lpElemData = ((
MEMPTR) CP) +
00268
ui32toSINT( ((
lpcpTag)*lpTagData)->offset);
00269
return(
TRUE);
00270 }
00271
00272
00273
00274
00275 BOOL EXTERN ValidateCP(CHANDLE CP)
00276 {
00277
BOOL Result;
00278
CSIG ProfileClass;
00279
00280
if(
GetCPClass(CP, (
LPCSIG) &ProfileClass) )
00281 {
00282
00283
00284
00285
if( !
DoesCPTagExist(CP,
icSigProfileDescriptionTag) ||
00286 !
DoesCPTagExist(CP,
icSigCopyrightTag ) )
00287 {
00288
SetCPLastError(
CP_NOT_FOUND_ERR);
00289
return(
FALSE);
00290 }
00291
00292
00293
switch( ProfileClass )
00294 {
00295
case icSigLinkClass :
00296
if(
DoesCPTagExist(CP,
icSigAToB0Tag) &&
00297
DoesCPTagExist(CP,
icSigProfileSequenceDescTag)
00298 )
00299 {
00300 Result =
TRUE;
00301 }
else
00302 {
00303 Result =
FALSE;
00304 }
00305
break;
00306
00307
case icSigInputClass:
00308
if(
DoesCPTagExist(CP,
icSigGrayTRCTag) ||
00309
DoesCPTagExist(CP,
icSigAToB0Tag) )
00310 {
00311 Result =
TRUE;
00312 }
else if(
DoesCPTagExist(CP,
icSigGreenColorantTag) )
00313 {
00314
if(
DoesCPTagExist(CP,
icSigRedColorantTag) &&
00315
DoesCPTagExist(CP,
icSigBlueColorantTag) &&
00316
DoesCPTagExist(CP,
icSigRedTRCTag) &&
00317
DoesCPTagExist(CP,
icSigGreenTRCTag) &&
00318
DoesCPTagExist(CP,
icSigBlueTRCTag)
00319 )
00320 {
00321 Result =
TRUE;
00322 }
else
00323 {
00324 Result =
FALSE;
00325 }
00326 }
else
00327 {
00328 Result =
FALSE;
00329 }
00330 Result &=
DoesCPTagExist(CP,
icSigMediaWhitePointTag);
00331
break;
00332
00333
case icSigDisplayClass:
00334
if(
DoesCPTagExist(CP,
icSigGrayTRCTag) )
00335 {
00336 Result =
TRUE;
00337 }
else if(
DoesCPTagExist(CP,
icSigGreenColorantTag) )
00338 {
00339
if(
DoesCPTagExist(CP,
icSigRedColorantTag) &&
00340
DoesCPTagExist(CP,
icSigBlueColorantTag) &&
00341
DoesCPTagExist(CP,
icSigRedTRCTag) &&
00342
DoesCPTagExist(CP,
icSigGreenTRCTag) &&
00343
DoesCPTagExist(CP,
icSigBlueTRCTag)
00344 )
00345 {
00346 Result =
TRUE;
00347 }
else
00348 {
00349 Result =
FALSE;
00350 }
00351 }
else
00352 {
00353 Result =
FALSE;
00354 }
00355 Result &=
DoesCPTagExist(CP,
icSigMediaWhitePointTag);
00356
break;
00357
00358
case icSigOutputClass:
00359
if(
DoesCPTagExist(CP,
icSigGrayTRCTag) )
00360 {
00361 Result =
TRUE;
00362 }
else if(
DoesCPTagExist(CP,
icSigAToB0Tag) &&
00363
DoesCPTagExist(CP,
icSigAToB1Tag) &&
00364
DoesCPTagExist(CP,
icSigAToB2Tag) &&
00365
DoesCPTagExist(CP,
icSigBToA0Tag) &&
00366
DoesCPTagExist(CP,
icSigBToA1Tag) &&
00367
DoesCPTagExist(CP,
icSigBToA2Tag) &&
00368
DoesCPTagExist(CP,
icSigGamutTag)
00369 )
00370 {
00371 Result =
TRUE;
00372 }
else
00373 {
00374 Result =
FALSE;
00375 }
00376 Result &=
DoesCPTagExist(CP,
icSigMediaWhitePointTag);
00377
break;
00378
00379
case icSigAbstractClass:
00380
if(
DoesCPTagExist(CP,
icSigAToB0Tag) )
00381 {
00382 Result =
TRUE;
00383 }
else
00384 {
00385 Result =
FALSE;
00386 }
00387 Result &=
DoesCPTagExist(CP,
icSigMediaWhitePointTag);
00388
break;
00389
00390
case icSigColorSpaceClass:
00391
if(
DoesCPTagExist(CP,
icSigAToB0Tag) &&
00392
DoesCPTagExist(CP,
icSigBToA0Tag)
00393 )
00394 {
00395 Result =
TRUE;
00396 }
else
00397 {
00398 Result =
FALSE;
00399 }
00400 Result &=
DoesCPTagExist(CP,
icSigMediaWhitePointTag);
00401
break;
00402
00403
default:
00404 Result =
FALSE;
00405
break;
00406 }
00407 }
else
00408 {
00409
return(
FALSE);
00410 }
00411
if( Result ==
FALSE )
00412 {
00413
SetCPLastError(
CP_NOT_FOUND_ERR);
00414 }
00415
return(Result);
00416 }
00417
00418 BOOL EXTERN DoesCPTagExist(CHANDLE CP, CSIG CPTag)
00419 {
00420
SINT Count;
00421
MEMPTR Data;
00422
lpcpTagList lpTL;
00423
00424 lpTL = (
lpcpTagList) &(((
lpcpProfile)CP)->count);
00425
Count =
ui32toSINT(lpTL->count);
00426 Data = (
MEMPTR) &(lpTL->tags[0]) ;
00427
while (
Count-- )
00428 {
00429
if(
SigtoCSIG( ((
lpcpTag)Data)->sig) == CPTag )
00430 {
00431
return(
TRUE);
00432 }
else
00433 {
00434 Data +=
sizeof(
icTag);
00435 }
00436 }
00437
return(
FALSE);
00438 }
00439
00440
00441 BOOL EXTERN GetCPTagIndex(CHANDLE CP, CSIG CPTag, LPSINT lpIndex)
00442 {
00443
SINT Count;
00444
MEMPTR Data;
00445
SINT i;
00446
lpcpTagList lpTL;
00447
00448
if (lpIndex ==
NULL)
00449 {
00450
SetCPLastError(
CP_NULL_POINTER_ERR);
00451
return(
FALSE);
00452 }
00453
00454 lpTL = (
lpcpTagList) &(((
lpcpProfile)CP)->count);
00455
Count =
ui32toSINT(lpTL->count);
00456 Data = (
MEMPTR) &(lpTL->tags[0]) ;
00457
00458
for (i = 0; i <
Count; i++ )
00459 {
00460
if(
SigtoCSIG( ((
lpcpTag)Data)->sig) == CPTag )
00461 {
00462 *lpIndex = i;
00463
return(
TRUE);
00464 }
else
00465 {
00466 Data +=
sizeof(
icTag);
00467 }
00468 }
00469
00470
SetCPLastError(
CP_NOT_FOUND_ERR);
00471
return(
FALSE);
00472 }
00473
00474
00475
00476 BOOL EXTERN GetCPTagSig(CHANDLE CP, SINT Index, LPCSIG lpCPTag)
00477 {
00478
MEMPTR TagData, ElemData;
00479
if (lpCPTag ==
NULL)
00480 {
00481
SetCPLastError(
CP_NULL_POINTER_ERR);
00482
return(
FALSE);
00483 }
00484
if (
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00485 (
LPMEMPTR) &ElemData) )
00486 {
00487 *lpCPTag =
SigtoCSIG( ((
lpcpTag)TagData)->sig ) ;
00488 }
else
00489 {
00490
return(
FALSE);
00491 }
00492
return(
TRUE);
00493 }
00494
00495
00496
00497
00498
00499
00500 BOOL EXTERN GetCPElementType(CHANDLE CP, SINT Index, LPCSIG lpCSig)
00501 {
00502
MEMPTR TagData, ElemData;
00503
if (
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00504 (
LPMEMPTR) &ElemData) )
00505 {
00506 *lpCSig =
SigtoCSIG( ((
lpcpTagBase)ElemData)->sig ) ;
00507 }
else
00508 {
00509
return(
FALSE);
00510 }
00511
return(
TRUE);
00512 }
00513
00514
00515
00516 BOOL EXTERN GetCPElementSize(CHANDLE CP, SINT Index, LPSINT lpSize)
00517 {
00518
MEMPTR TagData, ElemData;
00519
if (lpSize ==
NULL)
00520 {
00521
SetCPLastError(
CP_NULL_POINTER_ERR);
00522
return(
FALSE);
00523 }
00524
00525
if (
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00526 (
LPMEMPTR) &ElemData) )
00527 {
00528 *lpSize =
ui32toSINT( ((
lpcpTag)TagData)->size );
00529 }
else
00530 {
00531
return(
FALSE);
00532 }
00533
00534
return(
TRUE);
00535 }
00536
00537 BOOL EXTERN GetCPElementDataSize(CHANDLE CP, SINT Index, LPSINT lpSize)
00538 {
00539
MEMPTR TagData, ElemData;
00540
if (lpSize ==
NULL)
00541 {
00542
SetCPLastError(
CP_NULL_POINTER_ERR);
00543
return(
FALSE);
00544 }
00545
00546
if (
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00547 (
LPMEMPTR) &ElemData) )
00548 {
00549
00550
00551
00552 *lpSize =
ui32toSINT( ((
lpcpTag)TagData)->size) -
00553
sizeof(
icTagBase) -
sizeof(
icUInt32Number);
00554 }
else
00555 {
00556
return(
FALSE);
00557 }
00558
00559
return(
TRUE);
00560 }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 BOOL EXTERN GetCPElement(CHANDLE CP, SINT Index,
00573 MEMPTR lpData, SINT Size)
00574 {
00575
SINT ElemSize;
00576
MEMPTR TagData, ElemData;
00577
if (lpData ==
NULL)
00578 {
00579
SetCPLastError(
CP_NULL_POINTER_ERR);
00580
return(
FALSE);
00581 }
00582
00583
if ( !
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00584 (
LPMEMPTR) &ElemData) )
00585 {
00586
return(
FALSE);
00587 }
00588 ElemSize =
ui32toSINT( ((
lpcpTag)TagData)->size);
00589
if(ElemSize >
Size )
00590 {
00591
SetCPLastError(
CP_NO_MEMORY_ERR);
00592
return(
FALSE);
00593 }
00594 MemCopy(lpData, ElemData, ElemSize);
00595
return(
TRUE);
00596
00597 }
00598
00599
00600 BOOL EXTERN GetCPElementData(CHANDLE CP, SINT Index,
00601 MEMPTR lpData, SINT Size)
00602 {
00603
SINT ElemSize;
00604
MEMPTR TagData, ElemData;
00605
if (lpData ==
NULL)
00606 {
00607
SetCPLastError(
CP_NULL_POINTER_ERR);
00608
return(
FALSE);
00609 }
00610
00611
if ( !
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00612 (
LPMEMPTR) &ElemData) )
00613 {
00614
return(
FALSE);
00615 }
00616
00617
00618
00619
00620 ElemData +=
sizeof(
icTagBase) +
sizeof(
icUInt32Number);
00621 ElemSize =
ui32toSINT( ((
lpcpTag)TagData)->size) -
00622
sizeof(
icTagBase) -
sizeof(
icUInt32Number);
00623
00624
if(ElemSize >
Size )
00625 {
00626
SetCPLastError(
CP_NO_MEMORY_ERR);
00627
return(
FALSE);
00628 }
00629
00630 MemCopy(lpData, ElemData, ElemSize);
00631
return(
TRUE);
00632 }
00633
00634
00635
00636 BOOL EXTERN GetCPElementDataType(CHANDLE CP, SINT Index,
long far *lpDataType)
00637 {
00638
MEMPTR TagData, ElemData;
00639
00640
if (lpDataType ==
NULL)
00641 {
00642
SetCPLastError(
CP_NULL_POINTER_ERR);
00643
return(
FALSE);
00644 }
00645
00646
if ( !
GetCPElementInfo(CP,
Index, (
LPMEMPTR) &TagData,
00647 (
LPMEMPTR) &ElemData) )
00648 {
00649
return(
FALSE);
00650 }
00651 ElemData +=
sizeof(
icTagBase);
00652 *lpDataType =
ui32toSINT( ((
icData __huge *)ElemData)->dataFlag);
00653
return (
TRUE);
00654 }
00655
00656 BOOL EXTERN ValidateCPElement(CHANDLE CP, SINT Index)
00657 {
00658
CSIG TagSig, DataSig;
00659
BOOL Result;
00660
if(
GetCPTagSig(CP,
Index, (
LPCSIG) &TagSig) &&
00661
GetCPElementType(CP,
Index, (
LPCSIG) &DataSig) )
00662 {
00663
switch(TagSig)
00664 {
00665
case icSigAToB0Tag:
00666
case icSigAToB1Tag:
00667
case icSigAToB2Tag:
00668
case icSigBToA0Tag:
00669
case icSigBToA1Tag:
00670
case icSigBToA2Tag:
00671
case icSigGamutTag:
00672
case icSigPreview0Tag:
00673
case icSigPreview1Tag:
00674
case icSigPreview2Tag:
00675 Result = (DataSig ==
icSigLut16Type) ||
00676 (DataSig ==
icSigLut8Type) ;
00677
break;
00678
00679
case icSigRedColorantTag:
00680
case icSigGreenColorantTag:
00681
case icSigBlueColorantTag:
00682
case icSigLuminanceTag:
00683
case icSigMediaBlackPointTag:
00684
case icSigMediaWhitePointTag:
00685 Result = (DataSig ==
icSigXYZType);
00686
break;
00687
00688
case icSigRedTRCTag:
00689
case icSigGreenTRCTag:
00690
case icSigBlueTRCTag:
00691
case icSigGrayTRCTag:
00692 Result = (DataSig ==
icSigCurveType);
00693
break;
00694
00695
case icSigPs2CRD0Tag:
00696
case icSigPs2CRD1Tag:
00697
case icSigPs2CRD2Tag:
00698
case icSigPs2CRD3Tag:
00699
case icSigPs2CSATag:
00700
case icSigPs2Intent0Tag:
00701
case icSigPs2Intent1Tag:
00702
case icSigPs2Intent2Tag:
00703
case icSigPs2Intent3Tag:
00704 Result = (DataSig ==
icSigDataType);
00705
break;
00706
00707
case icSigCharTargetTag:
00708
case icSigCopyrightTag:
00709 Result = (DataSig ==
icSigTextType);
00710
break;
00711
00712
case icSigCalibrationDateTimeTag:
00713 Result = (DataSig ==
icSigDateTimeType);
00714
break;
00715
00716
case icSigDeviceMfgDescTag:
00717
case icSigDeviceModelDescTag:
00718
case icSigProfileDescriptionTag:
00719
case icSigScreeningDescTag:
00720
case icSigViewingCondDescTag:
00721 Result = (DataSig ==
icSigTextDescriptionType);
00722
break;
00723
00724
case icSigMeasurementTag:
00725 Result = (DataSig ==
icSigMeasurementTag);
00726
break;
00727
00728
case icSigNamedColorTag:
00729 Result = (DataSig ==
icSigNamedColorTag);
00730
break;
00731
00732
case icSigProfileSequenceDescTag:
00733 Result = (DataSig ==
icSigProfileSequenceDescTag);
00734
break;
00735
00736
case icSigScreeningTag:
00737 Result = (DataSig ==
icSigScreeningTag);
00738
break;
00739
00740
case icSigTechnologyTag:
00741 Result = (DataSig ==
icSigSignatureType);
00742
break;
00743
00744
case icSigUcrBgTag:
00745 Result = (DataSig ==
icSigUcrBgTag);
00746
break;
00747
00748
case icSigViewingConditionsTag:
00749 Result = (DataSig ==
icSigViewingConditionsTag);
00750
break;
00751
00752
default:
00753 Result =
TRUE;
00754
break;
00755 }
00756 }
else
00757 {
00758 Result =
FALSE;
00759 }
00760
return(Result);
00761 }
00762
00763
00764
00765
00766 BOOL EXTERN GetCPSize(CHANDLE CP, LPSINT lpSize)
00767 {
00768
if (lpSize ==
NULL)
00769 {
00770
SetCPLastError(
CP_NULL_POINTER_ERR);
00771
return(
FALSE);
00772 }
00773 *lpSize =
ui32toSINT( ((
lpcpHeader)CP)->size);
00774
return(
TRUE);
00775 }
00776
00777 BOOL EXTERN GetCPCMMType(CHANDLE CP, LPCSIG lpType)
00778 {
00779
if (lpType ==
NULL)
00780 {
00781
SetCPLastError(
CP_NULL_POINTER_ERR);
00782
return(
FALSE);
00783 }
00784 *lpType =
SigtoCSIG( ((
lpcpHeader)CP)->cmmId);
00785
return(
TRUE);
00786 }
00787
00788 BOOL EXTERN GetCPVersion(CHANDLE CP, LPSINT lpVers)
00789 {
00790
if (lpVers ==
NULL)
00791 {
00792
SetCPLastError(
CP_NULL_POINTER_ERR);
00793
return(
FALSE);
00794 }
00795 *lpVers =
ui32toSINT( ((
lpcpHeader)CP)->version);
00796
return(
TRUE);
00797 }
00798
00799 BOOL EXTERN GetCPClass(CHANDLE CP, LPCSIG lpClass)
00800 {
00801
if (lpClass ==
NULL)
00802 {
00803
SetCPLastError(
CP_NULL_POINTER_ERR);
00804
return(
FALSE);
00805 }
00806 *lpClass =
SigtoCSIG( ((
lpcpHeader)CP)->deviceClass);
00807
return(
TRUE);
00808 }
00809
00810 BOOL EXTERN GetCPDevSpace(CHANDLE CP, LPCSIG lpInSpace)
00811 {
00812
if (lpInSpace ==
NULL)
00813 {
00814
SetCPLastError(
CP_NULL_POINTER_ERR);
00815
return(
FALSE);
00816 }
00817 *lpInSpace =
SigtoCSIG( ((
lpcpHeader)CP)->colorSpace);
00818
return(
TRUE);
00819 }
00820
00821 BOOL EXTERN GetCPConnSpace(CHANDLE CP, LPCSIG lpOutSpace)
00822 {
00823
if (lpOutSpace ==
NULL)
00824 {
00825
SetCPLastError(
CP_NULL_POINTER_ERR);
00826
return(
FALSE);
00827 }
00828 *lpOutSpace =
SigtoCSIG( ((
lpcpHeader)CP)->
pcs);
00829
return(
TRUE);
00830 }
00831
00832 BOOL EXTERN GetCPTarget(CHANDLE CP, LPCSIG lpTarget)
00833 {
00834
if (lpTarget ==
NULL)
00835 {
00836
SetCPLastError(
CP_NULL_POINTER_ERR);
00837
return(
FALSE);
00838 }
00839 *lpTarget =
SigtoCSIG( ((
lpcpHeader)CP)->platform);
00840
return(
TRUE);
00841 }
00842
00843 BOOL EXTERN GetCPManufacturer(CHANDLE CP, LPCSIG lpManuf)
00844 {
00845
if (lpManuf ==
NULL)
00846 {
00847
SetCPLastError(
CP_NULL_POINTER_ERR);
00848
return(
FALSE);
00849 }
00850 *lpManuf =
SigtoCSIG( ((
lpcpHeader)CP)->manufacturer);
00851
return(
TRUE);
00852 }
00853
00854 BOOL EXTERN GetCPModel(CHANDLE CP, LPCSIG lpModel)
00855 {
00856
if (lpModel ==
NULL)
00857 {
00858
SetCPLastError(
CP_NULL_POINTER_ERR);
00859
return(
FALSE);
00860 }
00861 *lpModel =
SigtoCSIG( ((
lpcpHeader)CP)->model);
00862
return(
TRUE);
00863 }
00864
00865 BOOL EXTERN GetCPFlags(CHANDLE CP, LPSINT lpFlags)
00866 {
00867
if (lpFlags ==
NULL)
00868 {
00869
SetCPLastError(
CP_NULL_POINTER_ERR);
00870
return(
FALSE);
00871 }
00872 *lpFlags =
ui32toSINT( ((
lpcpHeader)CP)->flags);
00873
return(
TRUE);
00874 }
00875
00876 BOOL EXTERN GetCPRenderIntent(CHANDLE CP, LPSINT lpIntent)
00877 {
00878
if (lpIntent ==
NULL)
00879 {
00880
SetCPLastError(
CP_NULL_POINTER_ERR);
00881
return(
FALSE);
00882 }
00883 *lpIntent =
ui32toSINT( ((
lpcpHeader)CP)->renderingIntent);
00884
return(
TRUE);
00885 }
00886
00887 BOOL EXTERN GetCPWhitePoint(CHANDLE CP, LPSFLOAT lpWP)
00888 {
00889
if (lpWP ==
NULL)
00890 {
00891
SetCPLastError(
CP_NULL_POINTER_ERR);
00892
return(
FALSE);
00893 }
00894 lpWP[0] = (
SFLOAT)
si16f16toSFLOAT( ((
lpcpHeader)CP)->illuminant.X);
00895 lpWP[1] = (
SFLOAT)
si16f16toSFLOAT( ((
lpcpHeader)CP)->illuminant.Y);
00896 lpWP[2] = (
SFLOAT)
si16f16toSFLOAT( ((
lpcpHeader)CP)->illuminant.Z);
00897
return(
TRUE);
00898 }
00899
00900 BOOL EXTERN GetCPAttributes(CHANDLE CP, LPATTRIB lpAttributes)
00901 {
00902
return(
TRUE);
00903 }
00904
00905 BOOL EXTERN GetCPMediaWhitePoint(CHANDLE cp, LPSFLOAT lpMediaWP)
00906 {
00907 HGLOBAL hTempMem;
00908
SINT TempSize;
00909
MEMPTR TempBuff;
00910
MEMPTR lpTable;
00911
SINT i,
Index;
00912
00913
if (
DoesCPTagExist (cp,
icSigMediaWhitePointTag) &&
00914
GetCPTagIndex (cp,
icSigMediaWhitePointTag, (
LPSINT) &
Index) &&
00915
GetCPElementSize (cp,
Index, (
LPSINT) & TempSize) &&
00916
MemAlloc (TempSize, (HGLOBAL *) & hTempMem, (
LPMEMPTR) & TempBuff) &&
00917
GetCPElement (cp,
Index, TempBuff, TempSize))
00918 {
00919 lpTable = (
MEMPTR) & (((
lpcpXYZType) TempBuff)->data);
00920
for (i = 0; i < 3; i++)
00921 {
00922 lpMediaWP[i] = (
SFLOAT)
si16f16toSFLOAT (lpTable);
00923 lpTable +=
sizeof (
icS15Fixed16Number);
00924 }
00925
MemFree (hTempMem);
00926
return (
TRUE);
00927 }
00928
return (
FALSE);
00929 }
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953 BOOL EXTERN GetPS2ColorRenderingIntent(CHANDLE cp, DWORD Intent,
00954 MEMPTR lpMem, LPDWORD lpcbSize)
00955 {
00956
SINT Index;
00957
SINT Size;
00958
00959
if (!cp)
00960
return FALSE;
00961
00962
Size = (
SINT) *lpcbSize;
00963
if( ( lpMem ==
NULL ) || (
Size == 0 ) )
00964 {
00965 lpMem =
NULL;
00966
Size = 0;
00967 *lpcbSize = 0;
00968 }
00969
00970
switch(
Intent)
00971 {
00972
case icPerceptual:
00973
if(
DoesCPTagExist(cp,
icSigPs2Intent0Tag) &&
00974
GetCPTagIndex(cp,
icSigPs2Intent0Tag, (
LPSINT) &
Index) &&
00975
GetCPElementDataSize(cp,
Index, (
LPSINT) &
Size) &&
00976 ( ( lpMem ==
NULL ) ||
00977
GetCPElementData(cp,
Index, lpMem,
Size) ) )
00978 {
00979 }
00980
break;
00981
00982
case icRelativeColorimetric:
00983
if(
DoesCPTagExist(cp,
icSigPs2Intent1Tag) &&
00984
GetCPTagIndex(cp,
icSigPs2Intent1Tag, (
LPSINT) &
Index) &&
00985
GetCPElementDataSize(cp,
Index, (
LPSINT) &
Size) &&
00986 ( ( lpMem ==
NULL ) ||
00987
GetCPElementData(cp,
Index, lpMem,
Size) ) )
00988 {
00989 }
00990
break;
00991
00992
case icSaturation:
00993
if(
DoesCPTagExist(cp,
icSigPs2Intent2Tag) &&
00994
GetCPTagIndex(cp,
icSigPs2Intent2Tag, (
LPSINT) &
Index) &&
00995
GetCPElementDataSize(cp,
Index, (
LPSINT) &
Size) &&
00996 ( ( lpMem ==
NULL ) ||
00997
GetCPElementData(cp,
Index, lpMem,
Size ) )
00998 )
00999 {
01000 }
01001
break;
01002
case icAbsoluteColorimetric:
01003
if(
DoesCPTagExist(cp,
icSigPs2Intent3Tag) &&
01004
GetCPTagIndex(cp,
icSigPs2Intent3Tag, (
LPSINT) &
Index) &&
01005
GetCPElementDataSize(cp,
Index, (
LPSINT) &
Size) &&
01006 ( ( lpMem ==
NULL ) ||
01007
GetCPElementData(cp,
Index, lpMem,
Size) ) )
01008 {
01009 }
01010
break;
01011
default:
01012
Size = 0 ;
01013
break;
01014 }
01015
01016
if (
Size != 0)
01017 {
01018
if (lpMem)
01019 {
01020 lpMem[
Size] =
'\0';
01021 }
01022
Size ++;
01023 *lpcbSize = (
DWORD)
Size;
01024
return (
TRUE);
01025 }
01026
else
01027 {
01028
return(
FALSE);
01029 }
01030 }
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
#ifndef ICMDLL
01044 BOOL EXTERN ValidColorSpace(LPPDEVICE lppd,
LPICMINFO lpICMI, LPCSIG lpDevCS )
01045 {
01046
icHeader CPHeader;
01047 HFILE hFile;
01048
SINT Res;
01049
CSIG CPColorSpaceTag;
01050
01051
if (
NULL == lpICMI)
01052 {
01053
return(
FALSE);
01054 }
01055 hFile = _lopen(lpICMI->
lcsDestFilename, READ);
01056
if( hFile == HFILE_ERROR )
01057 {
01058
return(
FALSE);
01059 }
01060
01061 Res = _lread(hFile, (
LPVOID) &CPHeader,
sizeof(CPHeader));
01062 _lclose(hFile);
01063
if( (Res == HFILE_ERROR) || (Res !=
sizeof(CPHeader)) )
01064 {
01065
return(
FALSE);
01066 }
01067
01068
01069
if(
SigtoCSIG(CPHeader.magic) !=
icMagicNumber )
01070 {
01071
return(
FALSE);
01072 }
01073
01074
01075
01076
01077
01078
01079 CPColorSpaceTag =
SigtoCSIG(CPHeader.colorSpace);
01080 *lpDevCS = CPColorSpaceTag;
01081
01082
switch ( lppd->lpPSExtDevmode->dm.iColorMatchingMethod )
01083 {
01084
case COLOR_MATCHING_ON_HOST:
01085
if ((CPColorSpaceTag ==
icSigCmyData))
01086
01087
01088 {
01089
return(
FALSE);
01090 }
01091
break;
01092
case COLOR_MATCHING_ON_PRINTER:
01093
if ((CPColorSpaceTag ==
icSigCmyData))
01094
01095 {
01096
return(
FALSE);
01097 }
01098
break;
01099
case COLOR_MATCHING_PRINTER_CALIBRATION:
01100
default:
01101
break;
01102 }
01103
return (
TRUE);
01104 }
01105
#endif
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119 SINT WriteHexBuffer(MEMPTR lpMem, MEMPTR lpBuff, MEMPTR lpLineStart, DWORD dwBytes)
01120 {
01121
SINT Res;
01122
char TempArray[
TempBfSize];
01123
MEMPTR lpOldPtr = lpMem;
01124
01125
for ( ; dwBytes ; dwBytes-- )
01126 {
01127 Res = wsprintf( (
MEMPTR)TempArray, (LPSTR)
"%2.2x", *lpBuff );
01128 *lpMem++ = TempArray[0];
01129 *lpMem++ = TempArray[1];
01130 lpBuff++;
01131
if (((
SINT)(lpMem - lpLineStart)) >
MAX_LINELENG)
01132 {
01133 lpLineStart = lpMem;
01134 lpMem +=
WriteObject(lpMem,
NewLine);
01135 }
01136 }
01137
return( (
SINT)(lpMem - lpOldPtr));
01138 }
01139
01140
01141
01142
01143
01144
01145 SINT WriteNewLineObject(MEMPTR lpMem, MEMPTR Obj)
01146 {
01147
SINT Res1, Res2;
01148
01149 Res1 = lstrlen(
NewLine);
01150 MemCopy(lpMem,
NewLine, Res1);
01151
01152 lpMem += Res1;
01153 Res2 = lstrlen(Obj);
01154 MemCopy(lpMem, Obj, Res2);
01155
return( Res1 + Res2 );
01156 }
01157
01158 SINT WriteObject(MEMPTR lpMem, MEMPTR Obj)
01159 {
01160
SINT Res;
01161
01162 Res = lstrlen(Obj);
01163 MemCopy(lpMem, Obj, Res);
01164
return( Res );
01165 }
01166
01167 SINT WriteObjectN(MEMPTR lpMem, MEMPTR Obj, SINT n)
01168 {
01169 MemCopy(lpMem, Obj,
n);
01170
return(
n );
01171 }
01172
01173
01174
01175
01176
01177 SINT WriteInt(MEMPTR lpMem, SINT Number)
01178 {
01179
SINT Res;
01180
char TempArray[
TempBfSize];
01181
01182 Res = wsprintf( (
MEMPTR)TempArray,
"%lu ", Number );
01183 MemCopy(lpMem, TempArray, lstrlen(TempArray));
01184
return( Res );
01185 }
01186
01187
01188
01189
01190
01191
01192 SINT WriteHex(MEMPTR lpMem, SINT Number)
01193 {
01194
SINT Res;
01195
char TempArray[
TempBfSize];
01196
01197 Res = wsprintf( TempArray,
"%2.2x", (
int)(Number & 0x00FF) );
01198 MemCopy(lpMem, TempArray, lstrlen(TempArray));
01199
return( Res );
01200 }
01201
01202
01203
01204
01205
01206
01207
01208 SINT WriteFloat(MEMPTR lpMem,
double dFloat)
01209 {
01210
char cSign;
01211
double dInt ;
01212
double dFract ;
01213 LONG lFloat ;
01214
SINT Res;
01215
char TempArray[
TempBfSize];
01216
01217 lFloat = (LONG) floor( dFloat * 10000.0 + 0.5);
01218
01219 dFloat = lFloat / 10000.0 ;
01220
01221 dInt = floor(fabs(dFloat));
01222 dFract = fabs(dFloat) - dInt ;
01223
01224 cSign =
' ' ;
01225
if ( dFloat < 0 )
01226 {
01227 cSign =
'-' ;
01228 }
01229
01230 Res = wsprintf( (LPSTR) TempArray, (LPSTR)
"%c%d.%0.4lu ",
01231 cSign, (WORD) dInt , (
DWORD) (dFract *10000.0) );
01232 MemCopy(lpMem, TempArray, lstrlen(TempArray));
01233
return ( Res );
01234 }
01235
01236
01237
01238
01239
01240
01241
01242 SINT WriteStringToken(MEMPTR lpMem, BYTE Token, SINT sNum)
01243 {
01244 *lpMem++ =
Token;
01245 *lpMem++ = (
BYTE)((sNum & 0xFF00) >> 8);
01246 *lpMem++ = (
BYTE)(sNum & 0x00FF);
01247
return (3);
01248 }
01249
01250
01251
01252
01253
01254
01255
01256 SINT WriteHNAToken(MEMPTR lpMem, BYTE Token, SINT sNum)
01257 {
01258 *lpMem++ =
Token;
01259 *lpMem++ = 32;
01260 *lpMem++ = (
BYTE)((sNum & 0xFF00) >> 8);
01261 *lpMem++ = (
BYTE)(sNum & 0x00FF);
01262
return (4);
01263 }
01264
01265
01266
01267
01268
01269
01270
01271
01272 SINT WriteIntStringU2S(MEMPTR lpMem, MEMPTR lpBuff, SINT sNum)
01273 {
01274
SINT i;
01275
SINT Temp;
01276
01277
for (i = 0; i < sNum; i ++)
01278 {
01279 Temp =
ui16toSINT( lpBuff) - 32768;
01280 *lpMem++ = (
BYTE)((Temp & 0xFF00) >> 8);
01281 *lpMem++ = (
BYTE)(Temp & 0x00FF);
01282 lpBuff +=
sizeof(
icUInt16Number);
01283 }
01284
return(sNum * 2);
01285 }
01286
01287
01288
01289
01290
01291
01292
01293
01294 SINT WriteIntStringU2S_L(MEMPTR lpMem, MEMPTR lpBuff, SINT sNum)
01295 {
01296
SINT i;
01297
SINT Temp;
01298
01299
for (i = 0; i < sNum; i ++)
01300 {
01301 Temp = (
SINT)*((
PUSHORT)lpBuff) - 32768;
01302 *lpMem++ = (
BYTE)((Temp & 0xFF00) >> 8);
01303 *lpMem++ = (
BYTE)(Temp & 0x00FF);
01304 lpBuff +=
sizeof(
icUInt16Number);
01305 }
01306
return(sNum * 2);
01307 }
01308
01309
01310
01311
01312
01313
01314 SINT WriteByteString(MEMPTR lpMem, MEMPTR lpBuff, SINT sBytes)
01315 {
01316
SINT i;
01317
01318
for (i = 0; i < sBytes; i ++)
01319 *lpMem++ = *lpBuff++;
01320
01321
return(sBytes);
01322 }
01323
01324
01325
01326
01327
01328
01329 SINT WriteInt2ByteString(MEMPTR lpMem, MEMPTR lpBuff, SINT sBytes)
01330 {
01331
SINT i;
01332
01333
for( i = 0; i < sBytes ; i++)
01334 {
01335 *lpMem++ = (
BYTE)(
ui16toSINT( lpBuff)/256) ;
01336 lpBuff +=
sizeof(
icUInt16Number);
01337 }
01338
return(sBytes);
01339 }
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354 SINT WriteASCII85Cont(MEMPTR lpDest, SINT BufSize, MEMPTR lpSource, SINT DataSize)
01355 {
01356
SINT incount;
01357
MEMPTR lpPtr, lpSave;
01358
SINT rem;
01359
SINT bcount;
01360
SINT dex;
01361
unsigned long word;
01362
01363
01364 lpSave =
lpDest;
01365 lpPtr =
lpSource;
01366 word = 0UL;
01367 bcount = 0;
01368
01369
for (incount = 0; incount < DataSize; incount ++)
01370 {
01371
if ( incount && ((incount %
LINELENG) == 0) )
01372
lpDest +=
WriteObject(
lpDest,
NewLine);
01373 word = (word<<8);
01374 word |= (
BYTE)*lpPtr++;
01375
if (bcount == 3)
01376 {
01377
lpDest +=
WriteAscii85(
lpDest, word, 5);
01378 word = 0UL;
01379 bcount = 0;
01380 }
01381
else
01382 {
01383 bcount ++;
01384 }
01385 }
01386
01387
01388
01389
if (bcount > 0)
01390 {
01391 rem = 4 - bcount;
01392
for (dex = 0; dex < rem; dex ++)
01393 {
01394 word = (word<<8);
01395 word |= (
BYTE)32;
01396 }
01397
01398
lpDest +=
WriteAscii85(
lpDest, word, 5);
01399 }
01400
return (
lpDest - lpSave);
01401 }
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415 SINT WriteAscii85(MEMPTR lpDest,
unsigned long inWord, SINT nBytes)
01416 {
01417
unsigned long divisor;
01418
int bcount;
01419
BYTE outchar;
01420
MEMPTR lpSave =
lpDest;
01421
01422
if ((inWord == 0UL) && (nBytes == 5))
01423 *
lpDest++ =
'z';
01424
else
01425 {
01426 divisor = 52200625UL;
01427
for (bcount = 0; bcount < nBytes; bcount ++)
01428 {
01429 outchar = (
BYTE)((
int)(inWord/divisor) + (
int)
'!');
01430 *
lpDest++ = outchar;
01431
if (bcount < 4)
01432 {
01433 inWord = (inWord % divisor);
01434 divisor =(divisor / 85);
01435 }
01436 }
01437 }
01438
return (
SINT)(
lpDest - lpSave);
01439 }
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455 SINT ConvertBinaryData2Ascii(MEMPTR lpMem, SINT DataSize, SINT BufSize)
01456 {
01457
MEMPTR intrbuf, Temp;
01458 HANDLE intrhandle;
01459
SINT AsciiDataSize = 0;
01460
01461
if (BufSize >= (
SINT)(DataSize/4*5 +
sizeof(
ASCII85DecodeBegine)+
sizeof(
ASCII85DecodeEnd) + 2048))
01462 {
01463
if ((intrhandle = GlobalAlloc(GHND, BufSize)) !=
NULL)
01464 {
01465
if ((intrbuf = (
MEMPTR) GlobalLock(intrhandle)) !=
NULL)
01466 {
01467 Temp = intrbuf;
01468 Temp +=
WriteObject(Temp,
NewLine);
01469 Temp +=
WriteObject(Temp,
ASCII85DecodeBegine);
01470 Temp +=
WriteObject(Temp,
NewLine);
01471 Temp +=
WriteASCII85Cont(Temp, BufSize, lpMem, DataSize);
01472 Temp +=
WriteObject(Temp,
ASCII85DecodeEnd);
01473 AsciiDataSize = (
SINT)(Temp - intrbuf);
01474 lstrcpyn(lpMem, intrbuf, (WORD)AsciiDataSize);
01475 GlobalUnlock(intrhandle);
01476 }
01477 }
01478 GlobalFree(intrhandle);
01479 }
01480
return (AsciiDataSize);
01481 }
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500 SINT Convert2Ascii(CHANDLE CP, SINT Index,
01501 MEMPTR lpData, SINT BufSize,
01502 SINT DataSize, BOOL AllowBinary)
01503 {
01504
long DataType;
01505
01506
GetCPElementDataType(CP,
Index, &DataType);
01507
if (BufSize == 0)
01508 {
01509
if (
AllowBinary)
01510
return (DataSize);
01511
else if (DataType == 0)
01512
return (DataSize);
01513
else
01514
return (DataSize / 4 * 5 +
sizeof(
ASCII85DecodeBegine)+
sizeof(
ASCII85DecodeEnd) + 2048);
01515 }
01516
else
01517 {
01518
if (
AllowBinary)
01519
return (DataSize);
01520
else if(DataType == 0)
01521
return (DataSize);
01522
else
01523
return (
ConvertBinaryData2Ascii(lpData, DataSize, BufSize) );
01524 }
01525 }
01526
01527
#ifdef ICMDLL
01528
SINT MemCopy(MEMPTR Dest, MEMPTR Source, SINT Length)
01529 {
01530
SINT i;
01531
01532
for (i = 0; i < Length; i++)
01533 {
01534 Dest[i] = Source[i];
01535 }
01536
return( Length );
01537 }
01538
01539
01540
BOOL EXTERN InvertMatrix (
double FAR * lpInMatrix,
01541
double FAR * lpOutMatrix)
01542 {
01543
double det;
01544
01545
double FAR *a;
01546
double FAR *b;
01547
double FAR *
c;
01548
if ((
NULL == lpInMatrix) ||
01549 (
NULL == lpOutMatrix))
01550 {
01551
return (
FALSE);
01552 }
01553 a = (
double FAR *) &(lpInMatrix[0]);
01554 b = (
double FAR *) &(lpInMatrix[3]);
01555
c = (
double FAR *) &(lpInMatrix[6]);
01556
01557 det = a[0] * b[1] *
c[2] + a[1] * b[2] *
c[0] + a[2] * b[0] *
c[1] -
01558 (a[2] * b[1] *
c[0] + a[1] * b[0] *
c[2] + a[0] * b[2] *
c[1]);
01559
01560
if (det == 0.0)
01561 {
01562 lpOutMatrix[0] = 1.0;
01563 lpOutMatrix[1] = 0.0;
01564 lpOutMatrix[2] = 0.0;
01565
01566 lpOutMatrix[3] = 0.0;
01567 lpOutMatrix[4] = 1.0;
01568 lpOutMatrix[5] = 0.0;
01569
01570 lpOutMatrix[6] = 0.0;
01571 lpOutMatrix[7] = 0.0;
01572 lpOutMatrix[8] = 1.0;
01573
return (
FALSE);
01574 }
else
01575 {
01576 lpOutMatrix[0] = (b[1] *
c[2] - b[2] *
c[1]) / det;
01577 lpOutMatrix[3] = -(b[0] *
c[2] - b[2] *
c[0]) / det;
01578 lpOutMatrix[6] = (b[0] *
c[1] - b[1] *
c[0]) / det;
01579
01580 lpOutMatrix[1] = -(a[1] *
c[2] - a[2] *
c[1]) / det;
01581 lpOutMatrix[4] = (a[0] *
c[2] - a[2] *
c[0]) / det;
01582 lpOutMatrix[7] = -(a[0] *
c[1] - a[1] *
c[0]) / det;
01583
01584 lpOutMatrix[2] = (a[1] * b[2] - a[2] * b[1]) / det;
01585 lpOutMatrix[5] = -(a[0] * b[2] - a[2] * b[0]) / det;
01586 lpOutMatrix[8] = (a[0] * b[1] - a[1] * b[0]) / det;
01587
return (
TRUE);
01588 }
01589 }
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
static DWORD crc_32_tab[] = {
01600 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
01601 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
01602 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
01603 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
01604 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
01605 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
01606 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
01607 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
01608 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
01609 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
01610 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
01611 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
01612 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
01613 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
01614 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
01615 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
01616 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
01617 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
01618 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
01619 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
01620 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
01621 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
01622 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
01623 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
01624 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
01625 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
01626 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
01627 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
01628 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
01629 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
01630 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
01631 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
01632 };
01633
01634
DWORD FAR PASCAL
crc32(MEMPTR buff, DWORD length)
01635 {
01636
DWORD crc, charcnt;
01637
BYTE c;
01638
01639
01640 crc = 0xFFFFFFFF;
01641 charcnt = 0;
01642
01643
for (charcnt = 0 ; charcnt < length ; charcnt++)
01644 {
01645
c = buff[charcnt] ;
01646 crc = crc_32_tab[(crc ^
c) & 0xff] ^ (crc >> 8);
01647 }
01648
01649
return crc;
01650 }
01651
#endif
01652