test: w98/mscmm/memprof.c File Reference

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

# memprof.c File Reference

`#include "Windef.h"`
`#include "WinGdi.h"`
`#include <wtypes.h>`
`#include <winbase.h>`
`#include <windowsX.h>`
`#include "ICM.h"`
`#include "General.h"`
`#include "MemProf.h"`
`#include "MemLink.h"`
`#include <io.h>`
`#include <fcntl.h>`
`#include <sys/stat.h>`

Go to the source code of this file.

## Functions

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)

## Function Documentation

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

Definition at line 46 of file w98/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 w98/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 w98/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 w98/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 }