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

runtime.h File Reference

Go to the source code of this file.

Functions

CMError LHMatchColorsPrivate (CMMModelPtr modelingData, CMColor *myColors, long count)
CMError LHCheckBitMapPrivate (CMMModelPtr modelingData, const CMBitmap *bitMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *resultBitMap)
CMError LHMatchBitMapPrivate (CMMModelPtr modelingData, const CMBitmap *bitMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *matchedBitMap)
CMError LHCheckColorsPrivate (CMMModelPtr modelingData, CMColor *myColors, UINT32 count, unsigned char *result)
CMError LHCheckColorsPrivateMS (CMMModelPtr modelingData, CMColor *myColors, UINT32 count, UINT8 *result)
CMError LHMatchBitMapPlanePrivate (CMMModelPtr modelingData, const LH_CMBitmapPlane *bitMapLH, CMBitmapCallBackUPP progressProc, void *refCon, LH_CMBitmapPlane *matchedBitMapLH)
OSErr ConvertNamedIndexToPCS (CMMModelPtr cw, CMColor *theData, SINT32 pixCnt)
OSErr ConvertNamedIndexToColors (CMMModelPtr modelingData, CMColor *theData, long pixCnt)
OSErr ConvertPCSToNamedIndex (CMMModelPtr modelingData, CMColor *theData, long pixCnt)
CMError ConvertLabToIndexBitmap (CMMModelPtr modelingData, Ptr InBuffer, UINT32 processedLinesIn, UINT32 inLineCount, UINT32 width, UINT32 rowBytes)
CMError ConvertIndexToLabBitmap (CMMModelPtr modelingData, Ptr InBuffer, Ptr OutBuffer, UINT32 processedLinesIn, UINT32 lineCount, UINT32 inWidth, UINT32 inRowBytes, UINT32 outRowBytes, UINT32 outputSize)
OSErr PreProcNamedColorMatchBitmap (CMMModelPtr modelingData, CMBitmap *inBitMap, CMBitmap *outBitMap, Boolean MatchInPlace)
OSErr MidProcNamedColorMatchBitmap (CMMModelPtr modelingData, CMBitmap *InBitMap, Ptr dataOut, UINT32 startLine, UINT32 height)
OSErr PostProcNamedColorMatchBitmap (CMMModelPtr modelingData, CMBitmap *inBitMap, CMBitmap *outBitMap)


Function Documentation

CMError ConvertIndexToLabBitmap CMMModelPtr  modelingData,
Ptr  InBuffer,
Ptr  OutBuffer,
UINT32  processedLinesIn,
UINT32  lineCount,
UINT32  inWidth,
UINT32  inRowBytes,
UINT32  outRowBytes,
UINT32  outputSize
 

Definition at line 4948 of file lh_core/runtime.c.

04957 { 04958 OSErr err = noErr; 04959 LUT_DATA_TYPE tagH=NULL; 04960 UINT16 *tagTbl = NULL,*ColorPtr = NULL; 04961 UINT32 *imgIn=NULL; 04962 UINT8 *imgOut=NULL; 04963 int deviceChannelCount,elemSz; 04964 UINT32 i,j,index,countNamesInProfile; 04965 04966 LH_START_PROC("ConvertIndexToLabBitmap") 04967 /* set up the table for indexing */ 04968 tagH = modelingData->theNamedColorTagData; 04969 if (tagH==NULL) { 04970 err = cmparamErr; 04971 goto CleanUp; 04972 } 04973 04974 LOCK_DATA(tagH); 04975 tagTbl = (UINT16 *)DATA_2_PTR(tagH) + 58; /* points to PCS */ 04976 deviceChannelCount = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.nDeviceCoords; 04977 countNamesInProfile = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.count; 04978 if (deviceChannelCount==3) { 04979 elemSz = 32+(3+3)*sizeof(UINT16); 04980 } else if (deviceChannelCount==4) { 04981 elemSz = 32+(3+4)*sizeof(UINT16); 04982 } else if (deviceChannelCount==0) { 04983 elemSz = 32+(3+0)*sizeof(UINT16); 04984 } else { 04985 err = cmparamErr; 04986 goto CleanUp; 04987 } 04988 elemSz/=2; 04989 04990 /* ...and convert the data from index to PCS values */ 04991 for( i=processedLinesIn; i<processedLinesIn+lineCount; i++ ){ 04992 imgIn = (UINT32 *)(InBuffer + i * inRowBytes); 04993 imgOut = (UINT8*)OutBuffer + (i-processedLinesIn) * outRowBytes; 04994 if( outputSize == 24 ){ 04995 for (j=0;j<inWidth;j++) { 04996 index = *imgIn++; 04997 if( index == 0 || index > countNamesInProfile ){ 04998 err = cmNamedColorNotFound; 04999 goto CleanUp; 05000 } 05001 05002 ColorPtr = tagTbl + (index-1)*elemSz; 05003 *imgOut++ = (*ColorPtr++)>>8; 05004 *imgOut++ = (*ColorPtr++)>>8; 05005 *imgOut++ = (*ColorPtr++)>>8; 05006 } 05007 } 05008 else if( outputSize == 32 ){ 05009 for (j=0;j<inWidth;j++) { 05010 index = *imgIn++; 05011 if( index == 0 || index > countNamesInProfile ){ 05012 err = cmNamedColorNotFound; 05013 goto CleanUp; 05014 } 05015 05016 ColorPtr = tagTbl + (index-1)*elemSz; 05017 *imgOut++ = (*ColorPtr++)>>8; 05018 *imgOut++ = (*ColorPtr++)>>8; 05019 *imgOut = (*ColorPtr++)>>8; 05020 imgOut += 2; 05021 } 05022 } 05023 } 05024 CleanUp: 05025 UNLOCK_DATA(tagH); 05026 LH_END_PROC("ConvertIndexToLabBitmap") 05027 return err; 05028 }

