test: w98/mscmm/memprof.h File Reference

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

# memprof.h File Reference

Go to the source code of this file.

## Functions

CMError | MyNewAbstractW (LPLOGCOLORSPACEW lpColorSpace, icProfile **theProf)
CMError | MyNewAbstract (LPLOGCOLORSPACEA lpColorSpace, icProfile **theProf)
CMError | MyNewDeviceLink (CMWorldRef cw, CMConcatProfileSet *profileSet, LPSTR theProf)
CMError | MyNewDeviceLinkW (CMWorldRef cw, CMConcatProfileSet *profileSet, LPWSTR theProf)
CMError | MyNewDeviceLinkFill (CMWorldRef cw, CMConcatProfileSet *profileSet, HPROFILE aHProf)
long | SaveMyProfile (LPSTR lpProfileName, LPWSTR lpProfileNameW, PPROFILE theProf)
CMError | DeviceLinkFill (CMMModelPtr cw, CMConcatProfileSet *profileSet, icProfile **theProf, unsigned long aIntent)
UINT32 | GetSizes (CMMModelPtr cw, UINT32 *clutSize)

## Function Documentation

CMError DeviceLinkFill | ( | CMMModelPtr | cw,
|  | CMConcatProfileSet * | profileSet,
|  | icProfile ** | theProf,
|  | unsigned long | aIntent
| ) |

Definition at line 1281 of file lh_core/memlink.c.

References BlockMove(), CMError, CMHelperICC2int32Const, CMMModelPtr, cmProfileError, icTagList::count, DisposeIfPtr(), GetSizes(), icSigAToB0Tag, icSigCopyrightTag, icSigLinkClass, icSigMediaWhitePointTag, icSigProfileDescriptionTag, icSigProfileSequenceDescTag, LINK_BUFFER_MAX, MyAdd_NL_AToB0Tag_mft1(), MyAdd_NL_AToB0Tag_mft2(), MyAdd_NL_ColorantTag(), MyAdd_NL_CopyrightTag(), MyAdd_NL_DescriptionTag(), MyAdd_NL_Header(), MyAdd_NL_SequenceDescTag(), MyGetColorSpaces(), MyTagCountLink, noErr, NoNamedColorProfile, icTag::offset, OSErr, OSType, Ptr, icTag::sig, icTag::size, SmartNewPtr(), SmartNewPtrClear(), icProfile::tagList, icTagList::tags, UINT32, unimpErr, and WriteProf().

