Commit 0a189ffa authored by Alexandre Julliard's avatar Alexandre Julliard

wineps: Use the brush information passed in SelectBrush for pattern brushes.

parent 5243d44b
......@@ -55,6 +55,9 @@ HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
case BS_PATTERN:
case BS_DIBPATTERN:
physDev->brush.info = info;
physDev->brush.bits = bits;
physDev->brush.usage = usage;
break;
default:
......@@ -232,43 +235,16 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
break;
case BS_PATTERN:
{
BITMAP bm;
BYTE *bits;
GetObjectA( (HBITMAP)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( (HBITMAP)logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dev);
PSDRV_WritePatternDict(dev, &bm, bits);
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
} else {
FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE;
}
HeapFree(PSDRV_Heap, 0, bits);
}
break;
case BS_DIBPATTERN:
{
BITMAPINFO *bmi = (BITMAPINFO *)logbrush.lbHatch;
UINT usage = logbrush.lbColor;
TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth,
bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount);
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dev);
ret = PSDRV_WriteDIBPatternDict(dev, bmi, usage);
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
} else {
FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE;
}
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dev);
ret = PSDRV_WriteDIBPatternDict(dev, physDev->brush.info,
physDev->brush.bits, physDev->brush.usage );
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
} else {
FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE;
}
break;
......
......@@ -843,74 +843,25 @@ BOOL PSDRV_WriteRectClip2(PHYSDEV dev, CHAR *pszArrayName)
return PSDRV_WriteSpool(dev, buf, strlen(buf));
}
BOOL PSDRV_WritePatternDict(PHYSDEV dev, BITMAP *bm, BYTE *bits)
BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, UINT usage)
{
static const char mypat[] = "/mypat\n";
static const char do_pattern[] = "<<\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 0 0 translate\n"
" %d %d scale\n mypat image\n end\n }\n>>\n matrix makepattern setpattern\n";
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf, *ptr;
INT w, h, x, y, w_mult, h_mult;
COLORREF map[2];
w = bm->bmWidth & ~0x7;
h = bm->bmHeight & ~0x7;
buf = HeapAlloc(PSDRV_Heap, 0, sizeof(do_pattern) + 100);
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_WriteSpool(dev, mypat, sizeof(mypat) - 1);
PSDRV_WriteImageDict(dev, 1, 8, 8, buf, FALSE);
PSDRV_WriteSpool(dev, "def\n", 4);
PSDRV_WriteIndexColorSpaceBegin(dev, 1);
map[0] = GetTextColor( dev->hdc );
map[1] = GetBkColor( dev->hdc );
PSDRV_WriteRGB(dev, map, 2);
PSDRV_WriteIndexColorSpaceEnd(dev);
/* Windows seems to scale patterns so that a one pixel corresponds to 1/300" */
w_mult = (physDev->logPixelsX + 150) / 300;
h_mult = (physDev->logPixelsY + 150) / 300;
sprintf(buf, do_pattern, w * w_mult, h * h_mult, w * w_mult, h * h_mult, w * w_mult, h * h_mult);
PSDRV_WriteSpool(dev, buf, strlen(buf));
HeapFree(PSDRV_Heap, 0, buf);
return TRUE;
}
BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, BITMAPINFO *bmi, UINT usage)
{
static const char mypat[] = "/mypat\n";
static const char do_pattern[] = "<<\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 0 0 translate\n"
" %d %d scale\n mypat image\n end\n }\n>>\n matrix makepattern setpattern\n";
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
char *buf, *ptr;
BYTE *bits;
INT w, h, x, y, colours, w_mult, h_mult;
COLORREF map[2];
TRACE( "size %dx%dx%d\n",
bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount);
if(bmi->bmiHeader.biBitCount != 1) {
FIXME("dib depth %d not supported\n", bmi->bmiHeader.biBitCount);
return FALSE;
}
bits = (LPBYTE)bmi + bmi->bmiHeader.biSize;
colours = bmi->bmiHeader.biClrUsed;
if (colours > 256) colours = 256;
if(!colours && bmi->bmiHeader.biBitCount <= 8)
colours = 1 << bmi->bmiHeader.biBitCount;
bits += colours * ((usage == DIB_RGB_COLORS) ?
sizeof(RGBQUAD) : sizeof(WORD));
w = bmi->bmiHeader.biWidth & ~0x7;
h = bmi->bmiHeader.biHeight & ~0x7;
......
......@@ -327,6 +327,9 @@ typedef struct {
typedef struct {
PSCOLOR color;
BOOL set;
const BITMAPINFO *info;
void *bits;
UINT usage;
} PSBRUSH;
#define MAX_DASHLEN 16
......@@ -531,8 +534,7 @@ extern BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, INT xDst, INT yDst,
extern BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteData(PHYSDEV dev, const BYTE *byte, DWORD number) DECLSPEC_HIDDEN;
extern DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WritePatternDict(PHYSDEV dev, BITMAP *bm, BYTE *bits) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, BITMAPINFO *bmi, UINT usage) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, UINT usage) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayPut(PHYSDEV dev, CHAR *pszArrayName, INT nIndex, LONG lCoord) DECLSPEC_HIDDEN;
extern BOOL PSDRV_WriteArrayDef(PHYSDEV dev, CHAR *pszArrayName, INT nSize) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment