Added patterned brushes (level 2 PostScript only).

Simple PatBlt for PATCOPY, WHITENESS and BLACKNESS.
This commit is contained in:
Huw D M Davies 1999-07-10 10:21:03 +00:00 committed by Alexandre Julliard
parent e5ea09c17f
commit e28224f0ea
7 changed files with 129 additions and 7 deletions

View File

@ -7,6 +7,7 @@ MODULE = psdrv
C_SRCS = \
afm.c \
bitblt.c \
bitmap.c \
brush.c \
color.c \

51
graphics/psdrv/bitblt.c Normal file
View File

@ -0,0 +1,51 @@
/*
* PostScript driver BitBlt, StretchBlt and PatBlt
*
* Copyright 1999 Huw D M Davies
*
*/
#include "gdi.h"
#include "psdrv.h"
#include "debugtools.h"
#include "winbase.h"
DEFAULT_DEBUG_CHANNEL(psdrv)
/***********************************************************************
*
* PSDRV_PatBlt
*/
BOOL PSDRV_PatBlt(DC *dc, INT x, INT y, INT width, INT height, DWORD dwRop)
{
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
switch(dwRop) {
case PATCOPY:
PSDRV_WriteGSave(dc);
PSDRV_WriteRectangle(dc, XLPTODP(dc, x), YLPTODP(dc, y),
XLSTODS(dc, width), YLSTODS(dc, height));
PSDRV_Brush(dc, FALSE);
PSDRV_WriteGRestore(dc);
return TRUE;
case BLACKNESS:
case WHITENESS:
{
PSCOLOR pscol;
PSDRV_WriteGSave(dc);
PSDRV_WriteRectangle(dc, XLPTODP(dc, x), YLPTODP(dc, y),
XLSTODS(dc, width), YLSTODS(dc, height));
PSDRV_CreateColor( physDev, &pscol, (dwRop == BLACKNESS) ?
RGB(0,0,0) : RGB(0xff,0xff,0xff) );
PSDRV_WriteSetColor(dc, &pscol);
PSDRV_WriteFill(dc);
PSDRV_WriteGRestore(dc);
return TRUE;
}
default:
FIXME("Unsupported rop %ld\n", dwRop);
return FALSE;
}
}

View File

@ -83,7 +83,7 @@ static BOOL PSDRV_WriteImageHeader(DC *dc, const BITMAPINFO *info, INT xDst,
}
PSDRV_WriteImageDict(dc, info->bmiHeader.biBitCount, xDst, yDst,
widthDst, heightDst, widthSrc, heightSrc);
widthDst, heightDst, widthSrc, heightSrc, NULL);
return TRUE;
}

View File

@ -9,6 +9,7 @@
#include "brush.h"
#include "debugtools.h"
#include "gdi.h"
#include "winbase.h"
DEFAULT_DEBUG_CHANNEL(psdrv)
@ -192,6 +193,28 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
return TRUE;
break;
case BS_PATTERN:
{
BITMAP bm;
BYTE *bits;
GetObjectA(brush->logbrush.lbHatch, sizeof(BITMAP), &bm);
TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
bm.bmBitsPixel);
bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
GetBitmapBits(brush->logbrush.lbHatch,
bm.bmWidthBytes * bm.bmHeight, bits);
PSDRV_WriteGSave(dc);
PSDRV_WritePatternDict(dc, &bm, bits);
HeapFree(PSDRV_Heap, 0, bits);
PSDRV_Fill(dc, EO);
PSDRV_WriteGRestore(dc);
return TRUE;
}
break;
default:
return FALSE;
break;

View File

@ -58,7 +58,7 @@ static const DC_FUNCTIONS PSDRV_Funcs =
NULL, /* pOffsetViewportOrg (optional) */
NULL, /* pOffsetWindowOrg (optional) */
NULL, /* pPaintRgn */
NULL, /* pPatBlt */
PSDRV_PatBlt, /* pPatBlt */
PSDRV_Pie, /* pPie */
PSDRV_PolyPolygon, /* pPolyPolygon */
PSDRV_PolyPolyline, /* pPolyPolyline */

View File