Referenced by CMCreateDeviceLinkProfile(), CWConcatColorWorld4MS(), and CWCreateLink4MS().

    01285 {
    01286         CMError                 err = unimpErr;
    01287         OSErr                   aOSerr = unimpErr;
    01288 #ifdef __MWERKS__
    01289         unsigned char   theText[] = "\pDeviceLink profile  ";
    01290         char                    copyrightText[] = "\p©1996 by Heidelberger Druckmaschinen AG  U.J.K.";
    01291 #elif __IS_MSDOS
    01292         char                    theText[] = "\030DeviceLink profile     ";
    01293         char                    copyrightText[] = "\060©1996 by Heidelberger Druckmaschinen AG  U.J.K.";
    01294 #else
    01295         char                    theText[] = "\030DeviceLink profile     ";
    01296         char                    copyrightText[] = "\060©1996 by Heidelberger Druckmaschinen AG  U.J.K.";
    01297 #endif
    01298         icProfile               *aProf=0;
    01299         long                    theTagTabSize;
    01300         long                    theHeaderSize;
    01301         long                    theDescSize;
    01302         long                    theMediaSize;
    01303         long                    theSequenceDescSize;
    01304         long                    theA2B0Size;
    01305         long                    theCopyRightSize;
    01306         long                    currentSize=0;
    01307         long                    theTotalSize=0;
    01308         icTag                   aTag;
    01309         UINT32                  sCS,dCS,clutSize;
    01310         Ptr                             aPtr=0;
    01311
    01312         MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
    01313         MyXYZNumber D50 = { (unsigned long)(0.9642 * 65536), (unsigned long)(1.0000 * 65536), (unsigned long)(0.8249 * 65536)};
    01314         theHeaderSize = sizeof(icHeader);
    01315         theDescSize   =                                                                           sizeof(OSType)                        /* type descriptor */
    01316                                                                                                                 + sizeof(unsigned long)         /* reserved */
    01317                                                                                                                 + sizeof(unsigned long)         /* ASCII length */
    01318                                                                                                                 + theText[0]                            /* ASCII profile description */
    01319                                                                                                                 + sizeof(unsigned long)         /* Unicode code */
    01320                                                                                                                 + sizeof(unsigned long)         /* Unicode character count */
    01321                                                                                                                 + sizeof(unsigned short)        /* Macintosh script code */
    01322                                                                                                                 + sizeof(unsigned char)         /* Macintosh string length */
    01323                                                                                                                 + 67                                            /* Macintosh string */
    01324                                                                                                                 ;
    01325         theCopyRightSize   =                                                              sizeof(OSType)                        /* type descriptor */
    01326                                                                                                                 + sizeof(unsigned long)         /* reserved */
    01327                                                                                                                 + copyrightText[0]                      /* ASCII profile description */
    01328                                                                                                                 ;
    01329         theMediaSize = sizeof( icXYZType );;
    01330
    01331         theTagTabSize = MyTagCountLink * sizeof( icTag ) + sizeof( unsigned long );
    01332
    01333         *theProf = 0;
    01334
    01335         if( cw->hasNamedColorProf != NoNamedColorProfile ){
    01336                 err = cmProfileError;
    01337                 goto CleanupAndExit;
    01338         }
    01339         err = MyGetColorSpaces( profileSet, &sCS, &dCS );
    01340         if (err)
    01341                 goto CleanupAndExit;
    01342
    01343         aProf = (icProfile *)SmartNewPtrClear( LINK_BUFFER_MAX, &aOSerr );
    01344         err = aOSerr;
    01345         if (err)
    01346                 goto CleanupAndExit;
    01347
    01348         err = MyAdd_NL_Header(theTotalSize, (icHeader*)((Ptr)aProf+currentSize), aIntent, icSigLinkClass, sCS, dCS );
    01349         if (err)
    01350                 goto CleanupAndExit;
    01351
    01352         /*----------------------------------------------------------------------------------------- cmProfileDescriptionTag */
    01353         currentSize = theHeaderSize + theTagTabSize;
    01354         CMHelperICC2int32Const(&(aProf->tagList.count ), MyTagCountLink);
    01355
    01356         CMHelperICC2int32Const(&(aTag.sig ), icSigProfileDescriptionTag);
    01357         CMHelperICC2int32Const(&(aTag.offset ), currentSize);
    01358         CMHelperICC2int32Const(&(aTag.size ), theDescSize);
    01359         aProf->tagList.tags[0] = aTag;
    01360         err =MyAdd_NL_DescriptionTag    ( (LHTextDescriptionType *)((Ptr)aProf+currentSize), (unsigned char *)theText );
    01361         if (err)
    01362                 goto CleanupAndExit;
    01363         currentSize += theDescSize;
    01364         currentSize = ( currentSize + 3 ) & ~ 3;
    01365
    01366         CMHelperICC2int32Const(&(aTag.sig ), icSigMediaWhitePointTag);
    01367         CMHelperICC2int32Const(&(aTag.offset ), currentSize );
    01368         CMHelperICC2int32Const(&(aTag.size ), theMediaSize);
    01369         aProf->tagList.tags[1] = aTag;
    01370         MyAdd_NL_ColorantTag((icXYZType *)((Ptr)aProf+currentSize), &D50);
    01371         currentSize += theMediaSize;
    01372         currentSize = ( currentSize + 3 ) & ~ 3;
    01373
    01374         CMHelperICC2int32Const(&(aTag.sig ), icSigCopyrightTag);
    01375         CMHelperICC2int32Const(&(aTag.offset ), currentSize );
    01376         CMHelperICC2int32Const(&(aTag.size ), theCopyRightSize);
    01377         aProf->tagList.tags[2] = aTag;
    01378         err = MyAdd_NL_CopyrightTag( (unsigned char *)copyrightText, (LHTextType *)((Ptr)aProf+currentSize));
    01379         if (err)
    01380                 goto CleanupAndExit;
    01381         currentSize += theCopyRightSize;
    01382         currentSize = ( currentSize + 3 ) & ~ 3;
    01383
    01384         err = MyAdd_NL_SequenceDescTag( profileSet, (icProfileSequenceDescType *)((Ptr)aProf+currentSize), &theSequenceDescSize );
    01385         CMHelperICC2int32Const(&(aTag.sig ), icSigProfileSequenceDescTag);
    01386         CMHelperICC2int32Const(&(aTag.offset ), currentSize );
    01387         CMHelperICC2int32Const(&(aTag.size ), theSequenceDescSize);
    01388         aProf->tagList.tags[3] = aTag;
    01389         currentSize += theSequenceDescSize;
    01390         currentSize = ( currentSize + 3 ) & ~ 3;
    01391
    01392     theA2B0Size = GetSizes( (CMMModelPtr)cw, &clutSize );
    01393
    01394         CMHelperICC2int32Const(&(aTag.sig ), icSigAToB0Tag);
    01395         CMHelperICC2int32Const(&(aTag.offset ), currentSize );
    01396         CMHelperICC2int32Const(&(aTag.size ), theA2B0Size);
    01397         aProf->tagList.tags[4] = aTag;
    01398
    01399 #if __IS_MSDOS
    01400         aPtr = GlobalAllocPtr( GHND, theA2B0Size+currentSize );
    01401         if( aPtr == 0 ){
    01402                 err = GetLastError();
    01403                 goto CleanupAndExit;
    01404         }
    01405 #else
    01406         aPtr =  SmartNewPtr( theA2B0Size+currentSize, &aOSerr );
    01407         err = aOSerr;
    01408         if( err ){
    01409                 goto CleanupAndExit;
    01410         }
    01411 #endif
    01412
    01413
    01414         if ( cw->lutParam.colorLutWordSize == 8 )
    01415         err = MyAdd_NL_AToB0Tag_mft1( (CMMModelPtr)cw, (icLut8Type *)(aPtr+currentSize), clutSize );
    01416     else
    01417         err = MyAdd_NL_AToB0Tag_mft2( (CMMModelPtr)cw, (icLut16Type *)(aPtr+currentSize), clutSize );
    01418
    01419         if (err)
    01420                 goto CleanupAndExit;
    01421
    01422         BlockMove( (Ptr)aProf, aPtr, currentSize );
    01423         aProf = (icProfile *)DisposeIfPtr( (Ptr)aProf );
    01424
    01425         CMHelperICC2int32Const( aPtr, theA2B0Size+currentSize );
    01426
    01427         *theProf = (icProfile *)aPtr;
    01428 #ifdef WRITE_PROFILE
    01429         WriteProf( "DeviceLinkFill.pf", (icProfile *)aPtr, theA2B0Size+currentSize );
    01430 #endif
    01431         return noErr;
    01432
    01433 CleanupAndExit:
    01434         *theProf = (icProfile *)DisposeIfPtr( (Ptr)aProf );
    01435 #if __IS_MSDOS
    01436         if( aPtr )GlobalFreePtr( aPtr );
    01437 #else
    01438         aPtr = DisposeIfPtr( (Ptr)aPtr );
    01439 #endif
    01440         return err;
    01441 }

