00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#include "Windef.h"
00014
#include "WinGdi.h"
00015
#include <wtypes.h>
00016
#include <winbase.h>
00017
#include <WindowsX.h>
00018
#include "ICM.h"
00019
00020
#ifndef LHGeneralIncs_h
00021
#include "General.h"
00022
#endif
00023
00024
#ifndef MSNewMemProfile_h
00025
#include "MemProf.h"
00026
#endif
00027
00028 #define CMM_WIN_VERSION 0
00029 #define CMM_IDENT 1
00030 #define CMM_DRIVER_LEVEL 2
00031 #define CMM_DLL_VERSION 3
00032 #define CMM_VERSION 4
00033 #define CMS_LEVEL_1 1
00034
00035 typedef HANDLE
HCMTRANSFORM;
00036 typedef LPVOID LPDEVCHARACTER;
00037 typedef LPVOID LPHPROFILE;
00038 typedef LPVOID LPARGBQUAD;
00039 typedef COLORREF
FAR *
LPCOLORREF;
00040
00041
#ifdef _DEBUG
00042
00043
#endif
00044
00045
00046
00047
00048 long IndexTransform=0;
00049 HCMTRANSFORM TheTransform[1000] = {0};
00050
00051 CRITICAL_SECTION
GlobalCriticalSection;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 BOOL WINAPI
DllMain ( HINSTANCE hinstDLL,
00072 DWORD fdwReason,
00073 LPVOID lpvReserved )
00074 {
00075
switch (fdwReason)
00076 {
00077
case DLL_PROCESS_ATTACH:
00078 DisableThreadLibraryCalls(hinstDLL);
00079 InitializeCriticalSection(&
GlobalCriticalSection);
00080
break;
00081
case DLL_PROCESS_DETACH:
00082 DeleteCriticalSection(&
GlobalCriticalSection);
00083
break;
00084 }
00085
return TRUE;
00086 }
00087
00088 #define DllExport __declspec( dllexport )
00089
00090
HCMTRANSFORM WINAPI
CMCreateMultiProfileTransform( LPHPROFILE lpahProfiles,
00091 DWORD nProfiles,
00092 UINT32 *aIntentArr,
00093 UINT32 nIntents,
00094 UINT32 dwFlags );
00095
long FillProfileFromLog( LPLOGCOLORSPACEA lpColorSpace,
00096 PPROFILE theProf );
00097
long FillProfileFromLogW( LPLOGCOLORSPACEW lpColorSpace,
00098 PPROFILE theProf );
00099
BOOL WINAPI
CMCreateProfile( LPLOGCOLORSPACEA lpColorSpace,
00100 LPBYTE *lpProfileData );
00101
CMWorldRef StoreTransform( CMWorldRef aRef );
00102
CMBitmapColorSpace CMGetDataColorSpace( BMFORMAT c,
long *pixelSize );
00103
HCMTRANSFORM WINAPI
CMGetTransform( HCMTRANSFORM hcmTransform );
00104
long CMCreateMultiProfileTransformInternal( CMWorldRef *cw,
00105 LPHPROFILE lpahProfiles,
00106 DWORD nProfiles,
00107 UINT32 *aIntentArr,
00108 UINT32 nIntents,
00109 UINT32 dwFlags,
00110 UINT32 dwCreateLink );
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 DWORD WINAPI
CMGetInfo( DWORD dwInfo )
00135 {
00136
DWORD ret = 0;
00137
switch( dwInfo ){
00138
case CMM_VERSION:
00139 ret = 0x00050000;
00140
break;
00141
case CMM_WIN_VERSION:
00142 ret = 0x00040000;
00143
break;
00144
case CMM_DLL_VERSION:
00145 ret = 0x00010000;
00146
break;
00147
case CMM_IDENT:
00148 ret = 'Win ';
00149
break;
00150
case CMM_LOGOICON:
00151 ret = 100;
00152
break;
00153
case CMM_DESCRIPTION:
00154 ret = 100;
00155
break;
00156
case CMM_DRIVER_LEVEL:
00157 ret =
CMS_LEVEL_1;
00158
break;
00159
default:
00160 ret = 0;
00161
break;
00162 }
00163
return ret;
00164 }
00165
00166
00167 long CMCreateTransformExtInternal( CMWorldRef *cwOut,
00168 UINT32 dwFlags,
00169 UINT32 lcsIntent,
00170 HPROFILE aProf,
00171 LPBYTE ptDeRef,
00172 LPBYTE pdDeRef )
00173 {
00174
CMWorldRef cw=0;
00175
CMWorldRef cw2=0;
00176
long err;
00177 HPROFILE saveProf;
00178 HPROFILE hArray[3];
00179
UINT32 aIntent[3];
00180
UINT32 aUINT32,count;
00181
CMMModelPtr theModelPtr;
00182
00183 *cwOut = 0;
00184 aIntent[0] =
icRelativeColorimetric;
00185
switch( lcsIntent ){
00186
case LCS_GM_BUSINESS:
00187 aIntent[1] =
icSaturation;
00188
break;
00189
case LCS_GM_GRAPHICS:
00190 aIntent[1] =
icRelativeColorimetric;
00191
break;
00192
case LCS_GM_ABS_COLORIMETRIC:
00193 aIntent[1] =
icAbsoluteColorimetric;
00194
break;
00195
default:
00196 aIntent[1] =
icPerceptual;
00197
break;
00198 }
00199
if( ptDeRef == 0 ){
00200 count = 2;
00201 hArray[0] = aProf;
00202 hArray[1] = pdDeRef;
00203 }
00204
else{
00205 count = 3;
00206 hArray[0] = aProf;
00207 hArray[1] = ptDeRef;
00208 hArray[2] = pdDeRef;
00209
if(
dwFlags & USE_RELATIVE_COLORIMETRIC )aIntent[2] = INTENT_RELATIVE_COLORIMETRIC;
00210
else aIntent[2] = INTENT_ABSOLUTE_COLORIMETRIC;
00211 }
00212
00213 err =
CMCreateMultiProfileTransformInternal( &cw, hArray, count, aIntent, count,
dwFlags, 0 );
00214
if( err ){
00215
goto CleanupAndExit;
00216 }
00217
if(
dwFlags & 0x80000000 ){
00218 count--;
00219 saveProf = hArray[count];
00220 hArray[count] = hArray[0];
00221 hArray[0] = saveProf;
00222 aUINT32 = aIntent[count];
00223 aIntent[count] = aIntent[0];
00224 aIntent[0] = aUINT32;
00225
00226 count++;
00227 err =
CMCreateMultiProfileTransformInternal( &cw2, hArray, count, aIntent, count,
dwFlags, 0 );
00228
if( err ){
00229
CWDisposeColorWorld( cw );
00230
goto CleanupAndExit;
00231 }
00232
LOCK_DATA( cw );
00233 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( cw ));
00234 theModelPtr->pBackwardTransform = cw2;
00235
UNLOCK_DATA( aTrans );
00236 }
00237
00238 CleanupAndExit:
00239
CloseColorProfile( aProf );
00240
if( err ){
00241 SetLastError( err );
00242 cw = (
CMWorldRef)(ULONG_PTR)(err & 255);
00243 }
00244
else{
00245 cw =
StoreTransform( cw );
00246 }
00247 *cwOut = cw;
00248
return 0;
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
void WriteProf( LPSTR name,
icProfile *theProf,
long currentSize );
00282 HCMTRANSFORM WINAPI
CMCreateTransformExt( LPLOGCOLORSPACEA lpColorSpace,
00283 LPDEVCHARACTER lpDevCharacter,
00284 LPDEVCHARACTER lpTargetDevCharacter,
00285 UINT32 dwFlags )
00286 {
00287
CMWorldRef cw=0;
00288
long err;
00289 LPBYTE pt,
pd, ptDeRef, pdDeRef;
00290 HPROFILE aProf;
00291 PROFILE theProf;
00292
BOOL bWin95;
00293 OSVERSIONINFO osvi;
00294
00295
#if 0
00296
CMCreateProfile( lpColorSpace, &pt );
00297 err = *(
long *)pt;
00298 SwapLong(&err);
00299
WriteProf(
"CMCreateProfile.icc", (
icProfile *)pt, err );
00300 GlobalFreePtr( pt );
00301
#endif
00302
00303
00304 err =
FillProfileFromLog( lpColorSpace, &theProf );
00305
if( err ){
00306 SetLastError( err );
00307
goto CleanupAndExit;
00308 }
00309 aProf = OpenColorProfile(&theProf, PROFILE_READ, FILE_SHARE_READ,
OPEN_EXISTING );
00310
if( !aProf ){
00311 err = GetLastError();
00312
goto CleanupAndExit;
00313 }
00314 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
00315 GetVersionEx(&osvi);
00316 bWin95 = osvi.dwMajorVersion == 4 &&
00317 osvi.dwMinorVersion == 0 &&
00318 osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
00319
00320
if (bWin95)
00321 {
00322 PROFILE myProf;
00323
DWORD l;
00324
00325
00326
00327
00328
00329 myProf.dwType = PROFILE_MEMBUFFER;
00330 myProf.pProfileData = lpDevCharacter;
00331 l = *(
DWORD *)(myProf.pProfileData);
00332 myProf.cbDataSize = SwapLong(&l);
00333 pdDeRef = OpenColorProfile(&myProf, PROFILE_READ, FILE_SHARE_READ,
OPEN_EXISTING );
00334
if( !pdDeRef ){
00335 err = GetLastError();
00336
goto CleanupAndExit;
00337 }
00338
00339 ptDeRef = 0;
00340
if (lpTargetDevCharacter)
00341 {
00342 myProf.dwType = PROFILE_MEMBUFFER;
00343 myProf.pProfileData = lpTargetDevCharacter;
00344 l = *(
DWORD *)(myProf.pProfileData);
00345 myProf.cbDataSize = SwapLong(&l);
00346 ptDeRef = OpenColorProfile(&myProf, PROFILE_READ, FILE_SHARE_READ,
OPEN_EXISTING );
00347
if( !ptDeRef ){
00348 err = GetLastError();
00349
goto CleanupAndExit;
00350 }
00351 }
00352 }
00353
else
00354 {
00355
pd = ((LPBYTE)lpColorSpace+
sizeof(LOGCOLORSPACEA));
00356 pdDeRef= (LPBYTE)*(PULONG_PTR)
pd;
00357
00358 pt = ((LPBYTE)lpColorSpace+
sizeof(LOGCOLORSPACEA)+
sizeof(HPROFILE));
00359 ptDeRef= (LPBYTE)*(PULONG_PTR)pt;
00360 }
00361
00362 err =
CMCreateTransformExtInternal( &cw,
dwFlags,
00363 lpColorSpace->lcsIntent, aProf, ptDeRef, pdDeRef );
00364
00365 CleanupAndExit:
00366
if( lpColorSpace->lcsFilename[0] == 0 ){
00367
if( theProf.pProfileData )GlobalFreePtr( theProf.pProfileData );
00368 theProf.pProfileData = 0;
00369 }
00370
if (bWin95)
00371 {
00372
if (pdDeRef)
00373 {
00374
CloseColorProfile(pdDeRef);
00375 }
00376
if (ptDeRef)
00377 {
00378
CloseColorProfile(ptDeRef);
00379 }
00380 }
00381
if( err ){
00382
return (
HCMTRANSFORM)(ULONG_PTR)(err & 255);
00383 }
00384
return (
HCMTRANSFORM)cw;
00385 }
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 HCMTRANSFORM WINAPI
CMCreateTransform ( LPLOGCOLORSPACEA lpColorSpace,
00411 LPDEVCHARACTER lpDevCharacter,
00412 LPDEVCHARACTER lpTargetDevCharacter )
00413 {
00414
return CMCreateTransformExt( lpColorSpace, lpDevCharacter, lpTargetDevCharacter, PROOF_MODE | ENABLE_GAMUT_CHECKING | 0x80000000 );
00415 }
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 HCMTRANSFORM WINAPI
CMCreateTransformExtW( LPLOGCOLORSPACEW lpColorSpace,
00447 LPDEVCHARACTER lpDevCharacter,
00448 LPDEVCHARACTER lpTargetDevCharacter,
00449 UINT32 dwFlags )
00450 {
00451
CMWorldRef cw=0;
00452
long err;
00453 LPBYTE pt,
pd, ptDeRef, pdDeRef;
00454 HPROFILE aProf;
00455 PROFILE theProf;
00456
00457 err =
FillProfileFromLogW( lpColorSpace, &theProf );
00458
if( err ){
00459 SetLastError( err );
00460
goto CleanupAndExit;
00461 }
00462 aProf =
OpenColorProfileW(&theProf, PROFILE_READ, FILE_SHARE_READ,
OPEN_EXISTING );
00463
if( !aProf ){
00464 err = GetLastError();
00465
goto CleanupAndExit;
00466 }
00467
pd = ((LPBYTE)lpColorSpace+
sizeof(LOGCOLORSPACEW));
00468 pdDeRef= (LPBYTE)*(PULONG_PTR)
pd;
00469
00470 pt = ((LPBYTE)lpColorSpace+
sizeof(LOGCOLORSPACEW)+
sizeof(HPROFILE));
00471 ptDeRef= (LPBYTE)*(PULONG_PTR)pt;
00472
00473 err =
CMCreateTransformExtInternal( &cw,
dwFlags,
00474 lpColorSpace->lcsIntent, aProf, ptDeRef, pdDeRef );
00475
00476 CleanupAndExit:
00477
if( lpColorSpace->lcsFilename[0] == 0 ){
00478
if( theProf.pProfileData )GlobalFreePtr( theProf.pProfileData );
00479 theProf.pProfileData = 0;
00480 }
00481
if( err ){
00482
return (
HCMTRANSFORM)(ULONG_PTR)(err & 255);
00483 }
00484
return (
HCMTRANSFORM)cw;
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509 HCMTRANSFORM WINAPI
CMCreateTransformW( LPLOGCOLORSPACEW lpColorSpace,
00510 LPDEVCHARACTER lpDevCharacter,
00511 LPDEVCHARACTER lpTargetDevCharacter )
00512 {
00513
return CMCreateTransformExtW( lpColorSpace, lpDevCharacter, lpTargetDevCharacter, PROOF_MODE | ENABLE_GAMUT_CHECKING );
00514 }
00515
00516 long CMCreateMultiProfileTransformInternal( CMWorldRef *cw,
00517 LPHPROFILE lpahProfiles,
00518 DWORD nProfiles,
00519 UINT32 *aIntentArr,
00520 UINT32 nIntents,
00521 UINT32 dwFlags,
00522 UINT32 dwCreateLink )
00523 {
00524
CMConcatProfileSet *profileSet;
00525
OSErr aOSErr;
00526
DWORD i;
00527
long err;
00528
UINT32 theFlags;
00529
UINT32 *arrIntents = 0;;
00530
00531 profileSet = (
CMConcatProfileSet *)
SmartNewPtrClear(
sizeof (
CMConcatProfileSet) + (nProfiles)*
sizeof(
CMProfileRef), &aOSErr );
00532
if (aOSErr == 0 )
00533 {
00534 profileSet->
keyIndex = 0;
00535 profileSet->
count = (
unsigned short)nProfiles;
00536
for( i=0; i<nProfiles; i++)
00537 profileSet->
profileSet[i] = (
CMProfileRef)((
DWORD *)(((PVOID *)lpahProfiles)[i]));
00538 }
00539
else return ERROR_NOT_ENOUGH_MEMORY;
00540
00541
switch(
dwFlags & 0xffff ){
00542
case BEST_MODE:
00543 theFlags =
cmBestMode;
00544
break;
00545
case PROOF_MODE:
00546 theFlags =
cmDraftMode;
00547
break;
00548
default:
00549 theFlags =
cmNormalMode;
00550
break;
00551 }
00552
if( ! (
dwFlags & ENABLE_GAMUT_CHECKING) ){
00553 theFlags |=
kCreateGamutLutMask;
00554 }
00555
if(
dwFlags & USE_RELATIVE_COLORIMETRIC ){
00556 theFlags |=
kUseRelColorimetric;
00557 }
00558
if(
dwFlags & FAST_TRANSLATE ){
00559 theFlags |=
kLookupOnlyMask;
00560 }
00561
if( nProfiles > 1 && nIntents == 1 ){
00562 arrIntents = (
UINT32 *)
SmartNewPtrClear( nProfiles *
sizeof (
UINT32), &aOSErr);
00563
if (aOSErr != 0 ){
00564 err = ERROR_NOT_ENOUGH_MEMORY;
00565
goto CleanupAndExit;
00566 }
00567 arrIntents[0] =
icPerceptual;
00568 arrIntents[1] = aIntentArr[0];
00569
for( i=2; i<nProfiles; i++){
00570 arrIntents[i] =
icAbsoluteColorimetric;
00571
if(
dwFlags &
kUseRelColorimetric ) arrIntents[i] =
icRelativeColorimetric;
00572 }
00573 err =
CWConcatColorWorld4MS( cw, profileSet, arrIntents, nProfiles, theFlags );
00574 arrIntents= (
UINT32 *)
DisposeIfPtr( (
Ptr) arrIntents );
00575 }
00576
else{
00577 err =
CWConcatColorWorld4MS( cw, profileSet, aIntentArr, nIntents, theFlags );
00578 }
00579
#ifdef WRITE_PROFILE
00580
if( err == 0 ){
00581 err =
MyNewDeviceLink( *cw, profileSet,
"MyCreateTransform.pf" );
00582
00583 }
00584
#endif
00585
CleanupAndExit:
00586 profileSet= (
CMConcatProfileSet *)
DisposeIfPtr( (
Ptr) profileSet );
00587
return err;
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626 HCMTRANSFORM WINAPI
CMCreateMultiProfileTransform( LPHPROFILE lpahProfiles,
00627 DWORD nProfiles,
00628 UINT32 *aIntentArr,
00629 UINT32 nIntents,
00630 UINT32 dwFlags )
00631 {
00632
long err;
00633
CMWorldRef cw;
00634
00635 err =
CMCreateMultiProfileTransformInternal( &cw, lpahProfiles, nProfiles, aIntentArr, nIntents,
dwFlags, 0 );
00636
if( err ){
00637 SetLastError( err );
00638
return (
HCMTRANSFORM)(ULONG_PTR)(err & 255);
00639 }
00640 cw =
StoreTransform( cw );
00641
return (
HCMTRANSFORM)cw;
00642 }
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658 BOOL WINAPI
CMDeleteTransform( HCMTRANSFORM hcmTransform )
00659 {
00660
long actTransform = (
long)(ULONG_PTR)hcmTransform - 256;
00661
HCMTRANSFORM aTrans;
00662
CMMModelPtr theModelPtr;
00663
CMWorldRef theWorldRef;
00664
00665 __try {
00666 EnterCriticalSection(&
GlobalCriticalSection);
00667
if( actTransform < IndexTransform && actTransform >= 0 ){
00668 aTrans =
TheTransform[actTransform];
00669
TheTransform[ actTransform ] = 0;
00670
if( actTransform ==
IndexTransform-1 )
IndexTransform--;
00671
return 1;
00672 }
00673
else return 0;
00674 }
00675 __finally{
00676 LeaveCriticalSection(&
GlobalCriticalSection);
00677
00678
LOCK_DATA( aTrans );
00679 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( aTrans ));
00680 theWorldRef = theModelPtr->pBackwardTransform;
00681
UNLOCK_DATA( aTrans );
00682
if( theWorldRef != 0 ){
00683
CWDisposeColorWorld( theWorldRef );
00684 }
00685
00686
CWDisposeColorWorld( aTrans );
00687 }
00688 }
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
BOOL WINAPI
CMCreateProfile( LPLOGCOLORSPACEA lpColorSpace,
00712 LPBYTE *lpProfileData )
00713 {
00714
CMWorldRef cw=0;
00715
long err;
00716
00717
if( lpColorSpace->lcsFilename[0] )
return 0;
00718 err =
MyNewAbstract( lpColorSpace, (
icProfile **)lpProfileData );
00719
00720
if( err ){
00721 SetLastError( err );
00722
goto CleanupAndExit;
00723 }
00724
return 1;
00725 CleanupAndExit:
00726
return 0;
00727 }
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750 BOOL WINAPI
CMCreateProfileW( LPLOGCOLORSPACEW lpColorSpace,
00751 LPBYTE *lpProfileData )
00752 {
00753
CMWorldRef cw=0;
00754
long err;
00755
00756
if( lpColorSpace->lcsFilename[0] )
return 0;
00757 err =
MyNewAbstractW( lpColorSpace, (
icProfile **)lpProfileData );
00758
00759
if( err ){
00760 SetLastError( err );
00761
goto CleanupAndExit;
00762 }
00763
return 1;
00764 CleanupAndExit:
00765
return 0;
00766 }
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 BOOL WINAPI
CMCreateDeviceLinkProfile( LPHPROFILE lpahProfiles,
00812 DWORD nProfiles,
00813 UINT32 *aIntentArr,
00814 UINT32 nIntents,
00815 UINT32 dwFlags,
00816 LPBYTE *lpProfileData )
00817 {
00818
long err;
00819
OSErr aOSErr;
00820
CMWorldRef cw;
00821
CMConcatProfileSet *profileSet;
00822
UINT32 i;
00823
00824 *lpProfileData = 0;
00825
00826 err =
CMCreateMultiProfileTransformInternal( &cw, lpahProfiles, nProfiles, aIntentArr, nIntents,
dwFlags, 0 );
00827
if( err ){
00828 SetLastError( err );
00829
return 0;
00830 }
00831 profileSet = (
CMConcatProfileSet *)
SmartNewPtrClear(
sizeof (
CMConcatProfileSet) + (nProfiles)*
sizeof(
CMProfileRef),&aOSErr);
00832 err = aOSErr;
00833
if (aOSErr == 0 )
00834 {
00835 profileSet->
keyIndex = 0;
00836 profileSet->
count = (
unsigned short)nProfiles;
00837
for( i=0; i<nProfiles; i++)
00838 profileSet->
profileSet[i] = (
CMProfileRef)((
DWORD *)(((PVOID *)lpahProfiles)[i]));
00839 }
00840
else goto CleanupAndExit;
00841
00842 err =
DeviceLinkFill( (
CMMModelPtr)cw, profileSet, (
icProfile **)lpProfileData, aIntentArr[0] );
00843 profileSet= (
CMConcatProfileSet *)
DisposeIfPtr( (
Ptr) profileSet );
00844
00845
if( err )
goto CleanupAndExit;
00846
CWDisposeColorWorld ( cw );
00847
return 1;
00848
00849 CleanupAndExit:
00850
CWDisposeColorWorld ( cw );
00851 SetLastError( err );
00852
return 0;
00853 }
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917 BOOL WINAPI
CMIsProfileValid( HPROFILE hProfile,
00918 LPBOOL lpbValid
00919 )
00920 {
00921
Boolean valid;
00922
00923
CMValidateProfile( (
CMProfileRef)hProfile, &valid );
00924
00925 *lpbValid = valid;
00926
return valid;
00927 }
00928
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
00954 BOOL WINAPI
CMTranslateColors( HCMTRANSFORM hcmTransform,
00955 LPCOLOR lpaInputColors,
00956 DWORD nColors,
00957 COLORTYPE ctInput,
00958 LPCOLOR lpaOutputColors,
00959 COLORTYPE ctOutput )
00960 {
00961
long matchErr;
00962
long i,
n;
00963
00964
n = nColors *
sizeof(COLOR) /
sizeof(
long);
00965
for( i=0; i<
n; i++) lpaOutputColors[ i ] = lpaInputColors[ i ];
00966
00967 matchErr =
CWMatchColors(
CMGetTransform( hcmTransform ), (
CMColor *)lpaOutputColors, nColors );
00968
if( matchErr ){
00969 SetLastError( matchErr );
00970
return 0;
00971 }
00972
return 1;
00973 }
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 BOOL WINAPI
CMCheckColors( HCMTRANSFORM hcmTransform,
01004 LPCOLOR lpaInputColors,
01005 DWORD nColors,
01006 COLORTYPE ctInput,
01007 LPBYTE lpaResult )
01008 {
01009
long matchErr;
01010
01011 matchErr =
CWCheckColorsMS(
CMGetTransform( hcmTransform ), (
CMColor *)lpaInputColors, nColors, lpaResult );
01012
if( matchErr ){
01013 SetLastError( matchErr );
01014
return 0;
01015 }
01016
return 1;
01017 }
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052 BOOL WINAPI
CMTranslateRGBs( HCMTRANSFORM hcmTransform,
01053 LPVOID lpSrcBits,
01054 BMFORMAT bmInput,
01055 DWORD dwWidth,
01056 DWORD dwHeight,
01057 DWORD dwStride,
01058 LPVOID lpDestBits,
01059 BMFORMAT bmOutput,
01060 DWORD dwTranslateDirection )
01061 {
01062
CMBitmapColorSpace spaceIn,spaceOut;
01063
CMBitmap InBitmap,OutBitmap;
01064
long matchErr, inPixelSize, outPixelSize;
01065
BOOL aBgrMode =
FALSE;
01066
CMMModelPtr theModelPtr;
01067
CMWorldRef theWorldRef;
01068
HCMTRANSFORM theTransform =
CMGetTransform( hcmTransform );
01069
01070
if( dwTranslateDirection ==
CMS_BACKWARD ){
01071
if( theTransform == 0 ){
01072 SetLastError( (
DWORD)
cmparamErr );
01073
return 0;
01074 }
01075
LOCK_DATA( theTransform );
01076 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( theTransform ));
01077 theWorldRef = theModelPtr->pBackwardTransform;
01078
UNLOCK_DATA( theTransform );
01079
if( theWorldRef == 0 ){
01080 SetLastError( (
DWORD)
cmparamErr );
01081
return 0;
01082 }
01083 theTransform = (
HCMTRANSFORM)theWorldRef;
01084 }
01085
01086 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01087
if( spaceIn == 0 ){
01088 SetLastError( (
DWORD)
cmInvalidColorSpace );
01089
return 0;
01090 }
01091 spaceOut =
CMGetDataColorSpace( bmOutput, &outPixelSize );
01092
if( spaceOut == 0 ){
01093 SetLastError( (
DWORD)
cmInvalidColorSpace );
01094
return 0;
01095 }
01096 InBitmap.
image = lpSrcBits;
01097 InBitmap.
width = dwWidth;
01098 InBitmap.
height = dwHeight;
01099
if( dwStride == 0 ){
01100 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01101 }
01102
else{
01103 InBitmap.
rowBytes = dwStride;
01104 }
01105 InBitmap.
pixelSize = inPixelSize;
01106 InBitmap.
space = spaceIn;
01107
01108 OutBitmap.
image = lpDestBits;
01109 OutBitmap.
width = dwWidth;
01110 OutBitmap.
height = dwHeight;
01111 OutBitmap.
rowBytes = ( dwWidth * (outPixelSize / 8) + 3 ) & ~3;
01112 OutBitmap.
pixelSize = outPixelSize;
01113 OutBitmap.
space = spaceOut;
01114
01115 matchErr =
CWMatchBitmap( theTransform, &InBitmap,
01116 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01117
if( matchErr ){
01118 SetLastError( matchErr );
01119
return 0;
01120 }
01121
return 1;
01122 }
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167 BOOL WINAPI
CMTranslateRGBsExt( HCMTRANSFORM hcmTransform,
01168 LPVOID lpSrcBits,
01169 BMFORMAT bmInput,
01170 DWORD dwWidth,
01171 DWORD dwHeight,
01172 DWORD dwInputStride,
01173 LPVOID lpDestBits,
01174 BMFORMAT bmOutput,
01175 DWORD dwOutputStride,
01176 LPBMCALLBACKFN lpfnCallback,
01177 LPARAM ulCallbackData )
01178 {
01179
CMBitmapColorSpace spaceIn,spaceOut;
01180
CMBitmap InBitmap,OutBitmap;
01181
long matchErr, inPixelSize, outPixelSize;
01182
BOOL aBgrMode =
FALSE;
01183
01184 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01185
if( spaceIn == 0 ){
01186 SetLastError( (
DWORD)
cmInvalidColorSpace );
01187
return 0;
01188 }
01189 spaceOut =
CMGetDataColorSpace( bmOutput, &outPixelSize );
01190
if( spaceOut == 0 ){
01191 SetLastError( (
DWORD)
cmInvalidColorSpace );
01192
return 0;
01193 }
01194 InBitmap.
image = lpSrcBits;
01195 InBitmap.
width = dwWidth;
01196 InBitmap.
height = dwHeight;
01197
if( dwInputStride == 0 ){
01198 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01199 }
01200
else{
01201 InBitmap.
rowBytes = dwInputStride;
01202 }
01203 InBitmap.
pixelSize = inPixelSize;
01204 InBitmap.
space = spaceIn;
01205
01206 OutBitmap.
image = lpDestBits;
01207 OutBitmap.
width = dwWidth;
01208 OutBitmap.
height = dwHeight;
01209
if( dwOutputStride == 0 ){
01210 OutBitmap.
rowBytes = ( dwWidth * (outPixelSize / 8) + 3 ) & ~3;
01211 }
01212
else{
01213 OutBitmap.
rowBytes = dwOutputStride;
01214 }
01215 OutBitmap.
pixelSize = outPixelSize;
01216 OutBitmap.
space = spaceOut;
01217
01218 matchErr =
CWMatchBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01219 (
CMBitmapCallBackUPP)lpfnCallback,(
void *)ulCallbackData,&OutBitmap );
01220
if( matchErr ){
01221 SetLastError( matchErr );
01222
return 0;
01223 }
01224
return 1;
01225 }
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277 BOOL WINAPI
CMCheckRGBs( HCMTRANSFORM hcmTransform,
01278 LPVOID lpSrcBits,
01279 BMFORMAT bmInput,
01280 DWORD dwWidth,
01281 DWORD dwHeight,
01282 DWORD dwStride,
01283 LPBYTE lpDestBits,
01284 PBMCALLBACKFN pfnCallback,
01285 LPARAM ulCallbackData )
01286
01287 {
01288
CMBitmapColorSpace spaceIn,spaceOut;
01289
CMBitmap InBitmap,OutBitmap;
01290
long matchErr, inPixelSize;
01291
BOOL aBgrMode =
FALSE;
01292
01293 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01294
if( spaceIn == 0 ){
01295 SetLastError( (
DWORD)
cmInvalidColorSpace );
01296
return 0;
01297 }
01298 spaceOut =
cm8PerChannelPacking +
cmGraySpace;
01299
01300
if( spaceOut == 0 )
return 0;
01301 InBitmap.
image = lpSrcBits;
01302 InBitmap.
width = dwWidth;
01303 InBitmap.
height = dwHeight;
01304
if( dwStride == 0 ){
01305 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01306 }
01307
else{
01308 InBitmap.
rowBytes = dwStride;
01309 }
01310 InBitmap.
pixelSize = inPixelSize;
01311 InBitmap.
space = spaceIn;
01312
01313 OutBitmap.
image = lpDestBits;
01314 OutBitmap.
width = dwWidth;
01315 OutBitmap.
height = dwHeight;
01316 OutBitmap.
rowBytes = dwWidth;
01317 OutBitmap.
pixelSize = 8;
01318 OutBitmap.
space =
cmGamutResultSpace;
01319
01320 matchErr =
CWCheckBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01321 (
CMBitmapCallBackUPP)pfnCallback,(
void *)ulCallbackData,&OutBitmap );
01322
01323
if( matchErr ){
01324 SetLastError( matchErr );
01325
return 0;
01326 }
01327
return 1;
01328 }
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354 BOOL WINAPI
CMTranslateRGB( HCMTRANSFORM hcmTransform,
01355 COLORREF colorRef,
01356 LPCOLORREF lpColorRef,
01357 DWORD dwFlags )
01358
01359 {
01360
CMBitmapColorSpace spaceIn;
01361
CMBitmap InBitmap,OutBitmap;
01362
long matchErr;
01363 COLORREF aColorRef = colorRef;
01364
BOOL aBgrMode =
FALSE;
01365
CMBitmapColorSpace In,Out;
01366
CMMModelPtr theModelPtr;
01367
CMWorldRef theWorldRef;
01368
HCMTRANSFORM theTransform =
CMGetTransform( hcmTransform );
01369
01370
if(
dwFlags ==
CMS_BACKWARD ){
01371
if( theTransform == 0 ){
01372 SetLastError( (
DWORD)
cmparamErr );
01373
return 0;
01374 }
01375
LOCK_DATA( theTransform );
01376 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( theTransform ));
01377 theWorldRef = theModelPtr->pBackwardTransform;
01378
UNLOCK_DATA( theTransform );
01379
if( theWorldRef == 0 ){
01380 SetLastError( (
DWORD)
cmparamErr );
01381
return 0;
01382 }
01383 theTransform = (
HCMTRANSFORM)theWorldRef;
01384 }
01385
01386 spaceIn =
cmRGBA32Space;
01387 InBitmap.
image = (
char *)(&aColorRef);
01388 InBitmap.
width = 1;
01389 InBitmap.
height = 1;
01390 InBitmap.
rowBytes = 4;
01391 InBitmap.
pixelSize = 32;
01392 InBitmap.
space = spaceIn;
01393 OutBitmap = InBitmap;
01394 OutBitmap.
image = (
char *)lpColorRef;
01395
01396 matchErr =
CWGetColorSpaces( theTransform, &In, &Out );
01397
if( matchErr ){
01398 SetLastError( matchErr );
01399
return 0;
01400 }
01401
if( Out ==
icSigCmykData ) OutBitmap.
space =
cmKYMC32Space;
01402 matchErr =
CWMatchBitmap( theTransform, &InBitmap,
01403 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01404
if( matchErr ){
01405 SetLastError( matchErr );
01406
return 0;
01407 }
01408
return 1;
01409 }
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433 BOOL WINAPI
CMCheckColorsInGamut( HCMTRANSFORM hcmTransform,
01434 LPARGBQUAD lpaRGBTriplet,
01435 LPBYTE lpBuffer,
01436 UINT nCount )
01437 {
01438
CMBitmap InBitmap,OutBitmap;
01439
long matchErr;
01440
BOOL aBgrMode =
FALSE;
01441
01442 InBitmap.
image = (
char *)(lpaRGBTriplet);
01443 InBitmap.
width = nCount;
01444 InBitmap.
height = 1;
01445 InBitmap.
rowBytes = 3*nCount;
01446 InBitmap.
pixelSize = 24;
01447 InBitmap.
space =
cm8PerChannelPacking +
cmRGBSpace;
01448 OutBitmap = InBitmap;
01449 OutBitmap.
rowBytes = nCount;
01450 OutBitmap.
pixelSize = 8;
01451 OutBitmap.
image = (
char *)lpBuffer;
01452
01453 matchErr =
CWCheckBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01454 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01455
if( matchErr ){
01456 SetLastError( matchErr );
01457
return 0;
01458 }
01459
return 1;
01460 }
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
long FillProfileFromLog( LPLOGCOLORSPACEA lpColorSpace,
01477 PPROFILE theProf )
01478 {
01479
long l;
01480
icProfile *aProf;
01481
CMError err = -1;
01482
01483
if( lpColorSpace->lcsFilename[0] ){
01484 theProf->pProfileData = (
char *)lpColorSpace->lcsFilename;
01485 theProf->dwType = PROFILE_FILENAME;
01486 theProf->cbDataSize = lstrlenA((
const unsigned char *)theProf->pProfileData) *
sizeof(
CHAR);
01487 err = 0;
01488 }
01489
else if( lpColorSpace->lcsCSType ==
LCS_CALIBRATED_RGB ){
01490 err =
MyNewAbstract( lpColorSpace, &aProf );
01491 theProf->pProfileData = ((PVOID *)aProf);
01492 theProf->dwType = PROFILE_MEMBUFFER;
01493 l = *(
DWORD *)(theProf->pProfileData);
01494 theProf->cbDataSize = SwapLong(&l);
01495 }
01496
else theProf->pProfileData = 0;
01497
01498
return err;
01499 }
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
long FillProfileFromLogW( LPLOGCOLORSPACEW lpColorSpace,
01517 PPROFILE theProf )
01518 {
01519
long l;
01520
icProfile *aProf;
01521
CMError err = -1;
01522
01523
if( lpColorSpace->lcsFilename[0] ){
01524 theProf->pProfileData = (
char *)lpColorSpace->lcsFilename;
01525 theProf->dwType = PROFILE_FILENAME;
01526 theProf->cbDataSize = lstrlenW((
const unsigned short *)theProf->pProfileData) *
sizeof(WCHAR);
01527 err = 0;
01528 }
01529
else if( lpColorSpace->lcsCSType ==
LCS_CALIBRATED_RGB ){
01530 err =
MyNewAbstractW( lpColorSpace, &aProf );
01531 theProf->pProfileData = ((PVOID *)aProf);
01532 theProf->dwType = PROFILE_MEMBUFFER;
01533 l = *(
DWORD *)(theProf->pProfileData);
01534 theProf->cbDataSize = SwapLong(&l);
01535 }
01536
else theProf->pProfileData = 0;
01537
01538
return err;
01539 }
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
CMBitmapColorSpace CMGetDataColorSpace( BMFORMAT bmMode,
long *pixelSize )
01556 {
01557
switch( bmMode ){
01558
case BM_565RGB:
01559 *pixelSize = 16;
01560
return cmWord565ColorPacking +
cmRGBSpace;
01561
break;
01562
case BM_x555RGB:
01563 *pixelSize = 16;
01564
return cmWord5ColorPacking +
cmRGBSpace;
01565
break;
01566
case BM_x555XYZ:
01567 *pixelSize = 16;
01568
return cmWord5ColorPacking +
cmXYZSpace;
01569
break;
01570
case BM_x555Yxy:
01571 *pixelSize = 16;
01572
return cmWord5ColorPacking +
cmYXYSpace;
01573
break;
01574
case BM_x555Lab:
01575 *pixelSize = 16;
01576
return cmWord5ColorPacking +
cmLABSpace;
01577
break;
01578
case BM_x555G3CH:
01579 *pixelSize = 16;
01580
return cmWord5ColorPacking +
cmGenericSpace;
01581
break;
01582
case BM_RGBTRIPLETS:
01583 *pixelSize = 24;
01584
return cm8PerChannelPacking +
cmBGRSpace;
01585
break;
01586
case BM_BGRTRIPLETS:
01587 *pixelSize = 24;
01588
return cm8PerChannelPacking +
cmRGBSpace;
01589
break;
01590
case BM_XYZTRIPLETS:
01591 *pixelSize = 24;
01592
return cm8PerChannelPacking +
cmXYZSpace;
01593
break;
01594
case BM_YxyTRIPLETS:
01595 *pixelSize = 24;
01596
return cm8PerChannelPacking +
cmYXYSpace;
01597
break;
01598
case BM_LabTRIPLETS:
01599 *pixelSize = 24;
01600
return cm8PerChannelPacking +
cmLABSpace;
01601
break;
01602
case BM_G3CHTRIPLETS:
01603 *pixelSize = 24;
01604
return cm8PerChannelPacking +
cmGenericSpace;
01605
break;
01606
case BM_5CHANNEL:
01607 *pixelSize = 40;
01608
return cmMCFive8Space;
01609
break;
01610
case BM_6CHANNEL:
01611 *pixelSize = 48;
01612
return cmMCSix8Space;
01613
break;
01614
case BM_7CHANNEL:
01615 *pixelSize = 56;
01616
return cmMCSeven8Space;
01617
break;
01618
case BM_8CHANNEL:
01619 *pixelSize = 64;
01620
return cmMCEight8Space;
01621
break;
01622
case BM_GRAY:
01623 *pixelSize = 8;
01624
return cm8PerChannelPacking +
cmGraySpace;
01625
break;
01626
case BM_xRGBQUADS:
01627 *pixelSize = 32;
01628
return cmBGR32Space;
01629
break;
01630
case BM_xBGRQUADS:
01631 *pixelSize = 32;
01632
return cmRGBA32Space;
01633
break;
01634
#if 0
01635
case BM_xXYZQUADS:
01636 *pixelSize = 32;
01637
return cmLong8ColorPacking +
cmXYZSpace;
01638
break;
01639
case BM_xYxyQUADS:
01640 *pixelSize = 32;
01641
return cmLong8ColorPacking +
cmYXYSpace;
01642
break;
01643
case BM_xLabQUADS:
01644 *pixelSize = 32;
01645
return cmLong8ColorPacking +
cmLABSpace;
01646
break;
01647
#endif
01648
case BM_xG3CHQUADS:
01649 *pixelSize = 32;
01650
return cmLong8ColorPacking +
cmGenericSpace;
01651
break;
01652
case BM_CMYKQUADS:
01653 *pixelSize = 32;
01654
return cmLong8ColorPacking +
cmKYMCSpace;
01655
break;
01656
case BM_KYMCQUADS:
01657 *pixelSize = 32;
01658
return cmLong8ColorPacking +
cmCMYKSpace;
01659
break;
01660
case BM_10b_RGB:
01661 *pixelSize = 32;
01662
return cmLong10ColorPacking +
cmRGBSpace;
01663
break;
01664
case BM_10b_XYZ:
01665 *pixelSize = 32;
01666
return cmLong10ColorPacking +
cmXYZSpace;
01667
break;
01668
case BM_10b_Yxy:
01669 *pixelSize = 32;
01670
return cmLong10ColorPacking +
cmYXYSpace;
01671
break;
01672
case BM_10b_Lab:
01673 *pixelSize = 32;
01674
return cmLong10ColorPacking +
cmLABSpace;
01675
break;
01676
case BM_10b_G3CH:
01677 *pixelSize = 32;
01678
return cmLong10ColorPacking +
cmGenericSpace;
01679
break;
01680
case BM_16b_RGB:
01681 *pixelSize = 48;
01682
return cm16PerChannelPacking +
cmBGRSpace;
01683
break;
01684
case BM_16b_XYZ:
01685 *pixelSize = 48;
01686
return cm16PerChannelPacking +
cmXYZSpace;
01687
break;
01688
case BM_16b_Yxy:
01689 *pixelSize = 48;
01690
return cm16PerChannelPacking +
cmYXYSpace;
01691
break;
01692
case BM_16b_Lab:
01693 *pixelSize = 48;
01694
return cm16PerChannelPacking +
cmLABSpace;
01695
break;
01696
case BM_16b_G3CH:
01697 *pixelSize = 48;
01698
return cm16PerChannelPacking +
cmGenericSpace;
01699
break;
01700
case BM_16b_GRAY:
01701 *pixelSize = 16;
01702
return cmGraySpace;
01703
break;
01704
case BM_NAMED_INDEX:
01705 *pixelSize = 32;
01706
return cmNamedIndexed32Space;
01707
break;
01708
default:
01709 *pixelSize = 0;
01710
return 0;
01711 }
01712 }
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
HCMTRANSFORM WINAPI
CMGetTransform( HCMTRANSFORM hcmTransform )
01728 {
01729
long actTransform = (
long)(ULONG_PTR)hcmTransform - 256;
01730
HCMTRANSFORM aTrans;
01731
01732 __try {
01733 EnterCriticalSection(&GlobalCriticalSection);
01734
if( actTransform < IndexTransform && actTransform >= 0 ){
01735 aTrans =
TheTransform[actTransform];
01736
return aTrans;
01737 }
01738
else return 0;
01739 }
01740 __finally{
01741 LeaveCriticalSection(&GlobalCriticalSection);
01742 }
01743 }
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
CMWorldRef StoreTransform( CMWorldRef aRef )
01759 {
01760
long i;
01761
01762 __try {
01763 EnterCriticalSection(&GlobalCriticalSection);
01764
01765
if(
IndexTransform >= 1000 )
return (
HCMTRANSFORM)ERROR_NOT_ENOUGH_MEMORY;
01766
for( i = 0; i<
IndexTransform ; i++ ){
01767
if(
TheTransform[i] == 0 ){
01768
TheTransform[i] = aRef;
01769
return (
CMWorldRef)(ULONG_PTR)(i + 256 );
01770 }
01771 }
01772
if( i >=
IndexTransform ){
01773
TheTransform[
IndexTransform] = aRef;
01774
IndexTransform++;
01775
return (
CMWorldRef)(ULONG_PTR)(
IndexTransform - 1 + 256);
01776 }
01777 }
01778 __finally{
01779 LeaveCriticalSection(&GlobalCriticalSection);
01780
01781 }
01782
01783
return NULL;
01784 }
01785
01786 BOOL WINAPI
CMConvertColorNameToIndex( HPROFILE aProf, LPCOLOR_NAME aColorNameArr, LPDWORD aDWordArr, DWORD count )
01787 {
01788
CMError err;
01789
01790 err =
CMConvNameToIndexProfile( aProf, aColorNameArr, aDWordArr, count );
01791
if( err ){
01792 SetLastError( err );
01793
return 0;
01794 }
01795
return 1;
01796 }
01797
01798 BOOL WINAPI
CMConvertIndexToColorName( HPROFILE aProf, LPDWORD aDWordArr, LPCOLOR_NAME aColorNameArr, DWORD count )
01799 {
01800
long matchErr;
01801
01802 matchErr =
CMConvIndexToNameProfile( aProf, aDWordArr, aColorNameArr, count );
01803
if( matchErr ){
01804 SetLastError( matchErr );
01805
return 0;
01806 }
01807
return 1;
01808 }
01809
01810 BOOL WINAPI
CMGetNamedProfileInfo( HPROFILE aProf, LPNAMED_PROFILE_INFO Info )
01811 {
01812
long matchErr;
01813
01814 matchErr =
CMGetNamedProfileInfoProfile( aProf, (
pCMNamedProfileInfo)Info );
01815
if( matchErr ){
01816 SetLastError( matchErr );
01817
return 0;
01818 }
01819
return 1;
01820 }
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894