2 * PostScript driver bitmap functions
4 * Copyright 1998 Huw D M Davies
9 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(psdrv);
16 /***************************************************************************
17 * PSDRV_WriteImageHeader
19 * Helper for PSDRV_StretchDIBits
22 * Uses level 2 PostScript
25 static BOOL PSDRV_WriteImageHeader(DC *dc, const BITMAPINFO *info, INT xDst,
26 INT yDst, INT widthDst, INT heightDst,
27 INT widthSrc, INT heightSrc)
32 switch(info->bmiHeader.biBitCount) {
34 PSDRV_WriteIndexColorSpaceBegin(dc, 255);
35 for(i = 0; i < 256; i++) {
36 map[i] = info->bmiColors[i].rgbRed |
37 info->bmiColors[i].rgbGreen << 8 |
38 info->bmiColors[i].rgbBlue << 16;
40 PSDRV_WriteRGB(dc, map, 256);
41 PSDRV_WriteIndexColorSpaceEnd(dc);
45 PSDRV_WriteIndexColorSpaceBegin(dc, 15);
46 for(i = 0; i < 16; i++) {
47 map[i] = info->bmiColors[i].rgbRed |
48 info->bmiColors[i].rgbGreen << 8 |
49 info->bmiColors[i].rgbBlue << 16;
51 PSDRV_WriteRGB(dc, map, 16);
52 PSDRV_WriteIndexColorSpaceEnd(dc);
56 PSDRV_WriteIndexColorSpaceBegin(dc, 1);
57 for(i = 0; i < 2; i++) {
58 map[i] = info->bmiColors[i].rgbRed |
59 info->bmiColors[i].rgbGreen << 8 |
60 info->bmiColors[i].rgbBlue << 16;
62 PSDRV_WriteRGB(dc, map, 2);
63 PSDRV_WriteIndexColorSpaceEnd(dc);
72 pscol.type = PSCOLOR_RGB;
73 pscol.value.rgb.r = pscol.value.rgb.g = pscol.value.rgb.b = 0.0;
74 PSDRV_WriteSetColor(dc, &pscol);
79 FIXME("Not implemented yet\n");
84 PSDRV_WriteImageDict(dc, info->bmiHeader.biBitCount, xDst, yDst,
85 widthDst, heightDst, widthSrc, heightSrc, NULL);
90 /***************************************************************************
95 * Doesn't work correctly if xSrc isn't byte aligned - this affects 1 and 4
97 * Compression not implemented.
99 INT PSDRV_StretchDIBits( DC *dc, INT xDst, INT yDst, INT widthDst,
100 INT heightDst, INT xSrc, INT ySrc,
101 INT widthSrc, INT heightSrc, const void *bits,
102 const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
105 INT widthbytes, fullSrcHeight;
106 WORD bpp, compression;
110 TRACE("%08x (%d,%d %dx%d) -> (%d,%d %dx%d)\n", dc->hSelf,
111 xSrc, ySrc, widthSrc, heightSrc, xDst, yDst, widthDst, heightDst);
113 DIB_GetBitmapInfo((const BITMAPINFOHEADER *)info, &fullSrcWidth,
114 &fullSrcHeight, &bpp, &compression);
116 widthbytes = DIB_GetDIBWidthBytes(fullSrcWidth, bpp);
118 TRACE("full size=%ldx%d bpp=%d compression=%d\n", fullSrcWidth,
119 fullSrcHeight, bpp, compression);
122 if(compression != BI_RGB) {
123 FIXME("Compression not supported\n");
127 xDst = XLPTODP(dc, xDst);
128 yDst = YLPTODP(dc, yDst);
129 widthDst = XLSTODS(dc, widthDst);
130 heightDst = YLSTODS(dc, heightDst);
135 PSDRV_WriteGSave(dc);
136 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
137 widthSrc, heightSrc);
139 ptr += (ySrc * widthbytes);
141 FIXME("This won't work...\n");
142 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
143 PSDRV_WriteBytes(dc, ptr + xSrc/8, (widthSrc+7)/8);
147 PSDRV_WriteGSave(dc);
148 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
149 widthSrc, heightSrc);
151 ptr += (ySrc * widthbytes);
153 FIXME("This won't work...\n");
154 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
155 PSDRV_WriteBytes(dc, ptr + xSrc/2, (widthSrc+1)/2);
159 PSDRV_WriteGSave(dc);
160 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
161 widthSrc, heightSrc);
163 ptr += (ySrc * widthbytes);
164 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
165 PSDRV_WriteBytes(dc, ptr + xSrc, widthSrc);
170 PSDRV_WriteGSave(dc);
171 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
172 widthSrc, heightSrc);
175 ptr += (ySrc * widthbytes);
176 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
177 PSDRV_WriteDIBits16(dc, (WORD *)ptr + xSrc, widthSrc);
181 PSDRV_WriteGSave(dc);
182 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
183 widthSrc, heightSrc);
186 ptr += (ySrc * widthbytes);
187 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
188 PSDRV_WriteDIBits24(dc, ptr + xSrc * 3, widthSrc);
192 PSDRV_WriteGSave(dc);
193 PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
194 widthSrc, heightSrc);
197 ptr += (ySrc * widthbytes);
198 for(line = 0; line < heightSrc; line++, ptr += widthbytes)
199 PSDRV_WriteDIBits32(dc, ptr + xSrc * 3, widthSrc);
203 FIXME("Unsupported depth\n");
207 PSDRV_WriteSpool(dc, ">\n", 2); /* End-of-Data for /HexASCIIDecodeFilter */
208 PSDRV_WriteGRestore(dc);