@ -741,7 +741,7 @@ BOOL PSDRV_WriteRGB(DC *dc, COLORREF *map, int number)
BOOL PSDRV_WriteImageDict(DC *dc, WORD depth, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT widthSrc,
INT heightSrc)
INT heightSrc, char *bits)
{
char start[] = "%d %d translate\n%d %d scale\n<<\n"
" /ImageType 1\n /Width %d\n /Height %d\n /BitsPerComponent %d\n"
@ -751,6 +751,7 @@ BOOL PSDRV_WriteImageDict(DC *dc, WORD depth, INT xDst, INT yDst,
char decode3[] = " /Decode [0 1 0 1 0 1]\n";
char end[] = " /DataSource currentfile /ASCIIHexDecode filter\n>> image\n";
char endbits[] = " /DataSource <%s>\n>> image\n";
char *buf = HeapAlloc(PSDRV_Heap, 0, 1000);
@ -779,12 +780,18 @@ BOOL PSDRV_WriteImageDict(DC *dc, WORD depth, INT xDst, INT yDst,
PSDRV_WriteSpool(dc, buf, strlen(buf));
if(!bits)
PSDRV_WriteSpool(dc, end, sizeof(end) - 1);
else {
sprintf(buf, endbits, bits);
PSDRV_WriteSpool(dc, buf, strlen(buf));
}
HeapFree(PSDRV_Heap, 0, buf);
return TRUE;
}
BOOL PSDRV_WriteBytes(DC *dc, const BYTE *bytes, int number)
{
char *buf = HeapAlloc(PSDRV_Heap, 0, number * 3 + 1);
@ -872,3 +879,42 @@ BOOL PSDRV_WriteDIBits32(DC *dc, const BYTE *bits, int number)
HeapFree(PSDRV_Heap, 0, buf);
return TRUE;
}
BOOL PSDRV_WritePatternDict(DC *dc, BITMAP *bm, BYTE *bits)
{
char start[] = "<<\n /PaintType 1\n /PatternType 1\n /TilingType 1\n "
"/BBox [0 0 %d %d]\n /XStep %d\n /YStep %d\n /PaintProc {\n begin\n";
char end[] = " end\n }\n>>\n matrix makepattern setpattern\n";
char *buf, *ptr;
INT w, h, x, y;
COLORREF map[2];
w = bm->bmWidth & ~0x7;
h = bm->bmHeight & ~0x7;
buf = HeapAlloc(PSDRV_Heap, 0, sizeof(start) + 100);
sprintf(buf, start, w, h, w, h);
PSDRV_WriteSpool(dc, buf, strlen(buf));
PSDRV_WriteIndexColorSpaceBegin(dc, 1);
map[0] = dc->w.textColor;
map[1] = dc->w.backgroundColor;
PSDRV_WriteRGB(dc, map, 2);
PSDRV_WriteIndexColorSpaceEnd(dc);
ptr = buf;
for(y = h-1; y >= 0; y--) {
for(x = 0; x < w/8; x++) {
sprintf(ptr, "%02x", *(bits + x/8 + y * bm->bmWidthBytes));
ptr += 2;
}
}
PSDRV_WriteImageDict(dc, 1, 0, 0, 8, 8, 8, 8, buf);
PSDRV_WriteSpool(dc, end, sizeof(end) - 1);
HeapFree(PSDRV_Heap, 0, buf);
return TRUE;
}

View File

@ -296,14 +296,13 @@ extern BOOL PSDRV_WriteIndexColorSpaceEnd(DC *dc);
extern BOOL PSDRV_WriteRGB(DC *dc, COLORREF *map, int number);
extern BOOL PSDRV_WriteImageDict(DC *dc, WORD depth, INT xDst, INT yDst,
INT widthDst, INT heightDst, INT widthSrc,
INT heightSrc);
INT heightSrc, char *bits);
extern BOOL PSDRV_WriteBytes(DC *dc, const BYTE *bytes, int number);
extern BOOL PSDRV_WriteDIBits16(DC *dc, const WORD *words, int number);
extern BOOL PSDRV_WriteDIBits24(DC *dc, const BYTE *bits, int number);
extern BOOL PSDRV_WriteDIBits32(DC *dc, const BYTE *bits, int number);
extern int PSDRV_WriteSpool(DC *dc, LPSTR lpData, WORD cch);
extern BOOL PSDRV_WritePatternDict(DC *dc, BITMAP *bm, BYTE *bits);
extern BOOL PSDRV_Arc( DC *dc, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart,
@ -327,6 +326,8 @@ extern BOOL PSDRV_GetTextExtentPoint( DC *dc, LPCSTR str, INT count,
extern BOOL PSDRV_GetTextMetrics( DC *dc, TEXTMETRICA *metrics );
extern BOOL PSDRV_LineTo( DC *dc, INT x, INT y );
extern BOOL PSDRV_MoveToEx( DC *dc, INT x, INT y, LPPOINT pt );
extern BOOL PSDRV_PatBlt( DC *dc, INT x, INT y, INT width, INT height, DWORD
dwRop);
extern BOOL PSDRV_Pie( DC *dc, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart,
INT xend, INT yend );