UINT32 GetSizes | ( | CMMModelPtr | cw,
|  | UINT32 * | clutSize
| ) |

| Referenced by DeviceLinkFill(), and MyNewDeviceLinkFill().

CMError MyNewAbstract | ( | LPLOGCOLORSPACEA | lpColorSpace,
|  | icProfile ** | theProf
| ) |

| Referenced by CMCreateProfile(), and FillProfileFromLog().

CMError MyNewAbstractW | ( | LPLOGCOLORSPACEW | lpColorSpace,
|  | icProfile ** | theProf
| ) |

| Referenced by CMCreateProfileW(), and FillProfileFromLogW().

CMError MyNewDeviceLink | ( | CMWorldRef | cw,
|  | CMConcatProfileSet * | profileSet,
|  | LPSTR | theProf
| ) |

Definition at line 46 of file mscmm/memprof.c.

References CHAR, CMError, MyNewDeviceLinkFill(), strlen(), and unimpErr.

Referenced by CMCreateMultiProfileTransformInternal().

    00047 {
    00048         CMError                 err = unimpErr;
    00049         PROFILE                 pProf;
    00050         HPROFILE                aHProf;
    00051
    00052         pProf.pProfileData = (PVOID *)theProf;
    00053         pProf.dwType = PROFILE_FILENAME;
    00054         pProf.cbDataSize = strlen((const unsigned char *)pProf.pProfileData) * sizeof(CHAR);
    00055         aHProf = OpenColorProfile( &pProf, PROFILE_READWRITE, 0, CREATE_ALWAYS );
    00056         if( !aHProf ){
    00057                 err = GetLastError();
    00058                 goto CleanupAndExit;
    00059         }
    00060         err = MyNewDeviceLinkFill( cw, profileSet, aHProf );
    00061
    00062 CleanupAndExit:
    00063         return err;
    00064 }

