2 * PostScript driver bitmap functions
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
29 /***************************************************************************
30 * PSDRV_WriteImageHeader
32 * Helper for PSDRV_StretchDIBits
35 * Uses level 2 PostScript
38 static BOOL
PSDRV_WriteImageHeader(DC
*dc
, const BITMAPINFO
*info
, INT xDst
,
39 INT yDst
, INT widthDst
, INT heightDst
,
40 INT widthSrc
, INT heightSrc
)
45 switch(info
->bmiHeader
.biBitCount
) {
47 PSDRV_WriteIndexColorSpaceBegin(dc
, 255);
48 for(i
= 0; i
< 256; i
++) {
49 map
[i
] = info
->bmiColors
[i
].rgbRed
|
50 info
->bmiColors
[i
].rgbGreen
<< 8 |
51 info
->bmiColors
[i
].rgbBlue
<< 16;
53 PSDRV_WriteRGB(dc
, map
, 256);
54 PSDRV_WriteIndexColorSpaceEnd(dc
);
58 PSDRV_WriteIndexColorSpaceBegin(dc
, 15);
59 for(i
= 0; i
< 16; i
++) {
60 map
[i
] = info
->bmiColors
[i
].rgbRed
|
61 info
->bmiColors
[i
].rgbGreen
<< 8 |
62 info
->bmiColors
[i
].rgbBlue
<< 16;
64 PSDRV_WriteRGB(dc
, map
, 16);
65 PSDRV_WriteIndexColorSpaceEnd(dc
);
69 PSDRV_WriteIndexColorSpaceBegin(dc
, 1);
70 for(i
= 0; i
< 2; i
++) {
71 map
[i
] = info
->bmiColors
[i
].rgbRed
|
72 info
->bmiColors
[i
].rgbGreen
<< 8 |
73 info
->bmiColors
[i
].rgbBlue
<< 16;
75 PSDRV_WriteRGB(dc
, map
, 2);
76 PSDRV_WriteIndexColorSpaceEnd(dc
);
85 pscol
.type
= PSCOLOR_RGB
;
86 pscol
.value
.rgb
.r
= pscol
.value
.rgb
.g
= pscol
.value
.rgb
.b
= 0.0;
87 PSDRV_WriteSetColor(dc
, &pscol
);
92 FIXME("Not implemented yet\n");
97 PSDRV_WriteImageDict(dc
, info
->bmiHeader
.biBitCount
, xDst
, yDst
,
98 widthDst
, heightDst
, widthSrc
, heightSrc
, NULL
);
103 /***************************************************************************
105 * PSDRV_StretchDIBits
108 * Doesn't work correctly if xSrc isn't byte aligned - this affects 1 and 4
110 * Compression not implemented.
112 INT
PSDRV_StretchDIBits( DC
*dc
, INT xDst
, INT yDst
, INT widthDst
,
113 INT heightDst
, INT xSrc
, INT ySrc
,
114 INT widthSrc
, INT heightSrc
, const void *bits
,
115 const BITMAPINFO
*info
, UINT wUsage
, DWORD dwRop
)
118 INT widthbytes
, fullSrcHeight
;
119 WORD bpp
, compression
;
123 TRACE("%08x (%d,%d %dx%d) -> (%d,%d %dx%d)\n", dc
->hSelf
,
124 xSrc
, ySrc
, widthSrc
, heightSrc
, xDst
, yDst
, widthDst
, heightDst
);
126 DIB_GetBitmapInfo((const BITMAPINFOHEADER
*)info
, &fullSrcWidth
,
127 &fullSrcHeight
, &bpp
, &compression
);
129 widthbytes
= DIB_GetDIBWidthBytes(fullSrcWidth
, bpp
);
131 TRACE("full size=%ldx%d bpp=%d compression=%d\n", fullSrcWidth
,
132 fullSrcHeight
, bpp
, compression
);
135 if(compression
!= BI_RGB
) {
136 FIXME("Compression not supported\n");
140 xDst
= XLPTODP(dc
, xDst
);
141 yDst
= YLPTODP(dc
, yDst
);
142 widthDst
= XLSTODS(dc
, widthDst
);
143 heightDst
= YLSTODS(dc
, heightDst
);
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
/8, (widthSrc
+7)/8);
160 PSDRV_WriteGSave(dc
);
161 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
162 widthSrc
, heightSrc
);
164 ptr
+= (ySrc
* widthbytes
);
166 FIXME("This won't work...\n");
167 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
168 PSDRV_WriteBytes(dc
, ptr
+ xSrc
/2, (widthSrc
+1)/2);
172 PSDRV_WriteGSave(dc
);
173 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
174 widthSrc
, heightSrc
);
176 ptr
+= (ySrc
* widthbytes
);
177 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
178 PSDRV_WriteBytes(dc
, ptr
+ xSrc
, widthSrc
);
183 PSDRV_WriteGSave(dc
);
184 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
185 widthSrc
, heightSrc
);
188 ptr
+= (ySrc
* widthbytes
);
189 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
190 PSDRV_WriteDIBits16(dc
, (WORD
*)ptr
+ xSrc
, widthSrc
);
194 PSDRV_WriteGSave(dc
);
195 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
196 widthSrc
, heightSrc
);
199 ptr
+= (ySrc
* widthbytes
);
200 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
201 PSDRV_WriteDIBits24(dc
, ptr
+ xSrc
* 3, widthSrc
);
205 PSDRV_WriteGSave(dc
);
206 PSDRV_WriteImageHeader(dc
, info
, xDst
, yDst
, widthDst
, heightDst
,
207 widthSrc
, heightSrc
);
210 ptr
+= (ySrc
* widthbytes
);
211 for(line
= 0; line
< heightSrc
; line
++, ptr
+= widthbytes
)
212 PSDRV_WriteDIBits32(dc
, ptr
+ xSrc
* 3, widthSrc
);
216 FIXME("Unsupported depth\n");
220 PSDRV_WriteSpool(dc
, ">\n", 2); /* End-of-Data for /HexASCIIDecodeFilter */
221 PSDRV_WriteGRestore(dc
);