CMError ConvertLabToIndexBitmap CMMModelPtr  modelingData,
Ptr  InBuffer,
UINT32  processedLinesIn,
UINT32  inLineCount,
UINT32  width,
UINT32  rowBytes
 

Definition at line 4865 of file lh_core/runtime.c.

04871 { 04872 OSErr err = noErr; 04873 LUT_DATA_TYPE tagH=NULL; 04874 UINT16 *tagTbl = NULL,*colorPtr = NULL; 04875 int deviceChannelCount,elemSz,count; 04876 UINT32 i,j,k,index,dE,dEnow; 04877 UINT16 LL,aa,bb; 04878 UINT8 *imgIn=NULL,*imgOut=NULL; 04879 UINT32 *imgInPtr=NULL; 04880 UINT8 *imgInPtr8=NULL; 04881 UINT8 *imgOutPtr8=NULL; 04882 04883 LH_START_PROC("ConvertLabToIndexBitmap") 04884 /* prepare the tag table */ 04885 tagH = modelingData->theNamedColorTagData; 04886 if (tagH==NULL){ 04887 err = cmparamErr; 04888 goto CleanUp; 04889 } 04890 LOCK_DATA(tagH); 04891 tagTbl = (UINT16 *)DATA_2_PTR(tagH) + 58; 04892 count = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.count; 04893 deviceChannelCount = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.nDeviceCoords; 04894 if (deviceChannelCount == 3){ 04895 elemSz = 32+(3+3)*sizeof(SINT16); 04896 } 04897 else if (deviceChannelCount == 4){ 04898 elemSz = 32+(3+4)*sizeof(SINT16); 04899 } 04900 else if (deviceChannelCount == 0){ 04901 elemSz = 32+(3+0)*sizeof(SINT16); 04902 } 04903 else{ 04904 err = cmparamErr; 04905 goto CleanUp; 04906 } 04907 elemSz /= 2; 04908 04909 /* search for index */ 04910 imgIn = (UINT8*)InBuffer + processedLinesIn * rowBytes; 04911 imgInPtr8=((UINT8 *)imgIn); 04912 LL = *(imgInPtr8+0)+1; /* do not use cache for first pixel */ 04913 for (i = 0; i < inLineCount; i++){ 04914 for (j = 0; j < width; j++){ 04915 imgInPtr8=((UINT8 *)imgIn+j*4); 04916 if( LL == *(imgInPtr8+0) ){ 04917 if( aa == *(imgInPtr8+1) && bb == *(imgInPtr8+2) ){ 04918 *((UINT32 *)imgIn+j) = index+1; 04919 continue; 04920 } 04921 } 04922 LL = *(imgInPtr8+0); 04923 aa = *(imgInPtr8+1); 04924 bb = *(imgInPtr8+2); 04925 /* go through the whole table to find the closest one*/ 04926 dEnow = 0x40000; /* just arbitrarily high = 256*256*4 */ 04927 index =(UINT32)-1; 04928 colorPtr = tagTbl; 04929 for (k = 0; k < (UINT32)count; k++){ 04930 dE = POS((long)aa - (*(colorPtr+1)>>8)); 04931 dE = dE + POS((long)bb - (*(colorPtr+2)>>8)); 04932 dE = 2*dE + (dE>>1) + POS((long)LL - (*(colorPtr)>>8)); /* Quantization L = 2.55 * (a|b) */ 04933 if (dE < dEnow){ 04934 index = k; 04935 dEnow = dE; 04936 } 04937 colorPtr += elemSz; 04938 } 04939 *((UINT32 *)imgIn+j) = index+1; 04940 } 04941 imgIn+=rowBytes; 04942 } 04943 CleanUp: 04944 UNLOCK_DATA(tagH); 04945 LH_END_PROC("ConvertLabToIndexBitmap") 04946 return err; 04947 }

OSErr ConvertNamedIndexToColors CMMModelPtr  modelingData,
CMColor theData,
long  pixCnt
 

OSErr ConvertNamedIndexToPCS CMMModelPtr  cw,
CMColor theData,
SINT32  pixCnt
 

Definition at line 4690 of file lh_core/runtime.c.

04693 { 04694 UINT16 *tagTbl = NULL; 04695 LUT_DATA_TYPE tagH = NULL; 04696 OSErr err = noErr; 04697 UINT32 i,index; 04698 UINT16 *colorPtr=NULL; 04699 int elemSz,deviceChannelCount,count; 04700 CMMModelPtr modelingData = (CMMModelPtr)cw; 04701 04702 04703 LH_START_PROC("ConvertNamedIndexToPCS") 04704 if( cw == 0 )return cmparamErr; 04705 { 04706 /* prepare the tag table */ 04707 tagH = modelingData->theNamedColorTagData; 04708 if (tagH == NULL) 04709 { 04710 err = cmparamErr; 04711 goto CleanUp; 04712 } 04713 LOCK_DATA(tagH); 04714 04715 /* tagTbl should now point to beginning of first PCS data */ 04716 /* = CMNamedColor2Type_header(84) + firstName(32) */ 04717 tagTbl = (UINT16 *)DATA_2_PTR(tagH) + 58; 04718 04719 /* find out how many bytes to skip per element. div'ed 2 for indexing purpose */ 04720 count = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.count; 04721 deviceChannelCount = ((icNamedColor2Type *)DATA_2_PTR(tagH))->ncolor.nDeviceCoords; 04722 if (deviceChannelCount == 3) 04723 { 04724 elemSz = 32+(3+3)*sizeof(SINT16); 04725 } else if (deviceChannelCount == 4) 04726 { 04727 elemSz = 32+(3+4)*sizeof(SINT16); 04728 } else if (deviceChannelCount == 0) 04729 { 04730 elemSz = 32+(3+0)*sizeof(SINT16); 04731 } else 04732 { 04733 err = cmparamErr; 04734 goto CleanUp; 04735 } 04736 elemSz /= 2; 04737 04738 /* doing the actual */ 04739 for (i=0; i<(UINT32)pixCnt; i++) 04740 { 04741 /* go to the index'th element*/ 04742 index = theData->namedColor.namedColorIndex; 04743 if (index > (UINT32)count || index == 0 ) 04744 { 04745 err = cmNamedColorNotFound; 04746 goto CleanUp; 04747 } 04748 colorPtr = tagTbl + (index-1)*elemSz; 04749 /* put in all the info */ 04750 theData->Lab.L = *colorPtr++; 04751 theData->Lab.a = *colorPtr++; 04752 theData->Lab.b = *colorPtr++; 04753 theData++; 04754 } 04755 UNLOCK_DATA(tagH); 04756 } 04757 CleanUp: 04758 LH_END_PROC("ConvertNamedIndexToPCS") 04759 return err; 04760 }

