1998-10-24 12:44:05 +02:00
|
|
|
/*
|
|
|
|
* PostScript driver bitmap functions
|
|
|
|
*
|
|
|
|
* Copyright 1998 Huw D M Davies
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gdi.h"
|
|
|
|
#include "psdrv.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-03-23 14:46:04 +01:00
|
|
|
#include "bitmap.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(psdrv);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* PSDRV_WriteImageHeader
|
|
|
|
*
|
|
|
|
* Helper for PSDRV_StretchDIBits
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Uses level 2 PostScript
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL PSDRV_WriteImageHeader(DC *dc, const BITMAPINFO *info, INT xDst,
|
|
|
|
INT yDst, INT widthDst, INT heightDst,
|
|
|
|
INT widthSrc, INT heightSrc)
|
|
|
|
{
|
|
|
|
COLORREF map[256];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch(info->bmiHeader.biBitCount) {
|
|
|
|
case 8:
|
|
|
|
PSDRV_WriteIndexColorSpaceBegin(dc, 255);
|
|
|
|
for(i = 0; i < 256; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
|
|
|
PSDRV_WriteRGB(dc, map, 256);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(dc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
PSDRV_WriteIndexColorSpaceBegin(dc, 15);
|
|
|
|
for(i = 0; i < 16; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
|
|
|
PSDRV_WriteRGB(dc, map, 16);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(dc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
PSDRV_WriteIndexColorSpaceBegin(dc, 1);
|
|
|
|
for(i = 0; i < 2; i++) {
|
|
|
|
map[i] = info->bmiColors[i].rgbRed |
|
|
|
|
info->bmiColors[i].rgbGreen << 8 |
|
|
|
|
info->bmiColors[i].rgbBlue << 16;
|
|
|
|
}
|
|
|
|
PSDRV_WriteRGB(dc, map, 2);
|
|
|
|
PSDRV_WriteIndexColorSpaceEnd(dc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
{
|
|
|
|
PSCOLOR pscol;
|
|
|
|
pscol.type = PSCOLOR_RGB;
|
|
|
|
pscol.value.rgb.r = pscol.value.rgb.g = pscol.value.rgb.b = 0.0;
|
|
|
|
PSDRV_WriteSetColor(dc, &pscol);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Not implemented yet\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
PSDRV_WriteImageDict(dc, info->bmiHeader.biBitCount, xDst, yDst,
|
1999-07-10 12:21:03 +02:00
|
|
|
widthDst, heightDst, widthSrc, heightSrc, NULL);
|
1999-03-23 14:46:04 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
1998-10-24 12:44:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* PSDRV_StretchDIBits
|
1999-03-23 14:46:04 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
1999-12-25 23:56:13 +01:00
|
|
|
* Doesn't work correctly if xSrc isn't byte aligned - this affects 1 and 4
|
|
|
|
* bit depths.
|
1999-03-23 14:46:04 +01:00
|
|
|
* Compression not implemented.
|
1998-10-24 12:44:05 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT PSDRV_StretchDIBits( DC *dc, INT xDst, INT yDst, INT widthDst,
|
1999-03-23 14:46:04 +01:00
|
|
|
INT heightDst, INT xSrc, INT ySrc,
|
|
|
|
INT widthSrc, INT heightSrc, const void *bits,
|
|
|
|
const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
|
1998-10-24 12:44:05 +02:00
|
|
|
{
|
1999-03-23 14:46:04 +01:00
|
|
|
DWORD fullSrcWidth;
|
|
|
|
INT widthbytes, fullSrcHeight;
|
|
|
|
WORD bpp, compression;
|
|
|
|
const char *ptr;
|
|
|
|
INT line;
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("%08x (%d,%d %dx%d) -> (%d,%d %dx%d)\n", dc->hSelf,
|
1999-03-23 14:46:04 +01:00
|
|
|
xSrc, ySrc, widthSrc, heightSrc, xDst, yDst, widthDst, heightDst);
|
|
|
|
|
|
|
|
DIB_GetBitmapInfo((const BITMAPINFOHEADER *)info, &fullSrcWidth,
|
|
|
|
&fullSrcHeight, &bpp, &compression);
|
|
|
|
|
|
|
|
widthbytes = DIB_GetDIBWidthBytes(fullSrcWidth, bpp);
|
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("full size=%ldx%d bpp=%d compression=%d\n", fullSrcWidth,
|
1999-03-23 14:46:04 +01:00
|
|
|
fullSrcHeight, bpp, compression);
|
1998-10-24 12:44:05 +02:00
|
|
|
|
|
|
|
|
1999-03-23 14:46:04 +01:00
|
|
|
if(compression != BI_RGB) {
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Compression not supported\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-06-12 08:37:05 +02:00
|
|
|
xDst = XLPTODP(dc, xDst);
|
|
|
|
yDst = YLPTODP(dc, yDst);
|
|
|
|
widthDst = XLSTODS(dc, widthDst);
|
|
|
|
heightDst = YLSTODS(dc, heightDst);
|
1999-03-23 14:46:04 +01:00
|
|
|
|
|
|
|
switch(bpp) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
1999-12-25 23:56:13 +01:00
|
|
|
if(xSrc & 7)
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("This won't work...\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
1999-12-25 23:56:13 +01:00
|
|
|
PSDRV_WriteBytes(dc, ptr + xSrc/8, (widthSrc+7)/8);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
1999-12-25 23:56:13 +01:00
|
|
|
if(xSrc & 1)
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("This won't work...\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
1999-12-25 23:56:13 +01:00
|
|
|
PSDRV_WriteBytes(dc, ptr + xSrc/2, (widthSrc+1)/2);
|
1999-03-23 14:46:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
|
|
|
PSDRV_WriteBytes(dc, ptr + xSrc, widthSrc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
|
|
|
PSDRV_WriteDIBits16(dc, (WORD *)ptr + xSrc, widthSrc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
|
|
|
PSDRV_WriteDIBits24(dc, ptr + xSrc * 3, widthSrc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 32:
|
|
|
|
PSDRV_WriteGSave(dc);
|
|
|
|
PSDRV_WriteImageHeader(dc, info, xDst, yDst, widthDst, heightDst,
|
|
|
|
widthSrc, heightSrc);
|
|
|
|
|
|
|
|
ptr = bits;
|
|
|
|
ptr += (ySrc * widthbytes);
|
|
|
|
for(line = 0; line < heightSrc; line++, ptr += widthbytes)
|
|
|
|
PSDRV_WriteDIBits32(dc, ptr + xSrc * 3, widthSrc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1999-06-26 21:09:08 +02:00
|
|
|
FIXME("Unsupported depth\n");
|
1999-03-23 14:46:04 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
2000-06-11 22:00:05 +02:00
|
|
|
PSDRV_WriteSpool(dc, ">\n", 2); /* End-of-Data for /HexASCIIDecodeFilter */
|
1999-06-12 08:37:05 +02:00
|
|
|
PSDRV_WriteGRestore(dc);
|
1999-03-23 14:46:04 +01:00
|
|
|
return TRUE;
|
1998-10-24 12:44:05 +02:00
|
|
|
}
|
1999-03-23 14:46:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|