01960 {
01961
MEMPTR lpTargetCRD, lpTargetCSA, lpDevCRD;
01962
DWORD cbTargetCRD, cbTargetCSA, cbDevCRD;
01963 HGLOBAL hTargetCRD, hTargetCSA, hDevCRD;
01964
BOOL Success =
FALSE;
01965
float Input[
MAXCHANNELS];
01966
float Output[
MAXCHANNELS];
01967
float Temp[
MAXCHANNELS];
01968
int i, j, k, l;
01969
MEMPTR lpLineStart;
01970
MEMPTR lpOldMem;
01971
CSIG ColorSpace;
01972
CSIG DevColorSpace;
01973
static CSIG IntentTag;
01974
static SINT PreviewCRDGrid;
01975
SINT OutArraySize, InArraySize;
01976
char PublicArrayName[
TempBfSize];
01977
SINT TargetGrids, DevGrids;
01978
01979
01980
if (lpMem ==
NULL)
01981 {
01982
SINT dwOutArraySizr = 0;
01983
01984 i = 3;
01985
if ((
GetCPDevSpace (cpDev, (LPCSIG) & DevColorSpace)) &&
01986 (DevColorSpace ==
icSigCmykData))
01987 {
01988 i = 4;
01989 }
01990
01991
01992
if (!
GetCRDInputOutputArraySize(cpTarget, Intent,
01993 &InArraySize, NULL, &IntentTag, &TargetGrids ))
01994
return FALSE;
01995
01996
01997
if (!
GetCRDInputOutputArraySize(cpDev, Intent,
01998 NULL, &OutArraySize, &IntentTag, &DevGrids ))
01999
return FALSE;
02000
02001 PreviewCRDGrid = (TargetGrids > DevGrids)? TargetGrids: DevGrids;
02002
02003
02004
if (PreviewCRDGrid <
PREVIEWCRDGRID)
02005 PreviewCRDGrid =
PREVIEWCRDGRID;
02006 *lpcbSize = PreviewCRDGrid * PreviewCRDGrid * PreviewCRDGrid *
02007 i * 2 +
02008 OutArraySize +
02009 InArraySize +
02010 4096;
02011
return (
TRUE);
02012 }
02013
02014
02015 lpOldMem = lpMem;
02016
02017
02018
if (!(
GetHostColorRenderingDictionary (cpTarget, Intent, NULL, &cbTargetCRD)) ||
02019 !(
GetHostColorSpaceArray (cpTarget, Intent, NULL, &cbTargetCSA)) ||
02020 !(
GetHostColorRenderingDictionary (cpDev, Intent, NULL, &cbDevCRD)))
02021 {
02022
return (Success);
02023 }
02024
02025
02026 hTargetCRD = hTargetCSA = hDevCRD = 0;
02027
if (!
MemAlloc (cbTargetCRD, (HGLOBAL FAR *)&hTargetCRD, (LPMEMPTR)&lpTargetCRD) ||
02028 !
MemAlloc (cbTargetCSA, (HGLOBAL FAR *)&hTargetCSA, (LPMEMPTR)&lpTargetCSA) ||
02029 !
MemAlloc (cbDevCRD, (HGLOBAL FAR *)&hDevCRD, (LPMEMPTR)&lpDevCRD))
02030 {
02031
goto Done;
02032 }
02033
02034
02035
if (!(
GetHostColorRenderingDictionary (cpTarget, Intent, lpTargetCRD, &cbTargetCRD)) ||
02036 !(
GetHostColorSpaceArray (cpTarget, Intent, lpTargetCSA, &cbTargetCSA)) ||
02037 !(
GetHostColorRenderingDictionary (cpDev, Intent, lpDevCRD, &cbDevCRD)))
02038 {
02039
goto Done;
02040 }
02041
02042
02043
02044
02045
02046
02047
02048
GetPublicArrayName (cpDev, IntentTag, PublicArrayName);
02049 lpMem +=
WriteNewLineObject (lpMem, CRDBegin);
02050
02051 lpMem +=
EnableGlobalDict(lpMem);
02052 lpMem +=
BeginGlobalDict(lpMem);
02053
02054 lpMem +=
CreateInputArray (lpMem, (SINT)0, (SINT)0, (MEMPTR)PublicArrayName,
02055 (CSIG)0, NULL, bAllowBinary, lpTargetCRD);
02056
02057 lpMem +=
CreateOutputArray (lpMem, (SINT)0, (SINT)0, (SINT)0,
02058 (MEMPTR)PublicArrayName, (CSIG)0, NULL, bAllowBinary, lpDevCRD);
02059
02060 lpMem +=
EndGlobalDict(lpMem);
02061
02062
02063 lpMem +=
WriteNewLineObject (lpMem, BeginDict);
02064 lpMem +=
WriteObject (lpMem, DictType);
02065
02066 lpMem +=
WriteNewLineObject (lpMem, IntentType);
02067
switch (
Intent)
02068 {
02069
case icPerceptual:
02070 lpMem +=
WriteObject (lpMem, IntentPer);
02071
break;
02072
02073
case icSaturation:
02074 lpMem +=
WriteObject (lpMem, IntentSat);
02075
break;
02076
02077
case icRelativeColorimetric:
02078 lpMem +=
WriteObject (lpMem, IntentRCol);
02079
break;
02080
02081
case icAbsoluteColorimetric:
02082 lpMem +=
WriteObject (lpMem, IntentACol);
02083
break;
02084 }
02085
02086
02087 lpMem +=
SendCRDBWPoint(lpMem,
02088 ((LPHOSTCLUT)lpTargetCRD)->whitePoint);
02089
02090
02091 lpMem +=
SendCRDPQR(lpMem, Intent,
02092 ((LPHOSTCLUT)lpTargetCRD)->whitePoint);
02093
02094
02095 lpMem +=
SendCRDLMN(lpMem, Intent,
02096 ((LPHOSTCLUT)lpTargetCRD)->whitePoint,
02097 ((LPHOSTCLUT)lpTargetCRD)->mediaWP,
02098 ((LPHOSTCLUT)lpTargetCRD)->pcs);
02099
02100
02101 lpMem +=
SendCRDABC(lpMem, PublicArrayName,
02102 ((LPHOSTCLUT)lpTargetCRD)->pcs,
02103 ((LPHOSTCLUT)lpTargetCRD)->inputChan,
02104 NULL,
02105 ((LPHOSTCLUT)lpTargetCRD)->e,
02106 (((LPHOSTCLUT)lpTargetCRD)->lutBits == 8)? icSigLut8Type:icSigLut16Type,
02107 bAllowBinary);
02108
02109
02110 lpMem +=
WriteNewLineObject (lpMem, RenderTableTag);
02111 lpMem +=
WriteObject (lpMem, BeginArray);
02112
02113 lpMem +=
WriteInt (lpMem, PreviewCRDGrid);
02114 lpMem +=
WriteInt (lpMem, PreviewCRDGrid);
02115 lpMem +=
WriteInt (lpMem, PreviewCRDGrid);
02116
02117 lpLineStart = lpMem;
02118 lpMem +=
WriteNewLineObject (lpMem, BeginArray);
02119 ColorSpace = ((
LPHOSTCLUT)lpDevCRD)->pcs;
02120
for (i = 0; i < PreviewCRDGrid; i++)
02121 {
02122 lpMem +=
WriteObject (lpMem, NewLine);
02123 lpLineStart = lpMem;
02124
if (bAllowBinary)
02125 {
02126 lpMem +=
WriteStringToken (lpMem, 143,
02127 PreviewCRDGrid * PreviewCRDGrid * ((LPHOSTCLUT)lpDevCRD)->outputChan);
02128 }
02129
else
02130 {
02131 lpMem +=
WriteObject (lpMem, BeginString);
02132 }
02133 Input[0] = ((
float)i) / (PreviewCRDGrid - 1);
02134
for (j = 0; j < PreviewCRDGrid; j++)
02135 {
02136 Input[1] = ((
float)j) / (PreviewCRDGrid - 1);
02137
for (k = 0; k < PreviewCRDGrid; k++)
02138 {
02139 Input[2] = ((
float)k) / (PreviewCRDGrid - 1);
02140
02141
DoHostConversionCRD ((LPHOSTCLUT)lpTargetCRD, NULL, Input, Output, ColorSpace, 1);
02142
DoHostConversionCSA ((LPHOSTCLUT)lpTargetCSA, Output, Temp);
02143
DoHostConversionCRD ((LPHOSTCLUT)lpDevCRD, (LPHOSTCLUT)lpTargetCSA,
02144 Temp, Output, 0, 0);
02145
for (l = 0; l < ((
LPHOSTCLUT)lpDevCRD)->outputChan; l++)
02146 {
02147
if (bAllowBinary)
02148 {
02149 *lpMem++ = (
BYTES)(Output[l]*255);
02150 }
02151
else
02152 {
02153 lpMem +=
WriteHex (lpMem, (USHORT)(Output[l]*255));
02154
if (((
SINT) (lpMem - lpLineStart)) >
MAX_LINELENG)
02155 {
02156 lpLineStart = lpMem;
02157 lpMem +=
WriteObject (lpMem, NewLine);
02158 }
02159 }
02160 }
02161 }
02162 }
02163
if (!bAllowBinary)
02164 lpMem +=
WriteObject (lpMem, EndString);
02165 }
02166 lpMem +=
WriteNewLineObject (lpMem, EndArray);
02167 lpMem +=
WriteInt (lpMem, ((LPHOSTCLUT)lpDevCRD)->outputChan);
02168
02169
02170 lpMem +=
SendCRDOutputTable(lpMem, PublicArrayName,
02171 ((LPHOSTCLUT)lpDevCRD)->outputChan,
02172 (((LPHOSTCLUT)lpDevCRD)->lutBits == 8)? icSigLut8Type:icSigLut16Type,
02173 TRUE,
02174 bAllowBinary);
02175
02176
02177 lpMem +=
WriteNewLineObject (lpMem, EndArray);
02178 lpMem +=
WriteObject (lpMem, EndDict);
02179 lpMem +=
WriteNewLineObject (lpMem, CRDEnd);
02180 Success =
TRUE;
02181
02182 Done:
02183 *lpcbSize = (
DWORD)(lpMem - lpOldMem);
02184
02185
if (hTargetCRD)
02186
MemFree(hTargetCRD);
02187
if (hTargetCSA)
02188
MemFree(hTargetCSA);
02189
if (hDevCRD)
02190
MemFree(hDevCRD);
02191
return (Success);
02192 }