OSErr ConvertPCSToNamedIndex CMMModelPtr  modelingData,
CMColor theData,
long  pixCnt
 

CMError LHCheckBitMapPrivate CMMModelPtr  modelingData,
const CMBitmap bitMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap resultBitMap
 

Definition at line 4255 of file lh_core/runtime.c.

04260 { 04261 CMCalcParam calcParam; 04262 CMLutParam lutParam; 04263 CMError err = -1; 04264 ColorSpaceInfo info; 04265 CalcProcPtr calcRoutine = nil; 04266 CMBitmap bitMapIn = *inBitMap; 04267 CMBitmap bitMapOut; 04268 OSType inColorSpace = modelingData->firstColorSpace; 04269 Boolean progressProcWasCalled = FALSE; 04270 SINT32 offset; 04271 SINT32 progressTimer; 04272 SINT32 dimLoop; 04273 Boolean matchInPlace = FALSE; 04274 long progressProcCount = 0; 04275 SINT32 inLineCount; 04276 04277 LH_START_PROC("LHCheckBitMapPrivate") 04278 04279 if( (modelingData)->gamutLutParam.colorLut == 0 )return cmMethodError; 04280 LOCK_DATA((modelingData)->gamutLutParam.inputLut); 04281 LOCK_DATA((modelingData)->gamutLutParam.colorLut); 04282 LOCK_DATA((modelingData)->gamutLutParam.outputLut); 04283 04284 SetMem(&info, sizeof(ColorSpaceInfo), 0); 04285 SetMem(&calcParam, sizeof(CMCalcParam), 0); 04286 04287 if ( (outBitMap == nil ) || (modelingData->gamutLutParam.colorLut == nil) ) 04288 { 04289 err = cmInvalidDstMap; 04290 goto CleanupAndExit; 04291 } 04292 bitMapOut = *outBitMap; 04293 FillLutParamChk(&lutParam, modelingData); 04294 FillCalcParam(&calcParam, &bitMapIn, &bitMapOut); 04295 04296 err = CheckInputColorSpace( &bitMapIn, &calcParam, &info, inColorSpace, lutParam.colorLutInDim ); 04297 inLineCount = calcParam.cmLineCount; 04298 if (err) 04299 goto CleanupAndExit; 04300 04301 err = CheckOutputColorSpaceChk( &bitMapOut, &calcParam, &info ); 04302 if (err) 04303 goto CleanupAndExit; 04304 04305 info.inPlace = bitMapOut.image == bitMapIn.image && info.tempInBuffer == nil && info.tempOutBuffer == nil; 04306 calcRoutine = FindCalcRoutine( &calcParam, &lutParam, &info, modelingData->lookup ); 04307 if (calcRoutine == nil) 04308 { 04309 err = cmMethodError; 04310 goto CleanupAndExit; 04311 } 04312 04313 /* ------------------------------------------------- 8 or 16 bit data --------------------------------------------------------- */ 04314 if ((info.tempInBuffer == nil) && (info.tempOutBuffer == nil) && modelingData->hasNamedColorProf == NoNamedColorProfile) 04315 { 04316 if (progressProc == nil) 04317 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); /* no callback proc - do it all in one step */ 04318 else 04319 { 04320 calcParam.cmLineCount = kMaxTempBlock / calcParam.cmInputBytesPerLine; 04321 if (calcParam.cmLineCount < 1) 04322 calcParam.cmLineCount = 1; 04323 else if (calcParam.cmLineCount > bitMapIn.height) 04324 calcParam.cmLineCount = bitMapIn.height; 04325 04326 progressTimer = TickCount(); 04327 while ( info.processedLinesIn < bitMapIn.height ) 04328 { 04329 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); 04330 04331 for (dimLoop = 0; dimLoop< lutParam.colorLutInDim; dimLoop++) 04332 calcParam.inputData[dimLoop] = (Ptr)calcParam.inputData[dimLoop] + calcParam.cmLineCount * calcParam.cmInputBytesPerLine; 04333 04334 for (dimLoop = 0; dimLoop< lutParam.colorLutOutDim; dimLoop++) 04335 calcParam.outputData[dimLoop] = (Ptr)calcParam.outputData[dimLoop] + calcParam.cmLineCount * calcParam.cmOutputBytesPerLine; 04336 04337 info.processedLinesIn += calcParam.cmLineCount; 04338 if ( info.processedLinesIn + calcParam.cmLineCount > bitMapIn.height ) 04339 calcParam.cmLineCount = bitMapIn.height-info.processedLinesIn; 04340 04341 /* - - - - - handle CMBitmapCallBackProc - - - - - */ 04342 if ( progressProc && ( progressTimer + kProgressTicks < (SINT32)TickCount()) ) 04343 { 04344 progressProcWasCalled = TRUE; 04345 if (CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, info.processedLinesIn, (void *)refCon )) 04346 { 04347 info.processedLinesIn = bitMapIn.height; 04348 err = userCanceledErr; 04349 } else 04350 progressTimer = TickCount(); 04351 progressProcCount = info.processedLinesIn; 04352 } 04353 } 04354 } 04355 } 04356 else if (modelingData->hasNamedColorProf != NamedColorProfileOnly ){ 04357 info.processedLinesIn = 0; 04358 progressTimer = TickCount(); 04359 if( info.tempInBuffer && info.tempOutBuffer ){ 04360 if( inLineCount > calcParam.cmLineCount )inLineCount = calcParam.cmLineCount; 04361 } 04362 else if( info.tempInBuffer ){ 04363 } 04364 else if( info.tempOutBuffer ){ 04365 inLineCount = calcParam.cmLineCount; 04366 } 04367 else if( progressProc ){ 04368 inLineCount = kMaxTempBlock / calcParam.cmInputBytesPerLine; 04369 if (inLineCount < 1) 04370 inLineCount = 1; 04371 else if (inLineCount > bitMapIn.height) 04372 inLineCount = bitMapIn.height; 04373 } 04374 while ( info.processedLinesIn < bitMapIn.height ) 04375 { 04376 if ( info.processedLinesIn + inLineCount > bitMapIn.height ) 04377 inLineCount = bitMapIn.height-info.processedLinesIn; 04378 04379 if (info.origSizeIn == 5 ) /* input is 5 bit */ 04380 Convert5To8 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04381 #ifdef PI_Application_h 04382 else if (info.origSizeIn == 6 ) /* output is 5 bit */ 04383 Convert565To8 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04384 #endif 04385 else if (info.origSizeIn == 10 ) 04386 Convert10To16 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04387 04388 if (modelingData->hasNamedColorProf == NamedColorProfileAtBegin ){ 04389 err = ConvertIndexToLabBitmap( modelingData, bitMapIn.image, 04390 (Ptr)info.tempInBuffer, info.processedLinesIn, 04391 inLineCount, bitMapIn.width, 04392 bitMapIn.rowBytes, 04393 calcParam.cmInputBytesPerLine, 04394 calcParam.cmInputPixelOffset*8 ); 04395 if (err) 04396 goto CleanupAndExit; 04397 } 04398 calcParam.cmLineCount = inLineCount; 04399 err = CallCalcProc( calcRoutine, &calcParam, &lutParam ); 04400 if (err) 04401 goto CleanupAndExit; 04402 04403 if( info.origSizeOut == 1 ) /* output is 5 bit */ 04404 Convert8To1 ( (Ptr)info.tempOutBuffer, bitMapOut.image, info.processedLinesIn, calcParam.cmLineCount, bitMapOut.width, bitMapOut.rowBytes); 04405 04406 info.processedLinesIn += inLineCount; 04407 /* - - - - - handle CMBitmapCallBackProc - - - - - */ 04408 if ( progressProc && ( progressTimer + kProgressTicks < (SINT32)TickCount()) ) 04409 { 04410 progressProcWasCalled = TRUE; 04411 if (CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, info.processedLinesIn, (void *)refCon )) 04412 { 04413 info.processedLinesIn = bitMapIn.height; 04414 err = userCanceledErr; 04415 } else 04416 progressTimer = TickCount(); 04417 progressProcCount = info.processedLinesIn; 04418 } 04419 if( !info.tempInBuffer ){ 04420 offset = calcParam.cmLineCount * calcParam.cmInputBytesPerLine; 04421 for (dimLoop = 0; dimLoop< lutParam.colorLutInDim; dimLoop++) 04422 calcParam.inputData[dimLoop] = (Ptr)calcParam.inputData[dimLoop] + offset; 04423 } 04424 if( !info.tempOutBuffer ){ 04425 offset = calcParam.cmLineCount * calcParam.cmOutputBytesPerLine; 04426 for (dimLoop = 0; dimLoop< lutParam.colorLutOutDim; dimLoop++) 04427 calcParam.outputData[dimLoop] = (Ptr)calcParam.outputData[dimLoop] + offset; 04428 } 04429 } 04430 DisposeIfPtr((Ptr)info.tempInBuffer); 04431 DisposeIfPtr((Ptr)info.tempOutBuffer); 04432 } 04433 else{ 04434 DisposeIfPtr((Ptr)info.tempInBuffer); 04435 err = cmMethodError; 04436 goto CleanupAndExit; 04437 } 04438 if (err) 04439 goto CleanupAndExit; 04440 04441 if( progressProcWasCalled && progressProcCount != bitMapIn.height ) 04442 CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, bitMapIn.height, (void *)refCon ); 04443 CleanupAndExit: 04444 UNLOCK_DATA((modelingData)->gamutLutParam.inputLut); 04445 UNLOCK_DATA((modelingData)->gamutLutParam.colorLut); 04446 UNLOCK_DATA((modelingData)->gamutLutParam.outputLut); 04447 04448 LH_END_PROC("LHCheckBitMapPrivate") 04449 04450 return err; 04451 }

CMError LHCheckColorsPrivate CMMModelPtr  modelingData,
CMColor myColors,
UINT32  count,
unsigned char *  result
 

CMError LHCheckColorsPrivateMS CMMModelPtr  modelingData,
CMColor myColors,
UINT32  count,
UINT8 result
 

Definition at line 3797 of file lh_core/runtime.c.

03801 { 03802 CMCalcParam calcParam; 03803 CMLutParam lutParam; 03804 CMError err = -1; 03805 ColorSpaceInfo info; 03806 CalcProcPtr calcRoutine = nil; 03807 03808 LH_START_PROC("LHCheckColorsPrivateMS") 03809 03810 if( (modelingData)->gamutLutParam.colorLut == 0 )return cmMethodError; 03811 LOCK_DATA((modelingData)->gamutLutParam.inputLut); 03812 LOCK_DATA((modelingData)->gamutLutParam.colorLut); 03813 LOCK_DATA((modelingData)->gamutLutParam.outputLut); 03814 03815 /* preprocess for NamedColor stuff */ 03816 if (modelingData->hasNamedColorProf == NamedColorProfileOnly){ 03817 err = unimpErr; 03818 goto CleanupAndExit; 03819 } 03820 else if (modelingData->hasNamedColorProf==NamedColorProfileAtBegin){ 03821 err = ConvertNamedIndexToPCS(modelingData,myColors,count); 03822 if (err) goto CleanupAndExit; 03823 } 03824 03825 SetMem(&info, sizeof(ColorSpaceInfo), 0); 03826 SetMem(&calcParam, sizeof(CMCalcParam), 0); 03827 03828 info.origSizeIn = 16; 03829 info.origSizeOut = 8; 03830 info.usedSizeIn = 16; 03831 info.usedSizeOut = 8; 03832 03833 FillLutParamChk(&lutParam, modelingData); 03834 FillCalcParamCM(&calcParam, &lutParam, myColors, count ); 03835 calcParam.outputData[0] = (Ptr)result; 03836 calcParam.cmOutputBytesPerLine = count*sizeof(UINT8); 03837 calcParam.cmOutputPixelOffset = 1; 03838 calcParam.cmOutputColorSpace = cmGraySpace8Bit; /* cmGraySpace is 16 bit */ 03839 03840 03841 info.inPlace = (UINT8 *)myColors == result; 03842 calcRoutine = FindCalcRoutine( &calcParam, &lutParam, &info, modelingData->lookup ); 03843 if (calcRoutine == nil) 03844 { 03845 err = cmMethodError; 03846 goto CleanupAndExit; 03847 } 03848 03849 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); 03850 if (err) 03851 goto CleanupAndExit; 03852 03853 /* postprocess for NamedColor stuff */ 03854 if( modelingData->hasNamedColorProf == NamedColorProfileAtEnd ){ 03855 err = unimpErr; 03856 goto CleanupAndExit; 03857 } 03858 CleanupAndExit: 03859 UNLOCK_DATA((modelingData)->gamutLutParam.inputLut); 03860 UNLOCK_DATA((modelingData)->gamutLutParam.colorLut); 03861 UNLOCK_DATA((modelingData)->gamutLutParam.outputLut); 03862 03863 LH_END_PROC("LHCheckColorsPrivateMS") 03864 return err; 03865 }

CMError LHMatchBitMapPlanePrivate CMMModelPtr  modelingData,
const LH_CMBitmapPlane bitMapLH,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
LH_CMBitmapPlane matchedBitMapLH
 

Definition at line 4466 of file lh_core/runtime.c.

04471 { 04472 CMCalcParam calcParam; 04473 CMLutParam lutParam; 04474 CMError err = -1; 04475 ColorSpaceInfo info; 04476 CalcProcPtr calcRoutine = nil; 04477 LH_CMBitmapPlane * secondBitmapLH = matchedBitMapLH; 04478 OSType inColorSpace = (modelingData)->firstColorSpace; 04479 OSType outColorSpace = (modelingData)->lastColorSpace; 04480 Boolean progressProcWasCalled = FALSE; 04481 Boolean matchInPlace = FALSE; 04482 SINT32 dimLoop; 04483 04484 LH_START_PROC("LHMatchBitMapPlanePrivate") 04485 04486 SetMem(&info, sizeof(ColorSpaceInfo), 0); 04487 SetMem(&calcParam, sizeof(CMCalcParam), 0); 04488 04489 if (secondBitmapLH == nil) 04490 { 04491 secondBitmapLH = (LH_CMBitmapPlane *)bitMapLH; 04492 matchInPlace = TRUE; 04493 } 04494 04495 LOCK_DATA((modelingData)->lutParam.inputLut); 04496 LOCK_DATA((modelingData)->lutParam.colorLut); 04497 LOCK_DATA((modelingData)->lutParam.outputLut); 04498 04499 /* create CMBitmap based on the LH_CMBitmapPlane - so we can use the 'standard' setup functions */ 04500 { 04501 CMBitmap bitMap; 04502 CMBitmap secondBitmap; 04503 04504 bitMap.image = bitMapLH->image[0]; 04505 bitMap.width = bitMapLH->width; 04506 bitMap.height = bitMapLH->height; 04507 bitMap.rowBytes = bitMapLH->rowBytes; 04508 bitMap.pixelSize = bitMapLH->pixelSize; 04509 bitMap.space = bitMapLH->space; 04510 04511 secondBitmap.image = secondBitmapLH->image[0]; 04512 secondBitmap.width = secondBitmapLH->width; 04513 secondBitmap.height = secondBitmapLH->height; 04514 secondBitmap.rowBytes = secondBitmapLH->rowBytes; 04515 secondBitmap.pixelSize = secondBitmapLH->pixelSize; 04516 secondBitmap.space = secondBitmapLH->space; 04517 04518 FillLutParam(&lutParam, modelingData); 04519 FillCalcParam(&calcParam, &bitMap, &secondBitmap); 04520 04521 err = CheckInputColorSpace(&bitMap,&calcParam, &info, inColorSpace, lutParam.colorLutInDim ); 04522 if (err) 04523 goto CleanupAndExit; 04524 err = CheckOutputColorSpace(&secondBitmap,&calcParam, &info, outColorSpace, lutParam.colorLutOutDim ); 04525 if (err) 04526 goto CleanupAndExit; 04527 } 04528 04529 /* now update the input/output data pointers */ 04530 for (dimLoop = 0; dimLoop < 8; dimLoop++) 04531 { 04532 calcParam.inputData[dimLoop] = bitMapLH->image[dimLoop]; 04533 calcParam.outputData[dimLoop] = secondBitmapLH->image[dimLoop]; 04534 } 04535 04536 calcParam.cmInputPixelOffset = bitMapLH->elementOffset; 04537 calcParam.cmOutputPixelOffset = secondBitmapLH->elementOffset; 04538 if (bitMapLH == secondBitmapLH) /* matching in place - check if pixeloffsets are ok */ 04539 { 04540 if (calcParam.cmInputPixelOffset < calcParam.cmOutputPixelOffset) 04541 { 04542 err = cmInvalidDstMap; 04543 goto CleanupAndExit; 04544 } 04545 if (info.origSizeIn * lutParam.colorLutInDim < info.origSizeOut * lutParam.colorLutOutDim) 04546 { 04547 err = cmInvalidDstMap; 04548 goto CleanupAndExit; 04549 } 04550 } else 04551 { 04552 calcParam.copyAlpha = (calcParam.cmInputColorSpace & cmAlphaSpace) && (calcParam.cmOutputColorSpace & cmAlphaSpace); 04553 } 04554 04555 info.inPlace = info.tempInBuffer == nil && info.tempOutBuffer == nil; 04556 calcRoutine = FindCalcRoutine( &calcParam, &lutParam, &info, modelingData->lookup ); 04557 if (calcRoutine == nil) 04558 { 04559 err = cmMethodError; 04560 goto CleanupAndExit; 04561 } 04562 04563 /* ------------------------------------------------- 8 or 16 bit data --------------------------------------------------------- */ 04564 if ((info.tempInBuffer == nil) && (info.tempOutBuffer == nil)) 04565 { 04566 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); 04567 } 04568 /* ----------------------------------------------- input is 5 or 10 bit ------------------------------------------------------- */ 04569 else if ((info.tempInBuffer != nil) && (info.tempOutBuffer == nil)) 04570 { 04571 DisposeIfPtr((Ptr)info.tempInBuffer); 04572 } 04573 /* ----------------------------------------------- output is 5 or 10 bit ------------------------------------------------------- */ 04574 else if ((info.tempInBuffer == nil) && (info.tempOutBuffer != nil)) 04575 { 04576 DisposeIfPtr((Ptr)info.tempOutBuffer); 04577 } 04578 /* ------------------------------------------ input and output are 5 or 10 bit ------------------------------------------------- */ 04579 else 04580 { 04581 DisposeIfPtr((Ptr)info.tempInBuffer); 04582 DisposeIfPtr((Ptr)info.tempOutBuffer); 04583 } 04584 04585 if (progressProcWasCalled) 04586 CallCMBitmapCallBackProc ( progressProc, 0, 0, (void *)refCon ); 04587 CleanupAndExit: 04588 UNLOCK_DATA((modelingData)->lutParam.inputLut); 04589 UNLOCK_DATA((modelingData)->lutParam.colorLut); 04590 UNLOCK_DATA((modelingData)->lutParam.outputLut); 04591 04592 LH_END_PROC("LHMatchBitMapPlanePrivate") 04593 return err; 04594 }