CMError MyNewDeviceLinkFill | ( | CMWorldRef | cw,
|  | CMConcatProfileSet * | profileSet,
|  | HPROFILE | aHProf
| ) |

Definition at line 85 of file mscmm/memprof.c.

References CloseColorProfile(), CMError, CMMModelPtr, DisposeIfPtr(), DWORD, GetSizes(), icSigAToB0Tag, icSigCopyrightTag, icSigMediaWhitePointTag, icSigProfileDescriptionTag, icSigProfileSequenceDescTag, MyAdd_NL_AToB0Tag_mft1(), MyAdd_NL_AToB0Tag_mft2(), MyAdd_NL_ColorantTag(), MyAdd_NL_CopyrightTag(), MyAdd_NL_DescriptionTag(), MyAdd_NL_HeaderMS(), MyAdd_NL_SequenceDescTag(), MyGetColorSpaces(), noErr, OSErr, OSType, Ptr, SetColorProfileElement(), SetColorProfileElementSize(), SetColorProfileHeader(), SmartNewPtr(), SmartNewPtrClear(), UINT32, unimpErr, MyDoubleXYZ::X, MyDoubleXYZ::Y, and MyDoubleXYZ::Z.

Referenced by MyNewDeviceLink(), and MyNewDeviceLinkW().

    00086 {
    00087         CMError                 err = unimpErr;
    00088         OSErr                   aOSerr = unimpErr;
    00089 #ifdef __MWERKS__
    00090         unsigned char                   theText[] = "\pLogColorSpProfile¥";
    00091 #else
    00092       char                      theText[] = "\024DeviceLinkProfile   ";
    00093 #endif
    00094         char                    copyrightText[] = "\060©1996 by Heidelberger Druckmaschinen AG  U.J.K.";
    00095         Ptr                     aPtr=0;
    00096         long                    theHeaderSize;
    00097         long                    theDescSize;
    00098         long                    theMediaSize;
    00099         long                    theCopyRightSize;
    00100         long                    currentSize=0;
    00101         long                    theTotalSize=0;
    00102         long                    theSequenceDescSize = 0;
    00103         long                    theA2B0Size;
    00104         unsigned long   aIntent;
    00105         UINT32                  sCS,dCS,clutSize;
    00106         OSErr                   aOSErr;
    00107
    00108
    00109         MyDoubleXYZ D50XYZ = { 0.9642, 1.0000, 0.8249 };
    00110         icXYZNumber D50 = { (unsigned long)(D50XYZ.X * 65536), (unsigned long)(D50XYZ.Y * 65536), (unsigned long)(D50XYZ.Z * 65536)};
    00111         theHeaderSize = sizeof(icHeader);
    00112
    00113         theDescSize   =                                                                           sizeof(OSType)                        /* type descriptor */
    00114                                                                                                                 + sizeof(unsigned long)         /* reserved */
    00115                                                                                                                 + sizeof(unsigned long)         /* ASCII length */
    00116                                                                                                                 + theText[0]                            /* ASCII profile description */
    00117                                                                                                                 + sizeof(unsigned long)         /* Unicode code */
    00118                                                                                                                 + sizeof(unsigned long)         /* Unicode character count */
    00119                                                                                                                 + sizeof(unsigned short)        /* Macintosh script code */
    00120                                                                                                                 + sizeof(unsigned char)         /* Macintosh string length */
    00121                                                                                                                 + 67                                            /* Macintosh string */
    00122                                                                                                                 ;
    00123         theCopyRightSize   =                                                              sizeof(OSType)                        /* type descriptor */
    00124                                                                                                                 + sizeof(unsigned long)         /* reserved */
    00125                                                                                                                 + copyrightText[0]                      /* ASCII profile description */
    00126                                                                                                                 ;
    00127         theMediaSize = sizeof( icXYZType );;
    00128
    00129         aPtr = SmartNewPtrClear( 5000, &aOSerr );
    00130         err = aOSerr;
    00131         if (err)
    00132                 goto CleanupAndExit;
    00133
    00134         aIntent = 0;
    00135
    00136         err = MyGetColorSpaces( profileSet, &sCS, &dCS );
    00137         if (err)
    00138                 goto CleanupAndExit;
    00139
    00140         err = MyAdd_NL_HeaderMS(theHeaderSize+4, (icHeader*)aPtr, aIntent, sCS, dCS );
    00141         if (err)
    00142                 goto CleanupAndExit;
    00143
    00144         err = SetColorProfileHeader( aHProf, (PPROFILEHEADER)aPtr);
    00145         if (!err){
    00146                 err = GetLastError();
    00147                 goto CleanupAndExit;
    00148         }
    00149
    00150         err =MyAdd_NL_DescriptionTag    ( (LHTextDescriptionType *)aPtr, (unsigned char *)theText );
    00151         if (err)
    00152                 goto CleanupAndExit;
    00153         err = SetColorProfileElementSize( aHProf, icSigProfileDescriptionTag, theDescSize );
    00154         if (!err){
    00155                 err = GetLastError();
    00156                 goto CleanupAndExit;
    00157         }
    00158         err = SetColorProfileElement( aHProf, icSigProfileDescriptionTag, 0, (DWORD *)&theDescSize, aPtr );
    00159         if (!err){
    00160                 err = GetLastError();
    00161                 goto CleanupAndExit;
    00162         }
    00163
    00164         err = MyAdd_NL_ColorantTag((icXYZType *)aPtr, &D50);
    00165         if (err)
    00166                 goto CleanupAndExit;
    00167
    00168         err = SetColorProfileElementSize( aHProf, icSigMediaWhitePointTag, theMediaSize );
    00169         if (!err){
    00170                 err = GetLastError();
    00171                 goto CleanupAndExit;
    00172         }
    00173         err = SetColorProfileElement( aHProf, icSigMediaWhitePointTag, 0, (DWORD *)&theMediaSize, aPtr );
    00174         if (!err){
    00175                 err = GetLastError();
    00176                 goto CleanupAndExit;
    00177         }
    00178
    00179         err = MyAdd_NL_CopyrightTag( (unsigned char *)copyrightText, (LHTextType *)aPtr);
    00180         if (err)
    00181                 goto CleanupAndExit;
    00182         err = SetColorProfileElementSize( aHProf, icSigCopyrightTag, theCopyRightSize );
    00183         if (!err){
    00184                 err = GetLastError();
    00185                 goto CleanupAndExit;
    00186         }
    00187         err = SetColorProfileElement( aHProf, icSigCopyrightTag, 0, (DWORD *)&theCopyRightSize, aPtr );
    00188         if (!err){
    00189                 err = GetLastError();
    00190                 goto CleanupAndExit;
    00191         }
    00192
    00193         err = MyAdd_NL_SequenceDescTag( profileSet, (icProfileSequenceDescType *)aPtr, &theSequenceDescSize );
    00194         if (err)
    00195                 goto CleanupAndExit;
    00196         err = SetColorProfileElementSize( aHProf, icSigProfileSequenceDescTag, theSequenceDescSize );
    00197         if (!err){
    00198                 err = GetLastError();
    00199                 goto CleanupAndExit;
    00200         }
    00201         err = SetColorProfileElement( aHProf, icSigProfileSequenceDescTag, 0, (DWORD *)&theSequenceDescSize, aPtr );
    00202         if (!err){
    00203                 err = GetLastError();
    00204                 goto CleanupAndExit;
    00205         }
    00206
    00207         aPtr = DisposeIfPtr( aPtr );
    00208
    00209     theA2B0Size = GetSizes( (CMMModelPtr)cw, &clutSize );
    00210
    00211         aPtr =  SmartNewPtr( theA2B0Size, &aOSErr );
    00212         err = aOSErr;
    00213         if (err)
    00214                 goto CleanupAndExit;
    00215
    00216         if ( ((CMMModelPtr)cw)->lutParam.colorLutWordSize == 8)
    00217         err = MyAdd_NL_AToB0Tag_mft1( (CMMModelPtr)cw, (icLut8Type *)aPtr, clutSize );
    00218     else
    00219         err = MyAdd_NL_AToB0Tag_mft2( (CMMModelPtr)cw, (icLut16Type *)aPtr, clutSize );
    00220
    00221         if (err)
    00222                 goto CleanupAndExit;
    00223
    00224         //if( theA2B0Size > 12000 ) theA2B0Size = 12000;
    00225         err = SetColorProfileElementSize( aHProf, icSigAToB0Tag, theA2B0Size );
    00226         if (!err){
    00227                 err = GetLastError();
    00228                 goto CleanupAndExit;
    00229         }
    00230         err = SetColorProfileElement( aHProf, icSigAToB0Tag, 0, (DWORD *)&theA2B0Size, aPtr );
    00231         if (!err){
    00232                 err = GetLastError();
    00233                 goto CleanupAndExit;
    00234         }
    00235
    00236         err = noErr;
    00237
    00238 CleanupAndExit:
    00239         CloseColorProfile( aHProf );
    00240         aPtr = DisposeIfPtr( aPtr );
    00241         return err;
    00242 }

