00001 
#include "generic.h"
00002 
00003 
#pragma optimize("",off)
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
void 
00025 CreateINTENTControl(
00026     LPSTR       FileName,
00027     LPSTR       SaveFileName,
00028     DWORD       Inter_Intent)
00029 {
00030     
BOOL        Ret;
00031     
CHANDLE     cp;
00032     HGLOBAL     hCP;
00033     HGLOBAL     hBuffer;
00034     
MEMPTR      lpBuffer;
00035     OFSTRUCT    OfStruct;
00036     HFILE       hOutput;
00037     
DWORD       cbSize;
00038     
CSIG        Intent;
00039 
00040     
if( !
LoadCP32( (LPCSTR) 
FileName, &hCP, (
LPCHANDLE) &cp) )
00041     {
00042         
return;
00043     }
00044     
00045     
switch (Inter_Intent)
00046     {
00047         
case 0: 
Intent = 
icPerceptual; 
break;
00048         
case 1: 
Intent = 
icRelativeColorimetric; 
break;
00049         
case 2: 
Intent = 
icSaturation; 
break;
00050         
case 3: 
Intent = 
icAbsoluteColorimetric; 
break;
00051         
default: 
return;
00052     }
00053 
00054     Ret = 
GetPS2ColorRenderingIntent(cp, 
Intent, 
NULL, &cbSize);
00055     
if (Ret)
00056     {
00057         
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00058             
return;
00059         Ret = 
GetPS2ColorRenderingIntent(cp, 
Intent, lpBuffer, &cbSize);
00060         hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00061         cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00062         _lclose(hOutput);
00063         
MemFree(hBuffer);
00064     }
00065     
FreeCP(hCP);
00066 
00067     
if (!Ret)
00068          MessageBox( 
GetFocus(), 
"No PS2 Intent created.", 
NULL, MB_OK );
00069 }
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
void 
00091 CreateCRDControl(
00092     LPSTR       FileName,
00093     LPSTR       SaveFileName,
00094     DWORD       Inter_Intent,
00095     BOOL        AllowBinary)
00096 {
00097     
BOOL        Ret;
00098     
CHANDLE     cp;
00099     HGLOBAL     hCP;
00100     HGLOBAL     hBuffer;
00101     
MEMPTR      lpBuffer;
00102     OFSTRUCT    OfStruct;
00103     HFILE       hOutput;
00104     
DWORD       cbSize;
00105     
CSIG        Intent;
00106 
00107     
if( !
LoadCP32( (LPCSTR) 
FileName, &hCP, (
LPCHANDLE) &cp) )
00108     {
00109         
return;
00110     }
00111     
00112     
switch (Inter_Intent)
00113     {
00114         
case 0: 
Intent = 
icPerceptual; 
break;
00115         
case 1: 
Intent = 
icRelativeColorimetric; 
break;
00116         
case 2: 
Intent = 
icSaturation; 
break;
00117         
case 3: 
Intent = 
icAbsoluteColorimetric; 
break;
00118         
default: 
return;
00119     }
00120 
00121     Ret = 
GetPS2ColorRenderingDictionary(cp, 
Intent, 
NULL, &cbSize, 
AllowBinary);
00122     
if (Ret)
00123     {
00124         
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00125             
return;
00126         Ret = 
GetPS2ColorRenderingDictionary(cp, 
Intent, lpBuffer, &cbSize, 
AllowBinary);
00127         hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00128         cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00129         _lclose(hOutput);
00130         
MemFree(hBuffer);
00131     }
00132     
FreeCP(hCP);
00133 
00134     
if (!Ret)
00135          MessageBox( 
GetFocus(), 
"No CRD created.", 
NULL, MB_OK );
00136 }
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
void 
00158 CreateProfCRDControl(
00159     LPSTR       DevProfile,
00160     LPSTR       TargetProfile,
00161     LPSTR       SaveFileName,
00162     DWORD       Inter_Intent,
00163     BOOL        AllowBinary)
00164 {
00165     
BOOL        Ret;
00166     
CHANDLE     cpDev, cpTar;
00167     HGLOBAL     hDevCP = 0, hTarCP = 0;
00168     HGLOBAL     hBuffer;
00169     
MEMPTR      lpBuffer;
00170     OFSTRUCT    OfStruct;
00171     HFILE       hOutput;
00172     
DWORD       cbSize;
00173     
CSIG        Intent;
00174 
00175     
LoadCP32( (LPCSTR) DevProfile, &hDevCP, (
LPCHANDLE) &cpDev);
00176     
LoadCP32( (LPCSTR) 
TargetProfile, &hTarCP, (
LPCHANDLE) &cpTar);
00177 
00178     
if (!hDevCP || !hTarCP)
00179     {
00180         
if (hDevCP)  
FreeCP(hDevCP);
00181         
if (hTarCP)  
FreeCP(hTarCP);
00182         
return;
00183     }
00184     
00185     
switch (Inter_Intent)
00186     {
00187         
case 0: 
Intent = 
icPerceptual; 
break;
00188         
case 1: 
Intent = 
icRelativeColorimetric; 
break;
00189         
case 2: 
Intent = 
icSaturation; 
break;
00190         
case 3: 
Intent = 
icAbsoluteColorimetric; 
break;
00191         
default: 
return;
00192     }
00193 
00194     Ret = 
GetPS2PreviewColorRenderingDictionary(cpDev, cpTar, 
Intent, 
NULL, &cbSize, 
AllowBinary);
00195     
if (Ret)
00196     {
00197         
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00198             
return;
00199         Ret = 
GetPS2PreviewColorRenderingDictionary(cpDev, cpTar, 
Intent, lpBuffer, &cbSize, 
AllowBinary);
00200         hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00201         cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00202         _lclose(hOutput);
00203         
MemFree(hBuffer);
00204     }
00205     
FreeCP(hDevCP);
00206     
FreeCP(hTarCP);
00207 
00208     
if (!Ret)
00209          MessageBox( 
GetFocus(), 
"No CRD created.", 
NULL, MB_OK );
00210 }
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
void 
00232 ColorSpaceControl(
00233     LPSTR       FileName,
00234     LPSTR       SaveFileName,
00235     DWORD       InpDrvClrSp,
00236     DWORD       Intent,
00237     WORD        CSAType,
00238     BOOL        AllowBinary)
00239 {
00240     
BOOL        Ret;
00241     
CHANDLE     cp;
00242     HGLOBAL     hCP;
00243     HGLOBAL     hBuffer;
00244     
MEMPTR      lpBuffer;
00245     OFSTRUCT    OfStruct;
00246     HFILE       hOutput;
00247     
DWORD       cbSize;
00248 
00249     
if( !
LoadCP32( (LPCSTR) 
FileName, &hCP, (
LPCHANDLE) &cp) )
00250     {
00251         
return;
00252     }
00253     
switch (InpDrvClrSp)
00254     {
00255         
case 0: 
break;
00256         
case 1: InpDrvClrSp = 
icSigGrayData; 
break;
00257         
case 3: InpDrvClrSp = 
icSigRgbData; 
break;
00258         
case 4: InpDrvClrSp = 
icSigCmykData; 
break;
00259         
default: InpDrvClrSp = 0; 
break;
00260     }
00261 
00262     
00263     
if (CSAType == 405)
00264     {
00265         Ret = 
GetPS2ColorSpaceArray(cp, 
Intent, InpDrvClrSp, 
NULL, &cbSize, 
AllowBinary);
00266         
if (Ret)
00267         {
00268             
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00269                 
return;
00270             Ret = 
GetPS2ColorSpaceArray(cp, 
Intent, InpDrvClrSp, lpBuffer, &cbSize, 
AllowBinary);
00271 
00272             hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00273             cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00274             _lclose(hOutput);
00275 
00276             
MemFree(hBuffer);
00277         }
00278     }
00279     
00280     
else if (CSAType == 406)
00281     {
00282         Ret = 
GetPS2ColorSpaceArray(cp, 
Intent, 
icSigRgbData, 
NULL, &cbSize, 
AllowBinary);
00283         
if (Ret)
00284         {
00285             
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00286                 
return;
00287             Ret = 
GetPS2ColorSpaceArray(cp, 
Intent, 
icSigRgbData, lpBuffer, &cbSize, 
AllowBinary);
00288 
00289             hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00290             cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00291             _lclose(hOutput);
00292 
00293             
MemFree(hBuffer);
00294         }
00295     }
00296 
#if 0
00297 
    else if (CSAType == 406)
00298     {
00299         Ret = 
GetPS2CSA_ABC( cp, 
NULL, &cbSize, InpDrvClrSp, 
AllowBinary);
00300         
if (Ret)
00301         {
00302             
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00303                 
return;
00304             Ret = 
GetPS2CSA_ABC( cp, lpBuffer, &cbSize, InpDrvClrSp, 
AllowBinary);
00305 
00306             hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00307             cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00308             _lclose(hOutput);
00309 
00310             
MemFree(hBuffer);
00311         }
00312 
00313     }
00314     
else if ((CSAType == 407) &&
00315         (
GetCPDevSpace(cp, (
LPCSIG) &ColorSpace)))
00316     {
00317         
if (ColorSpace == 
icSigRgbData)
00318             Ret = 
GetPS2CSA_DEFG_Intent(cp, 
NULL, &cbSize, 
00319                     InpDrvClrSp, 
Intent, 
TYPE_CIEBASEDDEF, 
AllowBinary);
00320         
else if (ColorSpace == 
icSigCmykData)
00321             Ret = 
GetPS2CSA_DEFG_Intent(cp, 
NULL, &cbSize, 
00322                     InpDrvClrSp, 
Intent, 
TYPE_CIEBASEDDEFG, 
AllowBinary);
00323         
if (Ret)
00324         {
00325             
if (!
MemAlloc(cbSize, &hBuffer, &lpBuffer))
00326                 
return;
00327             
if (ColorSpace == 
icSigRgbData)
00328                 Ret = 
GetPS2CSA_DEFG_Intent(cp, lpBuffer, &cbSize, 
00329                     InpDrvClrSp, 
Intent, 
TYPE_CIEBASEDDEF, 
AllowBinary);
00330             
else if (ColorSpace == 
icSigCmykData)
00331                 Ret = 
GetPS2CSA_DEFG_Intent(cp, lpBuffer, &cbSize, 
00332                     InpDrvClrSp, 
Intent, 
TYPE_CIEBASEDDEFG, 
AllowBinary);
00333             hOutput = OpenFile(SaveFileName, &OfStruct, OF_CREATE);
00334             cbSize = _lwrite(hOutput, lpBuffer, cbSize);
00335             _lclose(hOutput);
00336 
00337             
MemFree(hBuffer);
00338         }
00339 
00340     }
00341 
#endif
00342 
    FreeCP(hCP);
00343     
if (!Ret)
00344          MessageBox( 
GetFocus(), 
"No CRD created.", 
NULL, MB_OK );
00345     
return;
00346 }