CMError LHMatchBitMapPrivate CMMModelPtr  modelingData,
const CMBitmap bitMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap matchedBitMap
 

Definition at line 3995 of file lh_core/runtime.c.

04000 { 04001 CMCalcParam calcParam; 04002 CMLutParam lutParam; 04003 CMError err = -1; 04004 ColorSpaceInfo info; 04005 CalcProcPtr calcRoutine = nil; 04006 CMBitmap bitMapOut; 04007 CMBitmap bitMapIn = *inBitMap; 04008 OSType inColorSpace = modelingData->firstColorSpace; 04009 OSType outColorSpace = modelingData->lastColorSpace; 04010 Boolean progressProcWasCalled = FALSE; 04011 SINT32 offset; 04012 SINT32 progressTimer; 04013 SINT32 dimLoop; 04014 Boolean matchInPlace = FALSE; 04015 long progressProcCount = 0; 04016 SINT32 inLineCount; 04017 Ptr aBuffer; 04018 04019 LH_START_PROC("LHMatchBitMapPrivate") 04020 04021 LOCK_DATA((modelingData)->lutParam.inputLut); 04022 LOCK_DATA((modelingData)->lutParam.colorLut); 04023 LOCK_DATA((modelingData)->lutParam.outputLut); 04024 04025 if( outBitMap == nil ){ 04026 bitMapOut = *inBitMap; 04027 matchInPlace = TRUE; 04028 } 04029 else{ 04030 bitMapOut = *outBitMap; 04031 } 04032 04033 SetMem(&info, sizeof(ColorSpaceInfo), 0); 04034 SetMem(&calcParam, sizeof(CMCalcParam), 0); 04035 04036 FillLutParam(&lutParam, modelingData); 04037 FillCalcParam(&calcParam, &bitMapIn, &bitMapOut); 04038 04039 err = CheckInputColorSpace( &bitMapIn, &calcParam, &info, inColorSpace, lutParam.colorLutInDim ); 04040 inLineCount = calcParam.cmLineCount; 04041 if (err) 04042 goto CleanupAndExit; 04043 04044 if (matchInPlace){ 04045 err = SetOutputColorSpaceInplace( &calcParam, &info, outColorSpace); 04046 if (err) 04047 goto CleanupAndExit; 04048 } 04049 err = CheckOutputColorSpace( &bitMapOut, &calcParam, &info, outColorSpace, lutParam.colorLutOutDim ); 04050 if (err) 04051 goto CleanupAndExit; 04052 04053 if (matchInPlace) /* matching in place - check if pixel sizes are ok */ 04054 { 04055 if (info.inputPixelSize < info.outputPixelSize) 04056 { 04057 err = cmInvalidDstMap; 04058 goto CleanupAndExit; 04059 } 04060 /* set the color space field to the output color space */ 04061 bitMapIn.space = calcParam.cmOutputColorSpace; 04062 } else 04063 { 04064 calcParam.copyAlpha = (calcParam.cmInputColorSpace & cmAlphaSpace) && (calcParam.cmOutputColorSpace & cmAlphaSpace); 04065 } 04066 04067 info.inPlace = bitMapOut.image == bitMapIn.image && info.tempInBuffer == nil && info.tempOutBuffer == nil; 04068 calcRoutine = FindCalcRoutine( &calcParam, &lutParam, &info, modelingData->lookup ); 04069 if (calcRoutine == nil) 04070 { 04071 err = cmMethodError; 04072 goto CleanupAndExit; 04073 } 04074 04075 if( info.inPlace && calcParam.cmInputPixelOffset < calcParam.cmOutputPixelOffset ){ 04076 for( dimLoop=0; dimLoop<8; dimLoop++){ /* now work backwards */ 04077 calcParam.inputData[dimLoop] = (Ptr)calcParam.inputData[dimLoop] + (calcParam.cmLineCount-1) * calcParam.cmInputBytesPerLine + (calcParam.cmPixelPerLine-1) * calcParam.cmInputPixelOffset; 04078 calcParam.outputData[dimLoop] = (Ptr)calcParam.outputData[dimLoop] + (calcParam.cmLineCount-1) * calcParam.cmOutputBytesPerLine + (calcParam.cmPixelPerLine-1) * calcParam.cmOutputPixelOffset; 04079 } 04080 calcParam.cmInputPixelOffset = -calcParam.cmInputPixelOffset; 04081 calcParam.cmOutputPixelOffset = -calcParam.cmOutputPixelOffset; 04082 calcParam.cmInputBytesPerLine = -calcParam.cmInputBytesPerLine; 04083 calcParam.cmOutputBytesPerLine = -calcParam.cmOutputBytesPerLine; 04084 } 04085 /* ------------------------------------------------- 8 or 16 bit data --------------------------------------------------------- */ 04086 if ((info.tempInBuffer == nil) && (info.tempOutBuffer == nil)&& modelingData->hasNamedColorProf == NoNamedColorProfile) 04087 { 04088 if (progressProc == nil) 04089 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); /* no callback proc - do it all in one step */ 04090 else 04091 { 04092 calcParam.cmLineCount = kMaxTempBlock / calcParam.cmInputBytesPerLine; 04093 if (calcParam.cmLineCount < 1) 04094 calcParam.cmLineCount = 1; 04095 else if (calcParam.cmLineCount > bitMapIn.height) 04096 calcParam.cmLineCount = bitMapIn.height; 04097 04098 progressTimer = TickCount(); 04099 while ( info.processedLinesIn < bitMapIn.height ) 04100 { 04101 err = CallCalcProc(calcRoutine,&calcParam, &lutParam); 04102 04103 for (dimLoop = 0; dimLoop< lutParam.colorLutInDim; dimLoop++) 04104 calcParam.inputData[dimLoop] = (Ptr)calcParam.inputData[dimLoop] + calcParam.cmLineCount * calcParam.cmInputBytesPerLine; 04105 04106 for (dimLoop = 0; dimLoop< lutParam.colorLutOutDim; dimLoop++) 04107 calcParam.outputData[dimLoop] = (Ptr)calcParam.outputData[dimLoop] + calcParam.cmLineCount * calcParam.cmOutputBytesPerLine; 04108 04109 info.processedLinesIn += calcParam.cmLineCount; 04110 if ( info.processedLinesIn + calcParam.cmLineCount > bitMapIn.height ) 04111 calcParam.cmLineCount = bitMapIn.height-info.processedLinesIn; 04112 04113 /* - - - - - handle CMBitmapCallBackProc - - - - - */ 04114 if ( progressProc && ( progressTimer + kProgressTicks < (SINT32)TickCount()) ) 04115 { 04116 progressProcWasCalled = TRUE; 04117 if (CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, info.processedLinesIn, (void *)refCon )) 04118 { 04119 info.processedLinesIn = bitMapIn.height; 04120 err = userCanceledErr; 04121 } else 04122 progressTimer = TickCount(); 04123 progressProcCount = info.processedLinesIn; 04124 } 04125 } 04126 } 04127 } 04128 else if (modelingData->hasNamedColorProf != NamedColorProfileOnly ){ 04129 info.processedLinesIn = 0; 04130 progressTimer = TickCount(); 04131 if( info.tempInBuffer && info.tempOutBuffer ){ 04132 if( inLineCount > calcParam.cmLineCount )inLineCount = calcParam.cmLineCount; 04133 } 04134 else if( info.tempInBuffer ){ 04135 if( progressProc && modelingData->hasNamedColorProf == NamedColorProfileAtEnd ){ 04136 inLineCount /= 32; 04137 if( inLineCount < 1 ) inLineCount = 1; 04138 } 04139 } 04140 else if( info.tempOutBuffer ){ 04141 inLineCount = calcParam.cmLineCount; 04142 } 04143 else if( progressProc ){ 04144 inLineCount = kMaxTempBlock / calcParam.cmInputBytesPerLine; 04145 if (inLineCount < 1) 04146 inLineCount = 1; 04147 else if (inLineCount > bitMapIn.height) 04148 inLineCount = bitMapIn.height; 04149 if( modelingData->hasNamedColorProf == NamedColorProfileAtEnd ){ 04150 inLineCount /= 32; 04151 if( inLineCount < 1 ) inLineCount = 1; 04152 } 04153 } 04154 while ( info.processedLinesIn < bitMapIn.height ) 04155 { 04156 if ( info.processedLinesIn + inLineCount > bitMapIn.height ) 04157 inLineCount = bitMapIn.height-info.processedLinesIn; 04158 04159 if (info.origSizeIn == 5 ) /* input is 5 bit */ 04160 Convert5To8 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04161 #ifdef PI_Application_h 04162 else if (info.origSizeIn == 6 ) /* output is 5 bit */ 04163 Convert565To8 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04164 #endif 04165 else if (info.origSizeIn == 10 ) 04166 Convert10To16 ( bitMapIn.image, (Ptr)info.tempInBuffer, info.processedLinesIn, inLineCount, bitMapIn.width, bitMapIn.rowBytes ); 04167 04168 if (modelingData->hasNamedColorProf == NamedColorProfileAtBegin ){ 04169 err = ConvertIndexToLabBitmap( modelingData, bitMapIn.image, 04170 (Ptr)info.tempInBuffer, info.processedLinesIn, 04171 inLineCount, bitMapIn.width, 04172 bitMapIn.rowBytes, 04173 calcParam.cmInputBytesPerLine, 04174 calcParam.cmInputPixelOffset*8 ); 04175 if (err) 04176 goto CleanupAndExit; 04177 } 04178 calcParam.cmLineCount = inLineCount; 04179 err = CallCalcProc( calcRoutine, &calcParam, &lutParam ); 04180 if (err) 04181 goto CleanupAndExit; 04182 04183 if (modelingData->hasNamedColorProf == NamedColorProfileAtEnd ){ 04184 if( info.tempOutBuffer )aBuffer = (Ptr)info.tempOutBuffer; 04185 else aBuffer = bitMapOut.image; 04186 err = ConvertLabToIndexBitmap( modelingData, aBuffer, 04187 info.processedLinesIn, 04188 calcParam.cmLineCount, 04189 bitMapOut.width, bitMapOut.rowBytes ); 04190 if (err) 04191 goto CleanupAndExit; 04192 } 04193 04194 if( info.origSizeOut == 5 ) /* output is 5 bit */ 04195 Convert8To5 ( (Ptr)info.tempOutBuffer, bitMapOut.image, info.processedLinesIn, calcParam.cmLineCount, bitMapOut.width, bitMapOut.rowBytes); 04196 #ifdef PI_Application_h 04197 else if( info.origSizeOut == 6 ) /* output is 5 bit */ 04198 Convert8To565 ( (Ptr)info.tempOutBuffer, bitMapOut.image, info.processedLinesIn, calcParam.cmLineCount, bitMapOut.width, bitMapOut.rowBytes); 04199 #endif 04200 else if( info.origSizeOut == 10 ) /* output is 10 bit */ 04201 Convert16To10 ( (Ptr)info.tempOutBuffer, bitMapOut.image, info.processedLinesIn, calcParam.cmLineCount, bitMapOut.width, bitMapOut.rowBytes); 04202 04203 info.processedLinesIn += inLineCount; 04204 /* - - - - - handle CMBitmapCallBackProc - - - - - */ 04205 if ( progressProc && ( progressTimer + kProgressTicks < (SINT32)TickCount()) ) 04206 { 04207 progressProcWasCalled = TRUE; 04208 if (CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, info.processedLinesIn, (void *)refCon )) 04209 { 04210 info.processedLinesIn = bitMapIn.height; 04211 err = userCanceledErr; 04212 } else 04213 progressTimer = TickCount(); 04214 progressProcCount = info.processedLinesIn; 04215 } 04216 if( !info.tempInBuffer ){ 04217 offset = calcParam.cmLineCount * calcParam.cmInputBytesPerLine; 04218 for (dimLoop = 0; dimLoop< lutParam.colorLutInDim; dimLoop++) 04219 calcParam.inputData[dimLoop] = (Ptr)calcParam.inputData[dimLoop] + offset; 04220 } 04221 if( !info.tempOutBuffer ){ 04222 offset = calcParam.cmLineCount * calcParam.cmOutputBytesPerLine; 04223 for (dimLoop = 0; dimLoop< lutParam.colorLutOutDim; dimLoop++) 04224 calcParam.outputData[dimLoop] = (Ptr)calcParam.outputData[dimLoop] + offset; 04225 } 04226 } 04227 } 04228 else{ 04229 CopyIndexData( &bitMapIn, &bitMapOut, &info ); 04230 } 04231 if (err) 04232 goto CleanupAndExit; 04233 04234 if( progressProcWasCalled && progressProcCount != bitMapIn.height ) 04235 CallCMBitmapCallBackProc ( progressProc, bitMapIn.height, bitMapIn.height, (void *)refCon ); 04236 CleanupAndExit: 04237 04238 /* Clean up temporary storage */ 04239 DisposeIfPtr((Ptr)info.tempInBuffer); 04240 DisposeIfPtr((Ptr)info.tempOutBuffer); 04241 04242 UNLOCK_DATA((modelingData)->lutParam.inputLut); 04243 UNLOCK_DATA((modelingData)->lutParam.colorLut); 04244 UNLOCK_DATA((modelingData)->lutParam.outputLut); 04245 04246 LH_END_PROC("LHMatchBitMapPrivate") 04247 04248 return err; 04249 }

CMError LHMatchColorsPrivate CMMModelPtr  modelingData,
CMColor myColors,
long  count
 

OSErr MidProcNamedColorMatchBitmap CMMModelPtr  modelingData,
CMBitmap InBitMap,
Ptr  dataOut,
UINT32  startLine,
UINT32  height
 

OSErr PostProcNamedColorMatchBitmap CMMModelPtr  modelingData,
CMBitmap inBitMap,
CMBitmap outBitMap
 

OSErr PreProcNamedColorMatchBitmap CMMModelPtr  modelingData,
CMBitmap inBitMap,
CMBitmap outBitMap,
Boolean  MatchInPlace
 


Generated on Sat May 15 19:45:31 2004 for test by doxygen 1.3.7