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 HANDLE *
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 DWORD *aIntentArr,
00093 DWORD nIntents,
00094 DWORD dwFlags );
00095
long FillProfileFromLog( LPLOGCOLORSPACEA lpColorSpace,
00096 PPROFILE theProf );
00097
long FillProfileFromLogW( LPLOGCOLORSPACEW lpColorSpace,
00098 PPROFILE theProf );
00099
BOOL WINAPI
CMCreateProfile( LPLOGCOLORSPACEA lpColorSpace,
00100 LPDEVCHARACTER *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 DWORD *aIntentArr,
00108 DWORD nIntents,
00109 DWORD dwFlags,
00110 DWORD 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 DWORD 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 DWORD 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 DWORD *aIntentArr,
00520 DWORD nIntents,
00521 DWORD dwFlags,
00522 DWORD 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 DWORD *aIntentArr,
00629 DWORD nIntents,
00630 DWORD 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 =
NULL;
00662
CMMModelPtr theModelPtr;
00663
CMWorldRef theWorldRef;
00664
BOOL bReturn = 0;
00665
00666 __try {
00667 EnterCriticalSection(&
GlobalCriticalSection);
00668
if( actTransform < IndexTransform && actTransform >= 0 ){
00669 aTrans =
TheTransform[actTransform];
00670
TheTransform[ actTransform ] = 0;
00671
if( actTransform ==
IndexTransform-1 )
IndexTransform--;
00672 bReturn = 1;
00673 }
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
return bReturn;
00689 }
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712 BOOL WINAPI
CMCreateProfile( LPLOGCOLORSPACEA lpColorSpace,
00713 LPBYTE *lpProfileData )
00714 {
00715
CMWorldRef cw=0;
00716
long err;
00717
00718
if( lpColorSpace->lcsFilename[0] )
return 0;
00719 err =
MyNewAbstract( lpColorSpace, (
icProfile **)lpProfileData );
00720
00721
if( err ){
00722 SetLastError( err );
00723
goto CleanupAndExit;
00724 }
00725
return 1;
00726 CleanupAndExit:
00727
return 0;
00728 }
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751 BOOL WINAPI
CMCreateProfileW( LPLOGCOLORSPACEW lpColorSpace,
00752 LPBYTE *lpProfileData )
00753 {
00754
CMWorldRef cw=0;
00755
long err;
00756
00757
if( lpColorSpace->lcsFilename[0] )
return 0;
00758 err =
MyNewAbstractW( lpColorSpace, (
icProfile **)lpProfileData );
00759
00760
if( err ){
00761 SetLastError( err );
00762
goto CleanupAndExit;
00763 }
00764
return 1;
00765 CleanupAndExit:
00766
return 0;
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
00812 BOOL WINAPI
CMCreateDeviceLinkProfile( LPHPROFILE lpahProfiles,
00813 DWORD nProfiles,
00814 DWORD *aIntentArr,
00815 DWORD nIntents,
00816 DWORD dwFlags,
00817 LPBYTE *lpProfileData )
00818 {
00819
long err;
00820
OSErr aOSErr;
00821
CMWorldRef cw;
00822
CMConcatProfileSet *profileSet;
00823
UINT32 i;
00824
00825 *lpProfileData = 0;
00826
00827 err =
CMCreateMultiProfileTransformInternal( &cw, lpahProfiles, nProfiles, aIntentArr, nIntents,
dwFlags, 0 );
00828
if( err ){
00829 SetLastError( err );
00830
return 0;
00831 }
00832 profileSet = (
CMConcatProfileSet *)
SmartNewPtrClear(
sizeof (
CMConcatProfileSet) + (nProfiles)*
sizeof(
CMProfileRef),&aOSErr);
00833 err = aOSErr;
00834
if (aOSErr == 0 )
00835 {
00836 profileSet->
keyIndex = 0;
00837 profileSet->
count = (
unsigned short)nProfiles;
00838
for( i=0; i<nProfiles; i++)
00839 profileSet->
profileSet[i] = (
CMProfileRef)((
DWORD *)(((PVOID *)lpahProfiles)[i]));
00840 }
00841
else goto CleanupAndExit;
00842
00843 err =
DeviceLinkFill( (
CMMModelPtr)cw, profileSet, (
icProfile **)lpProfileData, aIntentArr[0] );
00844 profileSet= (
CMConcatProfileSet *)
DisposeIfPtr( (
Ptr) profileSet );
00845
00846
if( err )
goto CleanupAndExit;
00847
CWDisposeColorWorld ( cw );
00848
return 1;
00849
00850 CleanupAndExit:
00851
CWDisposeColorWorld ( cw );
00852 SetLastError( err );
00853
return 0;
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
00918 BOOL WINAPI
CMIsProfileValid( HPROFILE hProfile,
00919 LPBOOL lpbValid
00920 )
00921 {
00922
Boolean valid;
00923
00924
CMValidateProfile( (
CMProfileRef)hProfile, &valid );
00925
00926 *lpbValid = valid;
00927
return valid;
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
00955 BOOL WINAPI
CMTranslateColors( HCMTRANSFORM hcmTransform,
00956 LPCOLOR lpaInputColors,
00957 DWORD nColors,
00958 COLORTYPE ctInput,
00959 LPCOLOR lpaOutputColors,
00960 COLORTYPE ctOutput )
00961 {
00962
long matchErr;
00963
DWORD i;
00964
00965
if (lpaOutputColors != lpaInputColors){
00966
for( i=0; i<nColors; i++) lpaOutputColors[ i ] = lpaInputColors[ i ];
00967 }
00968
00969 matchErr =
CWMatchColors(
CMGetTransform( hcmTransform ), (
CMColor *)lpaOutputColors, nColors );
00970
if( matchErr ){
00971 SetLastError( matchErr );
00972
return 0;
00973 }
00974
return 1;
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
01004
01005 BOOL WINAPI
CMCheckColors( HCMTRANSFORM hcmTransform,
01006 LPCOLOR lpaInputColors,
01007 DWORD nColors,
01008 COLORTYPE ctInput,
01009 LPBYTE lpaResult )
01010 {
01011
long matchErr;
01012
01013 matchErr =
CWCheckColorsMS(
CMGetTransform( hcmTransform ), (
CMColor *)lpaInputColors, nColors, lpaResult );
01014
if( matchErr ){
01015 SetLastError( matchErr );
01016
return 0;
01017 }
01018
return 1;
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
01053
01054 BOOL WINAPI
CMTranslateRGBs( HCMTRANSFORM hcmTransform,
01055 LPVOID lpSrcBits,
01056 BMFORMAT bmInput,
01057 DWORD dwWidth,
01058 DWORD dwHeight,
01059 DWORD dwStride,
01060 LPVOID lpDestBits,
01061 BMFORMAT bmOutput,
01062 DWORD dwTranslateDirection )
01063 {
01064
CMBitmapColorSpace spaceIn,spaceOut;
01065
CMBitmap InBitmap,OutBitmap;
01066
long matchErr, inPixelSize, outPixelSize;
01067
BOOL aBgrMode =
FALSE;
01068
CMMModelPtr theModelPtr;
01069
CMWorldRef theWorldRef;
01070
HCMTRANSFORM theTransform =
CMGetTransform( hcmTransform );
01071
01072
if( dwTranslateDirection ==
CMS_BACKWARD ){
01073
if( theTransform == 0 ){
01074 SetLastError( (
DWORD)
cmparamErr );
01075
return 0;
01076 }
01077
LOCK_DATA( theTransform );
01078 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( theTransform ));
01079 theWorldRef = theModelPtr->pBackwardTransform;
01080
UNLOCK_DATA( theTransform );
01081
if( theWorldRef == 0 ){
01082 SetLastError( (
DWORD)
cmparamErr );
01083
return 0;
01084 }
01085 theTransform = (
HCMTRANSFORM)theWorldRef;
01086 }
01087
01088 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01089
if( spaceIn == 0 ){
01090 SetLastError( (
DWORD)
cmInvalidColorSpace );
01091
return 0;
01092 }
01093 spaceOut =
CMGetDataColorSpace( bmOutput, &outPixelSize );
01094
if( spaceOut == 0 ){
01095 SetLastError( (
DWORD)
cmInvalidColorSpace );
01096
return 0;
01097 }
01098 InBitmap.
image = lpSrcBits;
01099 InBitmap.
width = dwWidth;
01100 InBitmap.
height = dwHeight;
01101
if( dwStride == 0 ){
01102 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01103 }
01104
else{
01105 InBitmap.
rowBytes = dwStride;
01106 }
01107 InBitmap.
pixelSize = inPixelSize;
01108 InBitmap.
space = spaceIn;
01109
01110 OutBitmap.
image = lpDestBits;
01111 OutBitmap.
width = dwWidth;
01112 OutBitmap.
height = dwHeight;
01113 OutBitmap.
rowBytes = ( dwWidth * (outPixelSize / 8) + 3 ) & ~3;
01114 OutBitmap.
pixelSize = outPixelSize;
01115 OutBitmap.
space = spaceOut;
01116
01117 matchErr =
CWMatchBitmap( theTransform, &InBitmap,
01118 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01119
if( matchErr ){
01120 SetLastError( matchErr );
01121
return 0;
01122 }
01123
return 1;
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
01168
01169 BOOL WINAPI
CMTranslateRGBsExt( HCMTRANSFORM hcmTransform,
01170 LPVOID lpSrcBits,
01171 BMFORMAT bmInput,
01172 DWORD dwWidth,
01173 DWORD dwHeight,
01174 DWORD dwInputStride,
01175 LPVOID lpDestBits,
01176 BMFORMAT bmOutput,
01177 DWORD dwOutputStride,
01178 LPBMCALLBACKFN lpfnCallback,
01179 LPARAM ulCallbackData )
01180 {
01181
CMBitmapColorSpace spaceIn,spaceOut;
01182
CMBitmap InBitmap,OutBitmap;
01183
long matchErr, inPixelSize, outPixelSize;
01184
BOOL aBgrMode =
FALSE;
01185
01186 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01187
if( spaceIn == 0 ){
01188 SetLastError( (
DWORD)
cmInvalidColorSpace );
01189
return 0;
01190 }
01191 spaceOut =
CMGetDataColorSpace( bmOutput, &outPixelSize );
01192
if( spaceOut == 0 ){
01193 SetLastError( (
DWORD)
cmInvalidColorSpace );
01194
return 0;
01195 }
01196 InBitmap.
image = lpSrcBits;
01197 InBitmap.
width = dwWidth;
01198 InBitmap.
height = dwHeight;
01199
if( dwInputStride == 0 ){
01200 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01201 }
01202
else{
01203 InBitmap.
rowBytes = dwInputStride;
01204 }
01205 InBitmap.
pixelSize = inPixelSize;
01206 InBitmap.
space = spaceIn;
01207
01208 OutBitmap.
image = lpDestBits;
01209 OutBitmap.
width = dwWidth;
01210 OutBitmap.
height = dwHeight;
01211
if( dwOutputStride == 0 ){
01212 OutBitmap.
rowBytes = ( dwWidth * (outPixelSize / 8) + 3 ) & ~3;
01213 }
01214
else{
01215 OutBitmap.
rowBytes = dwOutputStride;
01216 }
01217 OutBitmap.
pixelSize = outPixelSize;
01218 OutBitmap.
space = spaceOut;
01219
01220 matchErr =
CWMatchBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01221 (
CMBitmapCallBackUPP)lpfnCallback,(
void *)ulCallbackData,&OutBitmap );
01222
if( matchErr ){
01223 SetLastError( matchErr );
01224
return 0;
01225 }
01226
return 1;
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
01278
01279 BOOL WINAPI
CMCheckRGBs( HCMTRANSFORM hcmTransform,
01280 LPVOID lpSrcBits,
01281 BMFORMAT bmInput,
01282 DWORD dwWidth,
01283 DWORD dwHeight,
01284 DWORD dwStride,
01285 LPBYTE lpDestBits,
01286 PBMCALLBACKFN pfnCallback,
01287 LPARAM ulCallbackData )
01288
01289 {
01290
CMBitmapColorSpace spaceIn,spaceOut;
01291
CMBitmap InBitmap,OutBitmap;
01292
long matchErr, inPixelSize;
01293
BOOL aBgrMode =
FALSE;
01294
01295 spaceIn =
CMGetDataColorSpace( bmInput, &inPixelSize );
01296
if( spaceIn == 0 ){
01297 SetLastError( (
DWORD)
cmInvalidColorSpace );
01298
return 0;
01299 }
01300 spaceOut =
cm8PerChannelPacking +
cmGraySpace;
01301
01302
if( spaceOut == 0 )
return 0;
01303 InBitmap.
image = lpSrcBits;
01304 InBitmap.
width = dwWidth;
01305 InBitmap.
height = dwHeight;
01306
if( dwStride == 0 ){
01307 InBitmap.
rowBytes = ( dwWidth * (inPixelSize / 8) + 3 ) & ~3;
01308 }
01309
else{
01310 InBitmap.
rowBytes = dwStride;
01311 }
01312 InBitmap.
pixelSize = inPixelSize;
01313 InBitmap.
space = spaceIn;
01314
01315 OutBitmap.
image = lpDestBits;
01316 OutBitmap.
width = dwWidth;
01317 OutBitmap.
height = dwHeight;
01318 OutBitmap.
rowBytes = dwWidth;
01319 OutBitmap.
pixelSize = 8;
01320 OutBitmap.
space =
cmGamutResultSpace;
01321
01322 matchErr =
CWCheckBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01323 (
CMBitmapCallBackUPP)pfnCallback,(
void *)ulCallbackData,&OutBitmap );
01324
01325
if( matchErr ){
01326 SetLastError( matchErr );
01327
return 0;
01328 }
01329
return 1;
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
01355
01356 BOOL WINAPI
CMTranslateRGB( HCMTRANSFORM hcmTransform,
01357 COLORREF colorRef,
01358 LPCOLORREF lpColorRef,
01359 DWORD dwFlags )
01360
01361 {
01362
CMBitmapColorSpace spaceIn;
01363
CMBitmap InBitmap,OutBitmap;
01364
long matchErr;
01365 COLORREF aColorRef = colorRef;
01366
BOOL aBgrMode =
FALSE;
01367
CMBitmapColorSpace In,Out;
01368
CMMModelPtr theModelPtr;
01369
CMWorldRef theWorldRef;
01370
HCMTRANSFORM theTransform =
CMGetTransform( hcmTransform );
01371
01372
if(
dwFlags ==
CMS_BACKWARD ){
01373
if( theTransform == 0 ){
01374 SetLastError( (
DWORD)
cmparamErr );
01375
return 0;
01376 }
01377
LOCK_DATA( theTransform );
01378 theModelPtr = (
CMMModelPtr)(
DATA_2_PTR( theTransform ));
01379 theWorldRef = theModelPtr->pBackwardTransform;
01380
UNLOCK_DATA( theTransform );
01381
if( theWorldRef == 0 ){
01382 SetLastError( (
DWORD)
cmparamErr );
01383
return 0;
01384 }
01385 theTransform = (
HCMTRANSFORM)theWorldRef;
01386 }
01387
01388 spaceIn =
cmRGBA32Space;
01389 InBitmap.
image = (
char *)(&aColorRef);
01390 InBitmap.
width = 1;
01391 InBitmap.
height = 1;
01392 InBitmap.
rowBytes = 4;
01393 InBitmap.
pixelSize = 32;
01394 InBitmap.
space = spaceIn;
01395 OutBitmap = InBitmap;
01396 OutBitmap.
image = (
char *)lpColorRef;
01397
01398 matchErr =
CWGetColorSpaces( theTransform, &In, &Out );
01399
if( matchErr ){
01400 SetLastError( matchErr );
01401
return 0;
01402 }
01403
if( Out ==
icSigCmykData ) OutBitmap.
space =
cmKYMC32Space;
01404 matchErr =
CWMatchBitmap( theTransform, &InBitmap,
01405 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01406
if( matchErr ){
01407 SetLastError( matchErr );
01408
return 0;
01409 }
01410
return 1;
01411 }
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435 BOOL WINAPI
CMCheckColorsInGamut( HCMTRANSFORM hcmTransform,
01436 RGBTRIPLE *lpaRGBTriplet,
01437 LPBYTE lpBuffer,
01438 UINT nCount )
01439 {
01440
CMBitmap InBitmap,OutBitmap;
01441
long matchErr;
01442
BOOL aBgrMode =
FALSE;
01443
01444 InBitmap.
image = (
char *)(lpaRGBTriplet);
01445 InBitmap.
width = nCount;
01446 InBitmap.
height = 1;
01447 InBitmap.
rowBytes = 3*nCount;
01448 InBitmap.
pixelSize = 24;
01449 InBitmap.
space =
cm8PerChannelPacking +
cmRGBSpace;
01450 OutBitmap = InBitmap;
01451 OutBitmap.
rowBytes = nCount;
01452 OutBitmap.
pixelSize = 8;
01453 OutBitmap.
image = (
char *)lpBuffer;
01454
01455 matchErr =
CWCheckBitmap(
CMGetTransform( hcmTransform ), &InBitmap,
01456 (
CMBitmapCallBackUPP)0,(
void *)
NULL,&OutBitmap );
01457
if( matchErr ){
01458 SetLastError( matchErr );
01459
return 0;
01460 }
01461
return 1;
01462 }
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478 long FillProfileFromLog( LPLOGCOLORSPACEA lpColorSpace,
01479 PPROFILE theProf )
01480 {
01481
long l;
01482
icProfile *aProf;
01483
CMError err = -1;
01484
01485
if( lpColorSpace->lcsFilename[0] ){
01486 theProf->pProfileData = (
char *)lpColorSpace->lcsFilename;
01487 theProf->dwType = PROFILE_FILENAME;
01488 theProf->cbDataSize = lstrlenA((
const unsigned char *)theProf->pProfileData) *
sizeof(
CHAR);
01489 err = 0;
01490 }
01491
else if( lpColorSpace->lcsCSType ==
LCS_CALIBRATED_RGB ){
01492 err =
MyNewAbstract( lpColorSpace, &aProf );
01493 theProf->pProfileData = ((PVOID *)aProf);
01494 theProf->dwType = PROFILE_MEMBUFFER;
01495 l = *(
DWORD *)(theProf->pProfileData);
01496 theProf->cbDataSize = SwapLong(&l);
01497 }
01498
else theProf->pProfileData = 0;
01499
01500
return err;
01501 }
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518 long FillProfileFromLogW( LPLOGCOLORSPACEW lpColorSpace,
01519 PPROFILE theProf )
01520 {
01521
long l;
01522
icProfile *aProf;
01523
CMError err = -1;
01524
01525
if( lpColorSpace->lcsFilename[0] ){
01526 theProf->pProfileData = (
char *)lpColorSpace->lcsFilename;
01527 theProf->dwType = PROFILE_FILENAME;
01528 theProf->cbDataSize = lstrlenW((
const unsigned short *)theProf->pProfileData) *
sizeof(WCHAR);
01529 err = 0;
01530 }
01531
else if( lpColorSpace->lcsCSType ==
LCS_CALIBRATED_RGB ){
01532 err =
MyNewAbstractW( lpColorSpace, &aProf );
01533 theProf->pProfileData = ((PVOID *)aProf);
01534 theProf->dwType = PROFILE_MEMBUFFER;
01535 l = *(
DWORD *)(theProf->pProfileData);
01536 theProf->cbDataSize = SwapLong(&l);
01537 }
01538
else theProf->pProfileData = 0;
01539
01540
return err;
01541 }
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557 CMBitmapColorSpace CMGetDataColorSpace( BMFORMAT bmMode,
long *pixelSize )
01558 {
01559
switch( bmMode ){
01560
case BM_565RGB:
01561 *pixelSize = 16;
01562
return cmWord565ColorPacking +
cmRGBSpace;
01563
break;
01564
case BM_x555RGB:
01565 *pixelSize = 16;
01566
return cmWord5ColorPacking +
cmRGBSpace;
01567
break;
01568
case BM_x555XYZ:
01569 *pixelSize = 16;
01570
return cmWord5ColorPacking +
cmXYZSpace;
01571
break;
01572
case BM_x555Yxy:
01573 *pixelSize = 16;
01574
return cmWord5ColorPacking +
cmYXYSpace;
01575
break;
01576
case BM_x555Lab:
01577 *pixelSize = 16;
01578
return cmWord5ColorPacking +
cmLABSpace;
01579
break;
01580
case BM_x555G3CH:
01581 *pixelSize = 16;
01582
return cmWord5ColorPacking +
cmGenericSpace;
01583
break;
01584
case BM_RGBTRIPLETS:
01585 *pixelSize = 24;
01586
return cm8PerChannelPacking +
cmBGRSpace;
01587
break;
01588
case BM_BGRTRIPLETS:
01589 *pixelSize = 24;
01590
return cm8PerChannelPacking +
cmRGBSpace;
01591
break;
01592
case BM_XYZTRIPLETS:
01593 *pixelSize = 24;
01594
return cm8PerChannelPacking +
cmXYZSpace;
01595
break;
01596
case BM_YxyTRIPLETS:
01597 *pixelSize = 24;
01598
return cm8PerChannelPacking +
cmYXYSpace;
01599
break;
01600
case BM_LabTRIPLETS:
01601 *pixelSize = 24;
01602
return cm8PerChannelPacking +
cmLABSpace;
01603
break;
01604
case BM_G3CHTRIPLETS:
01605 *pixelSize = 24;
01606
return cm8PerChannelPacking +
cmGenericSpace;
01607
break;
01608
case BM_5CHANNEL:
01609 *pixelSize = 40;
01610
return cmMCFive8Space;
01611
break;
01612
case BM_6CHANNEL:
01613 *pixelSize = 48;
01614
return cmMCSix8Space;
01615
break;
01616
case BM_7CHANNEL:
01617 *pixelSize = 56;
01618
return cmMCSeven8Space;
01619
break;
01620
case BM_8CHANNEL:
01621 *pixelSize = 64;
01622
return cmMCEight8Space;
01623
break;
01624
case BM_GRAY:
01625 *pixelSize = 8;
01626
return cm8PerChannelPacking +
cmGraySpace;
01627
break;
01628
case BM_xRGBQUADS:
01629 *pixelSize = 32;
01630
return cmBGR32Space;
01631
break;
01632
case BM_xBGRQUADS:
01633 *pixelSize = 32;
01634
return cmRGBA32Space;
01635
break;
01636
#if 0
01637
case BM_xXYZQUADS:
01638 *pixelSize = 32;
01639
return cmLong8ColorPacking +
cmXYZSpace;
01640
break;
01641
case BM_xYxyQUADS:
01642 *pixelSize = 32;
01643
return cmLong8ColorPacking +
cmYXYSpace;
01644
break;
01645
case BM_xLabQUADS:
01646 *pixelSize = 32;
01647
return cmLong8ColorPacking +
cmLABSpace;
01648
break;
01649
#endif
01650
case BM_xG3CHQUADS:
01651 *pixelSize = 32;
01652
return cmLong8ColorPacking +
cmGenericSpace;
01653
break;
01654
case BM_CMYKQUADS:
01655 *pixelSize = 32;
01656
return cmLong8ColorPacking +
cmKYMCSpace;
01657
break;
01658
case BM_KYMCQUADS:
01659 *pixelSize = 32;
01660
return cmLong8ColorPacking +
cmCMYKSpace;
01661
break;
01662
case BM_10b_RGB:
01663 *pixelSize = 32;
01664
return cmLong10ColorPacking +
cmRGBSpace;
01665
break;
01666
case BM_10b_XYZ:
01667 *pixelSize = 32;
01668
return cmLong10ColorPacking +
cmXYZSpace;
01669
break;
01670
case BM_10b_Yxy:
01671 *pixelSize = 32;
01672
return cmLong10ColorPacking +
cmYXYSpace;
01673
break;
01674
case BM_10b_Lab:
01675 *pixelSize = 32;
01676
return cmLong10ColorPacking +
cmLABSpace;
01677
break;
01678
case BM_10b_G3CH:
01679 *pixelSize = 32;
01680
return cmLong10ColorPacking +
cmGenericSpace;
01681
break;
01682
case BM_16b_RGB:
01683 *pixelSize = 48;
01684
return cm16PerChannelPacking +
cmBGRSpace;
01685
break;
01686
case BM_16b_XYZ:
01687 *pixelSize = 48;
01688
return cm16PerChannelPacking +
cmXYZSpace;
01689
break;
01690
case BM_16b_Yxy:
01691 *pixelSize = 48;
01692
return cm16PerChannelPacking +
cmYXYSpace;
01693
break;
01694
case BM_16b_Lab:
01695 *pixelSize = 48;
01696
return cm16PerChannelPacking +
cmLABSpace;
01697
break;
01698
case BM_16b_G3CH:
01699 *pixelSize = 48;
01700
return cm16PerChannelPacking +
cmGenericSpace;
01701
break;
01702
case BM_16b_GRAY:
01703 *pixelSize = 16;
01704
return cmGraySpace;
01705
break;
01706
case BM_NAMED_INDEX:
01707 *pixelSize = 32;
01708
return cmNamedIndexed32Space;
01709
break;
01710
default:
01711 *pixelSize = 0;
01712
return 0;
01713 }
01714 }
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729 HCMTRANSFORM WINAPI
CMGetTransform( HCMTRANSFORM hcmTransform )
01730 {
01731
long actTransform = (
long)(ULONG_PTR)hcmTransform - 256;
01732
HCMTRANSFORM aTrans =
NULL;
01733
01734 __try {
01735 EnterCriticalSection(&
GlobalCriticalSection);
01736
if( actTransform < IndexTransform && actTransform >= 0 ){
01737 aTrans =
TheTransform[actTransform];
01738 }
01739 }
01740 __finally{
01741 LeaveCriticalSection(&
GlobalCriticalSection);
01742 }
01743
return aTrans;
01744 }
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759 CMWorldRef StoreTransform( CMWorldRef aRef )
01760 {
01761
long i;
01762
CMWorldRef cw =
NULL;
01763
01764 __try {
01765 EnterCriticalSection(&
GlobalCriticalSection);
01766
01767
if(
IndexTransform >= 1000 )
return (
HCMTRANSFORM)ERROR_NOT_ENOUGH_MEMORY;
01768
for( i = 0; i<
IndexTransform ; i++ ){
01769
if(
TheTransform[i] == 0 ){
01770
TheTransform[i] = aRef;
01771 cw = (
CMWorldRef)(ULONG_PTR)(i + 256 );
01772 }
01773 }
01774
if( i >=
IndexTransform ){
01775
TheTransform[
IndexTransform] = aRef;
01776
IndexTransform++;
01777 cw = (
CMWorldRef)(ULONG_PTR)(
IndexTransform - 1 + 256);
01778 }
01779 }
01780 __finally{
01781 LeaveCriticalSection(&
GlobalCriticalSection);
01782 }
01783
01784
return cw;
01785 }
01786
01787 BOOL WINAPI
CMConvertColorNameToIndex( HPROFILE aProf, LPCOLOR_NAME aColorNameArr, LPDWORD aDWordArr, DWORD count )
01788 {
01789
CMError err;
01790
01791 err =
CMConvNameToIndexProfile( aProf, aColorNameArr, aDWordArr, count );
01792
if( err ){
01793 SetLastError( err );
01794
return 0;
01795 }
01796
return 1;
01797 }
01798
01799 BOOL WINAPI
CMConvertIndexToColorName( HPROFILE aProf, LPDWORD aDWordArr, LPCOLOR_NAME aColorNameArr, DWORD count )
01800 {
01801
long matchErr;
01802
01803 matchErr =
CMConvIndexToNameProfile( aProf, aDWordArr, aColorNameArr, count );
01804
if( matchErr ){
01805 SetLastError( matchErr );
01806
return 0;
01807 }
01808
return 1;
01809 }
01810
01811 BOOL WINAPI
CMGetNamedProfileInfo( HPROFILE aProf, LPNAMED_PROFILE_INFO Info )
01812 {
01813
long matchErr;
01814
01815 matchErr =
CMGetNamedProfileInfoProfile( aProf, (
pCMNamedProfileInfo)Info );
01816
if( matchErr ){
01817 SetLastError( matchErr );
01818
return 0;
01819 }
01820
return 1;
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
01895