Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

icm32.c

Go to the documentation of this file.
00001 /* 00002 File: MsLinoCMM.c 00003 00004 Contains: 00005 Interface to MS ICM 00006 Written by: U. J. Krabbenhoeft 00007 00008 Copyright: � 1993-1997 by Heidelberger Druckmaschinen AG, all rights reserved. 00009 00010 Version: 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 //#define WRITE_PROFILE 00043 #endif 00044 /* ______________________________________________________________________ 00045 static section for holding the CW pointers 00046 _____________________________________________________________________ */ 00047 00048 long IndexTransform=0; 00049 HCMTRANSFORM TheTransform[1000] = {0}; 00050 00051 CRITICAL_SECTION GlobalCriticalSection; /* for multithreaded dll */ 00052 00053 /* ______________________________________________________________________ */ 00054 00055 /* ______________________________________________________________________ 00056 00057 BOOL WINAPI DllMain ( HINSTANCE hinstDLL, 00058 DWORD fdwReason, 00059 LPVOID lpvReserved ) 00060 00061 Abstract: 00062 DLL Entrypoint 00063 00064 Params: 00065 standard 00066 00067 Return: 00068 TRUE 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 DWORD WINAPI CMGetInfo( DWORD dwInfo ); 00114 00115 Abstract: 00116 The CMGetInfo function retrieves various information about the ICM. 00117 00118 Parameter Description 00119 00120 dwInfo Values that can have the following meaning: 00121 00122 Type Meaning 00123 00124 CMS_VERSION Retrieves the version of Windows supported. 00125 CMS_IDENT Retrieves the identifier of the ICMDLL. 00126 CMS_DRIVER_LEVEL Retrieves the support level of a device driver. 00127 00128 Returns 00129 CMGetInfo returns zero if an invalid parameter is passed in. If successful it returns a value that depends on the information requested. 00130 For CMS_VERSION CMGetInfo retrieves the version of Windows ICM interface supported by this module. For Windows 95 this should be 4.0, represented as 0x00040000. 00131 For CMS_IDENT CMGetInfo retrieves the identifier of the ICMDLL. This is the same as the ICC color profile header identifier. 00132 For CMS_DRIVER_LEVEL CMGetInfo retrieves the supported level of the device driver. ICMDLLs should return CMS_LEVEL_1. The values have been defined in a previous section. 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 ){ /* this is for the backward transform */ 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 ); /* delete other 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 HCMTRANSFORM WINAPI CMCreateTransformExt( LPLOGCOLORSPACEA lpColorSpace, 00253 LPDEVCHARACTER lpDevCharacter, 00254 LPDEVCHARACTER lpTargetDevCharacter, 00255 UINT32 dwFlags ); 00256 00257 Abstract: 00258 The CMCreateTransformExt function creates a color transform that 00259 maps from an input LogColorSpace to an optional target to an 00260 output device. 00261 00262 Parameter Description 00263 lpColorSpace Pointer to input color space. If lcsFilename is non-zero, 00264 it is a pointer to the memory mapped profile. 00265 LpDevCharacter Pointer to memory mapped device profile 00266 lpTargetDevCharacter Pointer to memory mapped target profile 00267 dwFlags Specifies flags to control creation of the transform. 00268 It is up to the CMM to determine how best to use these flags. 00269 Set the high-order word to ENABLE_GAMUT_CHECKING if the transform 00270 will be used for gamut checking. 00271 The low-order WORD can have one of the following constant values: 00272 PROOF_MODE, NORMAL_MODE, BEST_MODE. 00273 Moving from PROOF_MODE to BEST_MODE, output quality generally improves and transform speed declines. 00274 00275 Returns 00276 If the function is successful, it returns a color transform 00277 in the range 256 to 65535. Otherwise it returns an error code 00278 (return value < 255). 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 /* Test for CMCreateProfile */ 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 // Handles are not provided below LCS structure, so create handles 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 HCMTRANSFORM WINAPI CMCreateTransform( LPLOGCOLORSPACEA lpColorSpace, 00390 LPDEVCHARACTER lpDevCharacter, 00391 LPDEVCHARACTER lpTargetDevCharacter ); 00392 00393 Abstract: 00394 The CMCreateTransform function creates a color transform that 00395 maps from an input LogColorSpace to an optional target to an 00396 output device. 00397 00398 Parameter Description 00399 lpColorSpace Pointer to input color space. If lcsFilename is non-zero, 00400 it is a pointer to the memory mapped profile. 00401 LpDevCharacter Pointer to memory mapped device profile 00402 lpTargetDevCharacter Pointer to memory mapped target profile 00403 00404 Returns 00405 If the function is successful, it returns a color transform 00406 in the range 256 to 65535. Otherwise it returns an error code 00407 (return value < 255). 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 HCMTRANSFORM WINAPI CMCreateTransformExtW( LPLOGCOLORSPACEW lpColorSpace, 00419 LPDEVCHARACTER lpDevCharacter, 00420 LPDEVCHARACTER lpTargetDevCharacter, 00421 UINT32 dwFlags ); 00422 00423 Abstract: 00424 The CMCreateTransformExtW function creates a color transform that 00425 maps from an input LogColorSpace to an optional target to an 00426 output device. 00427 00428 Parameter Description 00429 lpColorSpace Pointer to input color space. If lcsFilename is non-zero, it is a pointer to the memory mapped profile. 00430 LpDevCharacter Pointer to memory mapped device profile 00431 lpTargetDevCharacter Pointer to memory mapped target profile 00432 dwFlags Specifies flags to control creation of the transform. 00433 It is up to the CMM to determine how best to use these flags. 00434 Set the high-order word to ENABLE_GAMUT_CHECKING if the transform 00435 will be used for gamut checking. 00436 The low-order WORD can have one of the following constant values: 00437 PROOF_MODE, NORMAL_MODE, BEST_MODE. 00438 Moving from PROOF_MODE to BEST_MODE, output quality generally improves and transform speed declines. 00439 00440 Returns 00441 If the function is successful, it returns a color transform 00442 in the range 256 to 65535. Otherwise it returns an error code 00443 (return value < 255). 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 HCMTRANSFORM WINAPI CMCreateTransformW( LPLOGCOLORSPACEW lpColorSpace, 00490 LPDEVCHARACTER lpDevCharacter, 00491 LPDEVCHARACTER lpTargetDevCharacter ); 00492 00493 Abstract: 00494 The CMCreateTransformW function creates a color transform that 00495 maps from an input LogColorSpace to an optional target to an 00496 output device. 00497 00498 Parameter Description 00499 lpColorSpace Pointer to input color space. If lcsFilename is non-zero, it is a pointer to the memory mapped profile. 00500 LpDevCharacter Pointer to memory mapped device profile 00501 lpTargetDevCharacter Pointer to memory mapped target profile 00502 00503 Returns 00504 If the function is successful, it returns a color transform 00505 in the range 256 to 65535. Otherwise it returns an error code 00506 (return value < 255). 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 //goto CleanupAndExit; 00583 } 00584 #endif 00585 CleanupAndExit: 00586 profileSet= (CMConcatProfileSet *)DisposeIfPtr( (Ptr) profileSet ); 00587 return err; 00588 } 00589 00590 /* ______________________________________________________________________ 00591 00592 HCMTRANSFORM WINAPI CMCreateMultiProfileTransform( LPHPROFILE lpahProfiles, 00593 DWORD nProfiles, 00594 UINT32 *aIntentArr, 00595 UINT32 nIntents, 00596 UINT32 dwFlags ); 00597 00598 Abstract: 00599 The CMCreateMultiProfileTransform function accepts 00600 an array of profiles or a single device link profile 00601 and creates a color transform. 00602 This transform is a mapping from the color space specified 00603 by the first profile to that of the second profile 00604 and so on until the last one. 00605 00606 Parameter Description 00607 lpahProfiles Pointer to an array of profile handles 00608 nProfiles Number of profiles in the array 00609 padwIntents (in) Points to an array of intent structures. 00610 0 = default behavior ( intents out of profiles ) 00611 00612 nIntents (in) Specifies the number of intents in the intent array. 00613 Can be 1, or the same value as nProfiles. 00614 00615 dwFlags (in) Specifies flags to control creation of the transform. 00616 These flags are intended only as hints, and it is up to the CMM 00617 to determine how best to use these flags. 00618 Set the high-order word to ENABLE_GAMUT_CHECKING if the transform will be used 00619 for gamut checking. 00620 The low-order WORD can have one of the following constant values: 00621 PROOF_MODE, NORMAL_MODE, BEST_MODE. Moving from PROOF_MODE to BEST_MODE, 00622 Returns 00623 If the function is successful, it returns a color transform. 00624 Otherwise it returns an error code (return value < 255). 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 BOOL WINAPI CMDeleteTransform( HCMTRANSFORM hcmTransform ); 00646 00647 Abstract: 00648 The CMDeleteTransform function deletes the given color transform, 00649 and frees any memory associated with it. 00650 00651 Parameter Description 00652 hcmTransform Identifies the color transform 00653 00654 Returns 00655 If the function is successful, the return value is nonzero. 00656 Otherwise it is zero. 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 BOOL WINAPI CMCreateProfile( LPLOGCOLORSPACEA lpColorSpace, 00692 LPBYTE *lpProfileData ); 00693 00694 Abstract: 00695 The CMCreateProfile function creates a display color profile 00696 from a LogColorSpace structure. 00697 00698 Parameter Description 00699 lpColorSpace Pointer to color space. lcsFilename field will be NULL. 00700 pProfileData Points to a pointer to a buffer. 00701 If successful the function allocates and fills this buffer. 00702 It is then the calling application�s responsibility to 00703 free this buffer with GlobalFreePtr( lpProfileData ) 00704 when it is no longer needed. 00705 00706 Returns 00707 If the function is successful, it returns nonzero. 00708 Otherwise it returns zero. 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 //err = FillProfileFromLog( lpColorSpace, &theProf ); 00720 if( err ){ 00721 SetLastError( err ); 00722 goto CleanupAndExit; 00723 } 00724 return 1; 00725 CleanupAndExit: 00726 return 0; 00727 } 00728 00729 /* ______________________________________________________________________ 00730 BOOL WINAPI CMCreateProfileW( LPLOGCOLORSPACEW lpColorSpace, 00731 LPBYTE *lpProfileData ); 00732 00733 Abstract: 00734 The CMCreateProfileW function creates a display color profile 00735 from a LogColorSpace structure. 00736 00737 Parameter Description 00738 lpColorSpace Pointer to color space. lcsFilename field will be NULL. 00739 pProfileData Points to a pointer to a buffer. 00740 If successful the function allocates and fills this buffer. 00741 It is then the calling application�s responsibility to 00742 free this buffer with GlobalFreePtr( lpProfileData ) 00743 when it is no longer needed. 00744 00745 Returns 00746 If the function is successful, it returns nonzero. 00747 Otherwise it returns zero. 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 //err = FillProfileFromLogW( lpColorSpace, &theProf ); 00759 if( err ){ 00760 SetLastError( err ); 00761 goto CleanupAndExit; 00762 } 00763 return 1; 00764 CleanupAndExit: 00765 return 0; 00766 } 00767 00768 /* ______________________________________________________________________ 00769 BOOL WINAPI CMCreateDeviceLinkProfile( LPHPROFILE lpahProfiles, 00770 DWORD nProfiles, 00771 UINT32 *aIntentArr, 00772 UINT32 nIntents, 00773 UINT32 dwFlags, 00774 LPBYTE *lpProfileData ); 00775 00776 Abstract: 00777 The CMCreateDeviceLinkProfile function creates a device link 00778 profile as specified by the "ICC Profile Format Specification." 00779 00780 Parameter Description 00781 lpahProfiles Pointer to an array of profile handles 00782 nProfiles Number of profiles in the array 00783 padwIntents Points to an array of rendering intents. 00784 Each rendering intent is represented by one of the following values: 00785 INTENT_PERCEPTUAL 00786 INTENT_SATURATION 00787 INTENT_RELATIVE_COLORIMETRIC 00788 INTENT_ABSOLUTE_COLORIMETRIC 00789 For more information, see Rendering Intents. 00790 00791 nIntents Specifies the number of intents in the intent array. Can be 1, or the same value as nProfiles. 00792 dwFlags Specifies flags to control creation of the transform. These flags are intended only as hints, 00793 and it is up to the CMM to determine how best to use these flags. 00794 Set the high-order word to ENABLE_GAMUT_CHECKING if the transform will be used for gamut checking. 00795 The low-order WORD can have one of the following constant values: 00796 PROOF_MODE, NORMAL_MODE, BEST_MODE. Moving from PROOF_MODE to BEST_MODE, 00797 output quality generally improves. 00798 00799 lpProfileData Points to a pointer to a buffer. 00800 If successful the function allocates and fills this buffer. 00801 It is then the calling application�s responsibility to 00802 free this buffer with GlobalFreePtr( lpProfileData ) 00803 when it is no longer needed. 00804 00805 Returns 00806 If the function is successful, it returns nonzero. 00807 Otherwise it returns zero. SetLastError is used. 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 BOOL WINAPI CMCreateDeviceLinkProfile( LPHPROFILE lpahProfiles, 00857 DWORD nProfiles, 00858 LPBYTE *lpProfileData ); 00859 00860 Abstract: 00861 The CMCreateDeviceLinkProfile function creates a device link 00862 profile as specified by the "ICC Profile Format Specification." 00863 00864 Parameter Description 00865 lpahProfiles Pointer to an array of profile handles 00866 nProfiles Number of profiles in the array 00867 pProfileData Points to a pointer to a buffer. 00868 If successful the function allocates and fills this buffer. 00869 It is then the calling application�s responsibility to 00870 free this buffer with GlobalFreePtr( lpProfileData ) 00871 when it is no longer needed. 00872 00873 Returns 00874 If the function is successful, it returns nonzero. 00875 Otherwise it returns zero. SetLastError is used. 00876 00877 _____________________________________________________________________ */ 00878 00879 /*BOOL WINAPI CMCreateDeviceLinkProfile( LPHPROFILE lpahProfiles, 00880 DWORD nProfiles, 00881 LPBYTE *lpProfileData ) 00882 { 00883 long err; 00884 UINT32 *arrIntents = 0; 00885 OSErr aOSErr; 00886 DWORD i; 00887 00888 arrIntents = (UINT32 *)SmartNewPtrClear( nProfiles * sizeof (UINT32), &aOSErr); 00889 if (aOSErr != 0 ) return ERROR_NOT_ENOUGH_MEMORY; 00890 00891 for( i=0; i<nProfiles; i++){ 00892 arrIntents[i] = icPerceptual; 00893 } 00894 00895 err = CMCreateDeviceLinkProfileExt( lpahProfiles, nProfiles, arrIntents, nProfiles, BEST_MODE, lpProfileData ); 00896 00897 arrIntents = (UINT32 *)DisposeIfPtr( (Ptr)arrIntents ); 00898 return err; 00899 } 00900 */ 00901 /* ______________________________________________________________________ 00902 BOOL WINAPI CMIsProfileValid ( HPROFILE hProfile, 00903 LPBOOL lpbValid 00904 ); 00905 00906 Abstract: 00907 The CMIsProfileValid function reports if the given profile is a valid ICC profile that can be used for color matching. 00908 00909 Parameter Description 00910 lpDevCharacter Pointer to memory mapped profile 00911 lpbValid Points to a variable that is set on exit to TRUE if the profile is a valid ICC profile, or FALSE if not. 00912 00913 Returns 00914 If it is a valid ICC profile that can be used for color matching, 00915 the return value is nonzero. Otherwise it is zero. 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 BOOL WINAPI CMTranslateColors( HCMTRANSFORM hcmTransform, 00931 LPCOLOR lpaInputColors, 00932 DWORD nColors, 00933 COLORTYPE ctInput, 00934 LPCOLOR lpaOutputColors, 00935 COLORTYPE ctOutput ); 00936 Abstract: 00937 The CMTranslateColors function translates an array of colors from 00938 the source colorspace to the destination colorspace as defined by 00939 the color transform. 00940 00941 Parameter Description 00942 hcmTransform Identifies the color transform to use 00943 lpaInputColors Pointer to an array of COLOR structures to translate 00944 nColors Number of elements in the array 00945 ctInput Specifies the input color type 00946 lpaOutputColors Pointer to an array of COLOR structures that receive the translated colors 00947 ctOutput Specifies the output color type 00948 00949 Returns 00950 If the function is successful, the return value is nonzero. 00951 Otherwise it is zero. 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 BOOL WINAPI CMCheckColors( HCMTRANSFORM hcmTransform, 00977 LPCOLOR lpaInputColors, 00978 DWORD nColors, 00979 COLORTYPE ctInput, 00980 LPBYTE lpaResult ); 00981 Abstract: 00982 The CMCheckColors function determines if the given colors lie 00983 within the output gamut of the given transform. 00984 00985 Parameter Description 00986 hcmTransform Identifies the color transform to use 00987 lpaInputColors Pointer to an array of COLOR structures 00988 nColors Number of elements in the array 00989 ctInput Input color type 00990 lpaResult Pointer to an array of bytes that hold the result 00991 00992 Returns 00993 If the function is successful, the return value is nonzero. 00994 Otherwise it is zero. 00995 The lpaResult array holds the results, each byte corresponds to a 00996 COLOR element and has a value between 0 and 255. 00997 The value 0 denotes that the color is in gamut; a non-zero value 00998 implies that it is out of gamut, with the number "n+1" being at 00999 least as far out of gamut as the number "n". These values are 01000 usually generated from the gamutTag in the ICC profile. 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 BOOL WINAPI CMTranslateRGBs( HCMTRANSFORM hcmTransform, 01021 LPVOID lpSrcBits, 01022 BMFORMAT bmInput, 01023 DWORD dwWidth, 01024 DWORD dwHeight, 01025 DWORD dwStride, 01026 LPVOID lpDestBits, 01027 BMFORMAT bmOutput, 01028 DWORD dwTranslateDirection ); 01029 Abstract: 01030 The CMTranslateRGBs function takes a bitmap in one of the defined 01031 formats and translates the colors in the bitmap producing another 01032 bitmap in the requested format. 01033 01034 Parameter Description 01035 hcmTransform Identifies the color transform to use 01036 lpSrcBits Pointer to bitmap to translate 01037 bmInput Input bitmap format 01038 dwWidth Number of pixels per scanline of input data 01039 dwHeight Number of scanlines of input data 01040 dwStride Number of bytes from beginning of one scanline to beginning of next 01041 lpDestBits Pointer to buffer to receive translated data 01042 bmOutput Output bitmap format 01043 dwTranslateDirection Describes direction of transform 01044 Value Meaning 01045 CMS_FORWARD Use forward transform 01046 CMS_BACKWARD Use reverse transform // NOT supported 01047 01048 Returns 01049 If the function is successful, the return value is nonzero. 01050 Otherwise it is zero. 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 BOOL WINAPI CMTranslateRGBsExt( HCMTRANSFORM hcmTransform, 01126 LPVOID lpSrcBits, 01127 BMFORMAT bmInput, 01128 DWORD dwWidth, 01129 DWORD dwHeight, 01130 DWORD dwInputStride, 01131 LPVOID lpDestBits, 01132 BMFORMAT bmOutput, 01133 DWORD dwOutputStride, 01134 LPBMCALLBACKFN lpfnCallback, 01135 LPARAM ulCallbackData ) 01136 Abstract: 01137 The CMTranslateRGBs function takes a bitmap in one of the defined 01138 formats and translates the colors in the bitmap producing another 01139 bitmap in the requested format. 01140 01141 Parameter Description 01142 hcmTransform Specifies the color transform to use. 01143 lpSrcBits Points to the bitmap to translate. 01144 bmInput Specifies the input bitmap format. 01145 dwWidth Specifies the number of pixels per scanline in the input bitmap. 01146 dwHeight Specifies the number of scanlines in the input bitmap. 01147 dwInputStride Specifies the number of bytes from the beginning of one scanline to 01148 the beginning of the next in the input bitmap. 01149 If dwInputStride is set to zero, the CMM should assume that scanlines 01150 are padded so as to be DWORD aligned. 01151 lpDestBits Points to a destination buffer in which to place the translated bitmap. 01152 bmOutput Specifies the output bitmap format. 01153 dwOutputStride Specifies the number of bytes from the beginning of one scanline to the 01154 beginning of the next in the input bitmap. 01155 If dwOutputStride is set to zero, the CMM should pad scanlines so 01156 that they are DWORD aligned. 01157 lpfnCallback Pointer to an application-supplied callback function called periodically 01158 by CMTranslateRGBsExt to report progress and allow the calling process 01159 to cancel the translation. (See ICMProgressProc.) 01160 ulCallbackData Data passed back to the callback function, for example to identify the 01161 translation that is reporting progress. 01162 01163 Returns 01164 If the function is successful, the return value is nonzero. 01165 Otherwise it is zero. 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 BOOL WINAPI CMCheckRGBs( HCMTRANSFORM hcmTransform, 01229 LPVOID lpSrcBits, 01230 BMFORMAT bmInput, 01231 DWORD dwWidth, 01232 DWORD dwHeight, 01233 DWORD dwStride, 01234 LPBYTE lpDestBits, 01235 PBMCALLBACKFN pfnCallback, 01236 LPARAM ulCallbackData ); 01237 Abstract: 01238 The CMCheckRGBs function checks if the pixels in the bitmap lie 01239 within the output gamut of the given transform. 01240 01241 Parameter Description 01242 01243 hcmTransform Specifies the color transform to use. 01244 lpSrcBits Points to the bitmap to check against an output gamut. 01245 bmInput Specifies the input bitmap format. 01246 dwWidth Specifies the number of pixels per scanline in the input bitmap. 01247 dwHeight Specifies the number of scanlines in the input bitmap. 01248 dwStride Specifies the number of bytes from the beginning of one scanline 01249 to the beginning of the next in the input bitmap. 01250 If dwStride is set to zero, the CMM should assume that scanlines 01251 are padded so as to be DWORD-aligned. 01252 lpaResult Points to a buffer in which the test results are to be placed. 01253 The results are represented by an array of bytes. 01254 Each byte in the array corresponds to a pixel in the bitmap, 01255 and on exit is set to an unsigned value between 0 and 255. 01256 The value 0 denotes that the color is in gamut, 01257 while a nonzero value denotes that it is out of gamut. 01258 For any integer n such that 0 < n < 255, a result value of n+1 01259 indicates that the corresponding color is at least as far out of 01260 gamut as would be indicated by a result value of n. 01261 These values are usually generated from the gamutTag in the ICC profile. 01262 pfnCallback Pointer to an application-supplied callback function called periodically 01263 by CMCheckRGBs to report progress and allow the calling process 01264 to cancel the translation. (See ICMProgressProc.) 01265 ulCallbackData Data passed back to the callback function, for example to identify 01266 the bitmap test that is reporting progress. 01267 01268 Returns 01269 If the function is successful, the return value is nonzero. 01270 Otherwise it is zero. 01271 The lpaResult array holds the results, each byte corresponds to a pixel 01272 and has a value between 0 and 255. The value 0 denotes that the color is in gamut; 01273 a non-zero value implies that it is out of gamut, with the number "n+1" being at 01274 least as far out of gamut as the number "n". These values are usually generated 01275 from the gamutTag in the ICC profile. 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; // perhaps wrong format? 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 BOOL WINAPI CMTranslateRGB( HCMTRANSFORM hcmTransform, 01332 COLORREF colorRef, 01333 LPCOLORREF lpColorRef, 01334 DWORD dwFlags ); 01335 Abstract: 01336 The CMTranslateRGB function translates an application supplied RGBQuad into the 01337 device color coordinate space. 01338 01339 Parameter Description 01340 hcmTransform Handle of transform to use. 01341 colorRef RGBQuad to translate. 01342 lpColorRef Pointer to buffer to store result. 01343 dwFlags Flags that can have the following meaning 01344 01345 Type Meaning 01346 01347 CMS_FORWARD Specifies that the forward transform is to be used. 01348 CMS_BACKWARD Specifies that the backward transform is to be used. // NOT supported 01349 01350 Returns 01351 The return value is TRUE if the function is successful. Otherwise, it is NULL. 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 BOOL WINAPI CMCheckColorsInGamut( HCMTRANSFORM hcmTransform, 01414 LPARGBQUAD lpaRGBTriplet, 01415 LPBYTE lpBuffer, 01416 UINT nCount ); 01417 Abstract: 01418 The CMCheckColorInGamut determines if the given RGBs lie in the output gamut of the 01419 given transform. 01420 01421 Parameter Description 01422 hcmTransform Handle of transform to use. 01423 lpaRGBTriples Pointer to array of RGB triples to check. 01424 lpBuffer Pointer to buffer to put results. 01425 nCount Count of elements in array. 01426 01427 01428 Returns 01429 The return value is TRUE if the function is successful. Otherwise, it is NULL. 01430 The lpBuffer holds the results, each byte corresponding to an RGB triple is a value in 01431 the range 0 to 255. 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; // perhaps wrong format? 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 long FillProfileFromLog( LPLOGCOLORSPACEA lpColorSpace, 01463 PPROFILE theProf ) 01464 Abstract: 01465 The FillProfileFromLog function convertes a lpColorSpace to a PROFILE. 01466 If lpColorSpace has a profile name the function returns a file based profile. 01467 Else it returns a memory based profile. 01468 01469 Parameter Description 01470 lpColorSpace Handle of transform to use. 01471 theProf Pointer to the profile. 01472 01473 Returns 01474 The return value is 0 if the function is successful. Otherwise, it is an error code. 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 long FillProfileFromLogW( LPLOGCOLORSPACEW lpColorSpace, 01503 PPROFILE theProf ) 01504 Abstract: 01505 The FillProfileFromLog function convertes a lpColorSpace to a PROFILE. 01506 If lpColorSpace has a profile name the function returns a file based profile. 01507 Else it returns a memory based profile. 01508 01509 Parameter Description 01510 lpColorSpace Handle of transform to use. 01511 theProf Pointer to the profile. 01512 01513 Returns 01514 The return value is 0 if the function is successful. Otherwise, it is an error code. 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 CMBitmapColorSpace CMGetDataColorSpace( BMFORMAT bmMode, long *pixelSize ); 01543 01544 Abstract: 01545 The CMGetDataColorSpace function retrieves the CMBitmapColorSpace and 01546 the pixel size from the BMFORMAT. 01547 01548 Parameter Description 01549 bmMode Identifies the data format. 01550 pixelSize Pointer to pixelsize. 01551 01552 Returns 01553 function returns the internal data format 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 HCMTRANSFORM WINAPI CMGetTransform( HCMTRANSFORM hcmTransform ); 01716 01717 Abstract: 01718 The CMGetTransform function retrieves the actual transform out of the static array 01719 in the critical section. 01720 01721 Parameter Description 01722 hcmTransform Handle to the transform. 01723 01724 Returns 01725 the actual pointer to the transform 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 CMWorldRef StoreTransform( CMWorldRef aRef ); 01747 01748 Abstract: 01749 The StoreTransform function stores the actual transform in the static array 01750 in the critical section. 01751 01752 Parameter Description 01753 aRef Ptr to the transform. 01754 01755 Returns 01756 valid (255 < handle < 65536 ) handle of the transform 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 CMBitmapColorSpace CMGetColorType( COLORTYPE bmMode, long *pixelSize ) 01824 { 01825 switch( bmMode ){ 01826 case COLOR_GRAY: 01827 *pixelSize = 16; 01828 return cm16PerChannelPacking + cmGraySpace; 01829 break; 01830 case COLOR_ : 01831 case COLOR_XYZ: 01832 case COLOR_Yxy: 01833 case COLOR_Lab: 01834 case COLOR_3_CHANNEL: 01835 case COLOR_CMYK: 01836 *pixelSize = 64; 01837 return cm16PerChannelPacking + cmRGBSpace; 01838 break; 01839 case COLOR_5_CHANNEL: 01840 case COLOR_6_CHANNEL: 01841 case COLOR_7_CHANNEL: 01842 case COLOR_8_CHANNEL: 01843 *pixelSize = 64; 01844 return cm8PerChannelPacking + cmMCFiveSpace + bmMode - COLOR_5_CHANNEL; 01845 break; 01846 default: 01847 *pixelSize = 0; 01848 return 0; 01849 } 01850 } 01851 01852 #define CMS_x555WORD 0x00000000 01853 #define CMS_565WORD 0x00000001 01854 #define CMS_RGBTRIPLETS 0x00000002 01855 #define CMS_BGRTRIPLETS 0x00000004 01856 #define CMS_XRGBQUADS 0x00000008 01857 #define CMS_XBGRQUADS 0x00000010 01858 #define CMS_QUADS 0x00000020 01859 01860 CMBitmapColorSpace CMGetCMSType( DWORD bmMode, long *pixelSize ) 01861 { 01862 if( bmMode & CMS_x555WORD ){ 01863 *pixelSize = 16; 01864 return cmWord5ColorPacking + cmRGBSpace; 01865 } 01866 else if( bmMode & CMS_RGBTRIPLETS ){ 01867 *pixelSize = 24; 01868 return cm8PerChannelPacking + cmRGBSpace; 01869 } 01870 else if( bmMode & CMS_BGRTRIPLETS ){ 01871 *pixelSize = 24; 01872 return cm8PerChannelPacking + cmBGRSpace; 01873 } 01874 else if( bmMode & CMS_XRGBQUADS ){ 01875 *pixelSize = 32; 01876 return cmLong8ColorPacking + cmRGBSpace; 01877 } 01878 else if( bmMode & CMS_XBGRQUADS ){ 01879 *pixelSize = 32; 01880 return cmLong8ColorPacking + cmBGRSpace; 01881 } 01882 else if( bmMode & CMS_QUADS ){ 01883 *pixelSize = 32; 01884 return cmLong8ColorPacking + cmCMYKSpace; 01885 } 01886 else{ 01887 *pixelSize = 0; 01888 return 0; 01889 } 01890 } 01891 */ 01892 01893 01894

Generated on Sat May 15 19:40:20 2004 for test by doxygen 1.3.7