Commit 3c2502a8 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Add support for dithering pattern brushes when painting to monochrome bitmaps.

parent 27ca37db
...@@ -230,7 +230,7 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit ...@@ -230,7 +230,7 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
__TRY __TRY
{ {
dst_dib.funcs->convert_to( &dst_dib, &src_dib, &src->visrect ); dst_dib.funcs->convert_to( &dst_dib, &src_dib, &src->visrect, FALSE );
ret = TRUE; ret = TRUE;
} }
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
......
...@@ -191,7 +191,7 @@ typedef struct primitive_funcs ...@@ -191,7 +191,7 @@ typedef struct primitive_funcs
DWORD (* get_pixel)(const dib_info *dib, int x, int y); DWORD (* get_pixel)(const dib_info *dib, int x, int y);
DWORD (* colorref_to_pixel)(const dib_info *dib, COLORREF color); DWORD (* colorref_to_pixel)(const dib_info *dib, COLORREF color);
COLORREF (* pixel_to_colorref)(const dib_info *dib, DWORD pixel); COLORREF (* pixel_to_colorref)(const dib_info *dib, DWORD pixel);
void (* convert_to)(dib_info *dst, const dib_info *src, const RECT *src_rect); void (* convert_to)(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither);
BOOL (* create_rop_masks)(const dib_info *dib, const dib_info *hatch, BOOL (* create_rop_masks)(const dib_info *dib, const dib_info *hatch,
const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits); const rop_mask *fg, const rop_mask *bg, rop_mask_bits *bits);
void (* stretch_row)(const dib_info *dst_dib, const POINT *dst_start, void (* stretch_row)(const dib_info *dst_dib, const POINT *dst_start,
......
...@@ -1874,6 +1874,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * ...@@ -1874,6 +1874,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL *
BITMAPINFO *info = (BITMAPINFO *)buffer; BITMAPINFO *info = (BITMAPINFO *)buffer;
RGBQUAD color_table[2]; RGBQUAD color_table[2];
dib_info pattern; dib_info pattern;
BOOL dither = (brush->dib.bit_count == 1);
if (!brush->pattern.info) if (!brush->pattern.info)
{ {
...@@ -1921,6 +1922,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * ...@@ -1921,6 +1922,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL *
pattern.color_table = color_table; pattern.color_table = color_table;
pattern.color_table_size = 2; pattern.color_table_size = 2;
*needs_reselect = TRUE; *needs_reselect = TRUE;
dither = FALSE; /* DDB pattern brushes don't get dithered */
} }
copy_dib_color_info(&brush->dib, &pdev->dib); copy_dib_color_info(&brush->dib, &pdev->dib);
...@@ -1930,7 +1932,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * ...@@ -1930,7 +1932,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL *
brush->dib.stride = get_dib_stride( brush->dib.width, brush->dib.bit_count ); brush->dib.stride = get_dib_stride( brush->dib.width, brush->dib.bit_count );
brush->dib.rect = pattern.rect; brush->dib.rect = pattern.rect;
if (matching_pattern_format( &brush->dib, &pattern )) if (!dither && matching_pattern_format( &brush->dib, &pattern ))
{ {
brush->dib.bits.ptr = pattern.bits.ptr; brush->dib.bits.ptr = pattern.bits.ptr;
brush->dib.bits.is_copy = FALSE; brush->dib.bits.is_copy = FALSE;
...@@ -1941,7 +1943,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * ...@@ -1941,7 +1943,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL *
brush->dib.bits.ptr = HeapAlloc( GetProcessHeap(), 0, brush->dib.height * brush->dib.stride ); brush->dib.bits.ptr = HeapAlloc( GetProcessHeap(), 0, brush->dib.height * brush->dib.stride );
brush->dib.bits.is_copy = TRUE; brush->dib.bits.is_copy = TRUE;
brush->dib.bits.free = free_heap_bits; brush->dib.bits.free = free_heap_bits;
brush->dib.funcs->convert_to(&brush->dib, &pattern, &pattern.rect); brush->dib.funcs->convert_to(&brush->dib, &pattern, &pattern.rect, dither);
} }
return TRUE; return TRUE;
} }
......
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