CMError MyNewDeviceLinkW | ( | CMWorldRef | cw,
|  | CMConcatProfileSet * | profileSet,
|  | LPWSTR | theProf
| ) |

Definition at line 66 of file mscmm/memprof.c.

References CMError, MyNewDeviceLinkFill(), OpenColorProfileW(), and unimpErr.

    00067 {
    00068         CMError                 err = unimpErr;
    00069         PROFILE                 pProf;
    00070         HPROFILE                aHProf;
    00071
    00072         pProf.pProfileData = (PVOID *)theProf;
    00073         pProf.dwType = PROFILE_FILENAME;
    00074         pProf.cbDataSize = wcslen((const unsigned short *)pProf.pProfileData) * sizeof(WCHAR);
    00075         aHProf = OpenColorProfileW( &pProf, PROFILE_READWRITE, 0, CREATE_ALWAYS );
    00076         if( !aHProf ){
    00077                 err = GetLastError();
    00078                 goto CleanupAndExit;
    00079         }
    00080         err = MyNewDeviceLinkFill( cw, profileSet, aHProf );
    00081 CleanupAndExit:
    00082         return err;
    00083 }

long SaveMyProfile | ( | LPSTR | lpProfileName,
|  | LPWSTR | lpProfileNameW,
|  | PPROFILE | theProf
| ) |

