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

pi_color.c

Go to the documentation of this file.
00001 /* 00002 File: PI_ColorWorld.c 00003 00004 Contains: 00005 00006 Written by: U. J. Krabbenhoeft 00007 00008 Version: 00009 00010 Copyright: © 1993-1997 by Heidelberger Druckmaschinen AG, all rights reserved. 00011 00012 */ 00013 #ifndef LHGeneralIncs_h 00014 #include "General.h" 00015 #endif 00016 00017 #ifndef PI_ColorWorld_h 00018 #include "PI_Color.h" 00019 #endif 00020 00021 #ifndef realThing 00022 #ifdef DEBUG_OUTPUT 00023 #define kThisFile kLHCMDo3DID 00024 #define __TYPES__ 00025 /*#include "DebugSpecial.h"*/ 00026 /*#include "LH_Util.h"*/ 00027 #endif 00028 #endif 00029 00030 #ifndef PI_CMMInitialization_h 00031 #include "PI_CMM.h" 00032 #endif 00033 00034 #ifndef MemLink_h 00035 #include "MemLink.h" 00036 #endif 00037 00038 /* ______________________________________________________________________ 00039 00040 CMError 00041 LHColorWorldOpen (Handle* storage) 00042 00043 Abstract: 00044 opens ColorWorld and allocates up any necessary memory 00045 00046 Params: 00047 storage (in/out) pointer to 00048 handle to memory to be used by CMM 00049 00050 Return: 00051 noErr successful 00052 00053 _____________________________________________________________________ */ 00054 00055 CMError LHColorWorldOpen (Ptr* storage) 00056 { 00057 Ptr myStorage; 00058 OSErr err; 00059 00060 myStorage = (Ptr)SmartNewPtrClear( sizeof( CMMModelData ) , &err); 00061 if (err) 00062 goto CleanupAndExit; 00063 else 00064 { 00065 *storage = myStorage; 00066 } 00067 00068 CleanupAndExit: 00069 return err; 00070 } 00071 00072 /* ______________________________________________________________________ 00073 00074 CMError 00075 LHColorWorldClose(Handle storage); 00076 00077 Abstract: 00078 closes ColorWorld and cleans up any remaining memory allocations 00079 00080 Params: 00081 storage (in/out) handle to memory to be used by CMM 00082 00083 Return: 00084 noErr successful 00085 00086 _____________________________________________________________________ */ 00087 00088 CMError LHColorWorldClose( Ptr storage ) 00089 { 00090 CMMModelPtr modelData = (CMMModelPtr)storage; 00091 00092 if (storage) 00093 { 00094 DISPOSE_IF_DATA((modelData)->lutParam.inputLut); 00095 DISPOSE_IF_DATA((modelData)->lutParam.outputLut); 00096 DISPOSE_IF_DATA((modelData)->lutParam.colorLut); 00097 00098 DISPOSE_IF_DATA((modelData)->gamutLutParam.inputLut); 00099 DISPOSE_IF_DATA((modelData)->gamutLutParam.outputLut); 00100 DISPOSE_IF_DATA((modelData)->gamutLutParam.colorLut); 00101 00102 DISPOSE_IF_DATA((modelData)->theNamedColorTagData); 00103 #if __IS_MAC 00104 DisposeIfHandle((modelData)->Monet); 00105 #endif 00106 00107 DisposeIfPtr(storage); 00108 } 00109 return( noErr ); 00110 } 00111 /* ______________________________________________________________________ 00112 00113 CMError 00114 CWNewColorWorld (CMWorldRef* storage, 00115 CMProfileRef srcProfile, 00116 CMProfileRef dstProfile) 00117 00118 Abstract: 00119 opens ColorWorld and allocates up any necessary memory, 00120 fill buffer for color transformation 00121 00122 00123 Params: 00124 storage (in/out) Ptr to memory to be used by CMM 00125 srcProfile (in) pointer to source profile 00126 description 00127 dstProfile (in) pointer to destination profile 00128 description 00129 00130 storage: 00131 typedef struct CMPrivateColorWorldRecord *CMWorldRef; 00132 00133 Return: 00134 noErr successful 00135 System or result code if an error occurs. 00136 00137 _____________________________________________________________________ */ 00138 00139 00140 CMError 00141 CWNewColorWorld ( CMWorldRef* storage, 00142 CMProfileRef srcProfile, 00143 CMProfileRef dstProfile) 00144 { 00145 Ptr myStorage; 00146 CMError err; 00147 00148 #ifdef DEBUG_OUTPUT 00149 /*printf("vor LHColorWorldOpen\n");*/ 00150 #endif 00151 err = LHColorWorldOpen(&myStorage); 00152 #ifdef DEBUG_OUTPUT 00153 /*printf("nach LHColorWorldOpen: err = %d\n", err);*/ 00154 #endif 00155 if ( !err ) 00156 { 00157 ((CMMModelPtr)myStorage)->aIntentArr = 0; 00158 ((CMMModelPtr)myStorage)->dwFlags = 0xffffffff; 00159 err = CMMInitPrivate((CMMModelPtr)myStorage, 00160 srcProfile, 00161 dstProfile); 00162 #ifdef DEBUG_OUTPUT 00163 /*printf("nach NCMMInitPrivate: err = %d\n", err);*/ 00164 #endif 00165 } 00166 00167 00168 if ( !err ) 00169 { 00170 *storage = (CMWorldRef)myStorage; 00171 } 00172 else{ 00173 *storage = (CMWorldRef)0; 00174 LHColorWorldClose( myStorage ); 00175 } 00176 00177 return err; 00178 } 00179 00180 /* ______________________________________________________________________ 00181 00182 CMError 00183 CWConcatColorWorld ( CMWorldRef* storage, 00184 CMConcatProfileSet* profileSet ) 00185 00186 Abstract: 00187 opens ColorWorld and allocates up any necessary memory, 00188 fill buffer for color transformation 00189 00190 00191 Params: 00192 storage (in/out) Ptr to memory to be used by CMM 00193 profileSet (in) CMConcatProfileSet contains an array of 00194 Profiles which describe the processing 00195 to be carried out.The profileSet array 00196 is in processing orderÑ Source through 00197 Destination. A minimum of one CMProfileRef 00198 must be specified. 00199 00200 storage: 00201 typedef struct CMPrivateColorWorldRecord *CMWorldRef; 00202 00203 Return: 00204 noErr successful 00205 System or result code if an error occurs. 00206 00207 _____________________________________________________________________ */ 00208 CMError 00209 CWConcatColorWorld ( CMWorldRef* storage, 00210 CMConcatProfileSet* profileSet) 00211 { 00212 Ptr myStorage; 00213 CMError err; 00214 00215 err = LHColorWorldOpen(&myStorage); 00216 00217 if ( !err ) 00218 { 00219 ((CMMModelPtr)myStorage)->aIntentArr = 0; 00220 ((CMMModelPtr)myStorage)->dwFlags = 0xffffffff; 00221 err = CMMConcatInitPrivate ((CMMModelPtr)myStorage, profileSet ); 00222 } 00223 00224 00225 if ( !err ) 00226 { 00227 *storage = (CMWorldRef)myStorage; 00228 } 00229 else{ 00230 *storage = (CMWorldRef)0; 00231 LHColorWorldClose( myStorage ); 00232 } 00233 00234 return err; 00235 } 00236 00237 #if WRITE_PROFILE 00238 void WriteProf( Ptr name, icProfile *theProf, long currentSize ); 00239 #endif 00240 /* ______________________________________________________________________ 00241 00242 CMError 00243 CWConcatColorWorld4MS ( CMWorldRef *storage, 00244 CMConcatProfileSet *profileSet, 00245 UINT32 *aIntentArr, 00246 UINT32 nIntents, 00247 UINT32 dwFlags 00248 ) 00249 00250 Abstract: 00251 opens ColorWorld and allocates up any necessary memory, 00252 fill buffer for color transformation 00253 00254 00255 Params: 00256 storage (in/out) Ptr to memory to be used by CMM 00257 profileSet (in) CMConcatProfileSet contains an array of 00258 Profiles which describe the processing 00259 to be carried out.The profileSet array 00260 is in processing orderÑ Source through 00261 Destination. A minimum of one CMProfileRef 00262 must be specified. 00263 00264 padwIntents (in) Points to an array of intent structures. 00265 0 = default behavior ( intents out of profiles ) 00266 00267 nIntents (in) Specifies the number of intents in the intent array. 00268 Can be 1, or the same value as nProfiles. 00269 00270 dwFlags (in) Specifies flags to control creation of the transform. 00271 These flags are intended only as hints, and it is up to the CMM 00272 to determine how best to use these flags. 00273 Set the high-order word to ENABLE_GAMUT_CHECKING if the transform will be used 00274 for gamut checking. 00275 The low-order WORD can have one of the following constant values: 00276 PROOF_MODE, NORMAL_MODE, BEST_MODE. Moving from PROOF_MODE to BEST_MODE, 00277 output quality generally improves and transform speed declines. 00278 Return: 00279 noErr successful 00280 System or result code if an error occurs. 00281 00282 _____________________________________________________________________ */ 00283 CMError CWConcatColorWorld4MS ( CMWorldRef *storage, 00284 CMConcatProfileSet *profileSet, 00285 UINT32 *aIntentArr, 00286 UINT32 nIntents, 00287 UINT32 dwFlags 00288 ) 00289 { 00290 Ptr myStorage; 00291 CMError err; 00292 #if WRITE_PROFILE 00293 icProfile *theLinkProfile; 00294 long l; 00295 #endif 00296 00297 err = LHColorWorldOpen(&myStorage); 00298 00299 if ( !err ) 00300 { 00301 ((CMMModelPtr)myStorage)->aIntentArr = aIntentArr; 00302 ((CMMModelPtr)myStorage)->nIntents = nIntents; 00303 ((CMMModelPtr)myStorage)->dwFlags = dwFlags; 00304 err = CMMConcatInitPrivate ((CMMModelPtr)myStorage, profileSet ); 00305 } 00306 00307 00308 if ( !err ) 00309 { 00310 *storage = (CMWorldRef)myStorage; 00311 } 00312 else{ 00313 *storage = (CMWorldRef)0; 00314 LHColorWorldClose( myStorage ); 00315 } 00316 00317 #if WRITE_PROFILE 00318 err = DeviceLinkFill( (CMMModelPtr)myStorage, profileSet, &theLinkProfile, 0 ); 00319 if( !err ){ 00320 l = *(unsigned long *)theLinkProfile; 00321 SwapLong(&l); 00322 WriteProf( "test", theLinkProfile, l ); 00323 } 00324 #endif 00325 return err; 00326 } 00327 00328 CMError 00329 CWLinkColorWorld ( CMWorldRef* storage, 00330 CMConcatProfileSet* profileSet) 00331 { 00332 Ptr myStorage; 00333 CMError err; 00334 00335 err = LHColorWorldOpen(&myStorage); 00336 00337 if ( !err ) 00338 { 00339 ((CMMModelPtr)myStorage)->currentCall = kCMMNewLinkProfile; 00340 ((CMMModelPtr)myStorage)->aIntentArr = 0; 00341 ((CMMModelPtr)myStorage)->dwFlags = 0xffffffff; 00342 err = CMMConcatInitPrivate ((CMMModelPtr)myStorage, profileSet ); 00343 } 00344 00345 00346 if ( !err ) 00347 { 00348 *storage = (CMWorldRef)myStorage; 00349 } 00350 else{ 00351 *storage = (CMWorldRef)0; 00352 LHColorWorldClose( myStorage ); 00353 } 00354 00355 return err; 00356 } 00357 00358 /* ______________________________________________________________________ 00359 00360 CMError 00361 CWDisposeColorWorld (CMWorldRef storage) 00362 00363 Abstract: 00364 closes ColorWorld and cleans up any remaining memory allocations 00365 00366 Params: 00367 storage (in/out) handle to memory to be used by CMM 00368 00369 Return: 00370 - 00371 _____________________________________________________________________ */ 00372 00373 00374 void 00375 CWDisposeColorWorld ( CMWorldRef storage ) 00376 { 00377 LHColorWorldClose ( (Ptr)storage ); 00378 } 00379 00380 void CMSetLookupOnlyMode( CMWorldRef Storage, 00381 PI_Boolean Mode ) 00382 { 00383 CMMModelPtr aPtr; 00384 00385 if( Storage == 0 )return; 00386 LOCK_DATA( Storage ); 00387 aPtr = (CMMModelPtr)(DATA_2_PTR( Storage )); 00388 aPtr->lookup = Mode; 00389 UNLOCK_DATA( Storage ); 00390 return; 00391 } 00392 00393 void CMFullColorRemains( CMWorldRef Storage, 00394 long ColorMask ) 00395 { 00396 CMMModelPtr aPtr; 00397 CMLutParamPtr lutParamPtr; 00398 long Address,Size,i,j; 00399 00400 if( Storage == 0 )return; 00401 LOCK_DATA( Storage ); 00402 aPtr = (CMMModelPtr)(DATA_2_PTR( Storage )); 00403 lutParamPtr = &aPtr->lutParam; 00404 00405 Size = lutParamPtr->colorLutWordSize / 8; 00406 if( !(lutParamPtr->colorLutInDim == 4 && lutParamPtr->colorLutOutDim == 4 ))return; 00407 00408 for( i=0; i<4; i++ ){ 00409 if( (ColorMask & (1<<i)) == 0 ) continue; 00410 Address = lutParamPtr->colorLutGridPoints - 1; 00411 for( j=3-i+1; j<4; j++ )Address *= lutParamPtr->colorLutGridPoints; 00412 Address = Address * lutParamPtr->colorLutOutDim; 00413 for( j=0; j<4; j++){ 00414 if( i == j ){ 00415 if( Size == 1 ){ 00416 *( ((unsigned char*)lutParamPtr->colorLut)+Address+3-j ) = (unsigned char)255; 00417 } 00418 else{ 00419 *( ((unsigned short*)lutParamPtr->colorLut)+Address+3-j ) = (unsigned short)65535; 00420 } 00421 } 00422 else{ 00423 if( Size == 1 ){ 00424 *( ((unsigned char*)lutParamPtr->colorLut)+Address+3-j ) = (unsigned char)0; 00425 } 00426 else{ 00427 *( ((unsigned short*)lutParamPtr->colorLut)+Address+3-j ) = (unsigned short)0; 00428 } 00429 } 00430 } 00431 } 00432 UNLOCK_DATA( Storage ); 00433 return; 00434 } 00435 00436 CMError CWCreateLink4MS ( CMWorldRef storage, 00437 CMConcatProfileSet *profileSet, 00438 UINT32 aIntent, 00439 icProfile **theLinkProfile ) 00440 { 00441 CMError err; 00442 00443 *theLinkProfile = 0; 00444 00445 err = DeviceLinkFill( (CMMModelPtr)storage, profileSet, theLinkProfile, aIntent ); 00446 00447 return err; 00448 }

Generated on Sat May 15 19:41:14 2004 for test by doxygen 1.3.7