2 * PostScript driver bitmap functions
4 * Copyright 1998 Huw D M Davies
10 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(psdrv
)
17 /***************************************************************************
18 * PSDRV_WriteImageHeader
20 * Helper for PSDRV_StretchDIBits
23 * Uses level 2 PostScript
26 static BOOL
PSDRV_WriteImageHeader(DC
*dc
, const BITMAPINFO
*info
, INT xDst
,
27 INT yDst
, INT widthDst
, INT heightDst
,
28 INT widthSrc
, INT heightSrc
)
33 switch(info
->bmiHeader
.biBitCount
) {
35 PSDRV_WriteIndexColorSpaceBegin(dc
, 255);
36 for(i
= 0; i
< 256; i
++) {
37 map
[i
] = info
->bmiColors
[i
].rgbRed
|
38 info
->bmiColors
[i
].rgbGreen
<< 8 |
39 info
->bmiColors
[i
].rgbBlue
<< 16;
41 PSDRV_WriteRGB(dc
, map
, 256);
42 PSDRV_WriteIndexColorSpaceEnd(dc
);
46 PSDRV_WriteIndexColorSpaceBegin(dc
, 15);
47 for(i
= 0; i
< 16; i
++) {
48 map
[i
] = info
->bmiColors
[i
].rgbRed
|
49 info
->bmiColors
[i
].rgbGreen
<< 8 |
50 info
->bmiColors
[i
].rgbBlue
<< 16;
52 PSDRV_WriteRGB(dc
, map
, 16);
53 PSDRV_WriteIndexColorSpaceEnd(dc
);
57 PSDRV_WriteIndexColorSpaceBegin(dc
, 1);
58 for(i
= 0; i
< 2; i
++) {
59 map
[i
] = info
->bmiColors
[i
].rgbRed
|
60 info
->bmiColors
[i
].rgbGreen
<< 8 |
61 info
->bmiColors
[i
].rgbBlue
<< 16;
63 PSDRV_WriteRGB(dc
, map
, 2);
64 PSDRV_WriteIndexColorSpaceEnd(dc
);
73 pscol
.type
= PSCOLOR_RGB
;
74 pscol
.value
.rgb
.r
= pscol
.value
.rgb
.g
= pscol
.value
.rgb
.b
= 0.0;
75 PSDRV_WriteSetColor(dc
, &pscol
);
80 FIXME("Not implemented yet\n");
85 PSDRV_WriteImageDict(dc
, info
->bmiHeader
.biBitCount
, xDst
, yDst
,
86 widthDst
, heightDst
, widthSrc
, heightSrc
, NULL
);
91 /***************************************************************************
96 * Doesn't work correctly if xSrc isn't byte aligned - this affects 1 and 4
98 * Compression not implemented.
100 INT
PSDRV_StretchDIBits( DC
*dc
, INT xDst
, INT yDst
, INT widthDst
,
101 INT heightDst
, INT xSrc
, INT ySrc
,
102 INT widthSrc
, INT heightSrc
, const void *bits
,
103 const BITMAPINFO
*info
, UINT wUsage
, DWORD dwRop
)
106 INT widthbytes
, fullSrcHeight
;
107 WORD bpp
, compression
;
111 TRACE("%08x (%d,%d %dx%d) -> (%d,%d %dx%d)\n", dc
->hSelf
,
112 xSrc
, ySrc
, widthSrc
, heightSrc
, xDst
, yDst
, widthDst
, heightDst
);
114 DIB_GetBitmapInfo((const BITMAPINFOHEADER
*)info
, &fullSrcWidth
,
115 &fullSrcHeight
, &bpp
, &compression
);
117 widthbytes
= DIB_GetDIBWidthBytes(fullSrcWidth
, bpp
);
119 TRACE("full size=%ldx%d bpp=%d compression=%d\n", fullSrcWidth
,
120 fullSrcHeight
, bpp
, compression
);
123 if(compression
!= BI_RGB
) {
124 FIXME("Compression not supported\n");
128 xDst
= XLPTODP(dc
, xDst
);
129 yDst
= YLPTODP(dc
, yDst
);
130 widthDst
= XLSTODS(dc
, widthDst
);
131 heightDst
= YLSTODS(dc
, heightDst
);
136 PSDRV_WriteGSave(dc
);
137 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
138 widthSrc
, heightSrc
);
140 ptr
+= (ySrc
* widthbytes
);
142 FIXME("This won't work...\n");
143 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
144 PSDRV_WriteBytes(dc
, ptr
+ xSrc
/8, (widthSrc
+7)/8);
148 PSDRV_WriteGSave(dc
);
149 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
150 widthSrc
, heightSrc
);
152 ptr
+= (ySrc
* widthbytes
);
154 FIXME("This won't work...\n");
155 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
156 PSDRV_WriteBytes(dc
, ptr
+ xSrc
/2, (widthSrc
+1)/2);
160 PSDRV_WriteGSave(dc
);
161 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
162 widthSrc
, heightSrc
);
164 ptr
+= (ySrc
* widthbytes
);
165 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
166 PSDRV_WriteBytes(dc
, ptr
+ xSrc
, widthSrc
);
171 PSDRV_WriteGSave(dc
);
172 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
173 widthSrc
, heightSrc
);
176 ptr
+= (ySrc
* widthbytes
);
177 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
178 PSDRV_WriteDIBits16(dc
, (WORD
*)ptr
+ xSrc
, widthSrc
);
182 PSDRV_WriteGSave(dc
);
183 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
184 widthSrc
, heightSrc
);
187 ptr
+= (ySrc
* widthbytes
);
188 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
189 PSDRV_WriteDIBits24(dc
, ptr
+ xSrc
* 3, widthSrc
);
193 PSDRV_WriteGSave(dc
);
194 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
195 widthSrc
, heightSrc
);
198 ptr
+= (ySrc
* widthbytes
);
199 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
200 PSDRV_WriteDIBits32(dc
, ptr
+ xSrc
* 3, widthSrc
);
204 FIXME("Unsupported depth\n");
208 PSDRV_WriteSpool(dc
, ">\n", 2); /* End-of-Data for /HexASCIIDecodeFilter */
209 PSDRV_WriteGRestore(dc
);