Definition at line 274 of file mscmm/memprof.c.

References unimpErr.

    00275 {
    00276         long ret;
    00277         int fh;
    00278
    00279         if( theProf->dwType != PROFILE_MEMBUFFER ){
    00280                 SetLastError( (unsigned long) unimpErr );
    00281                 return 0;
    00282         }
    00283         if( lpProfileNameW == 0 ){
    00284                 if( lpProfileName == 0 ) return 0;
    00285                 fh = _open( lpProfileName, _O_BINARY | _O_CREAT  | _O_EXCL, _S_IREAD | _S_IWRITE );
    00286         }
    00287         else{
    00288                 fh = _wopen( lpProfileNameW, _O_BINARY | _O_CREAT  | _O_EXCL, _S_IREAD | _S_IWRITE );
    00289         }
    00290         if( fh == -1 ) return -1;
    00291
    00292         if( theProf->pProfileData == 0 ){
    00293                 SetLastError( ERROR_INVALID_DATA );
    00294                 return 0;
    00295         }
    00296         ret = _write( fh, theProf->pProfileData, theProf->cbDataSize );
    00297         if( ret == -1 ) return -1;
    00298
    00299         ret = _close( fh );
    00300         if( ret == -1 ) return -1;
    00301         return 0;
    00302 }