ReactOS 0.4.15-dev-7931-gfd331f1
dib.c File Reference
#include "precomp.h"
#include <wincrypt.h>
Include dependency graph for dib.c:

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 

Functions

static BOOL rop_uses_src (DWORD rop)
 
static DWORD get_stride (const BITMAPINFO *bmi)
 
static DWORD get_dib_size (const BITMAPINFO *bmi)
 
static charhash_dib (const BITMAPINFO *bmi, const void *bits)
 
static void reset_bounds (HDC hdc)
 
static void compare_bounds (HDC hdc, const char *info)
 
static void compare_hash_broken_todo (HDC hdc, const BITMAPINFO *bmi, BYTE *bits, const char *info, int num_broken, BOOL todo)
 
static void compare_hash (HDC hdc, const BITMAPINFO *bmi, BYTE *bits, const char *info)
 
static HPALETTE create_default_palette (int bpp)
 
static void solid_patblt (HDC hdc, int x, int y, int width, int height, COLORREF color)
 
static void draw_graphics (HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
 
static void get_range (BYTE alpha, DWORD text_comp, BYTE *min_comp, BYTE *max_comp)
 
static BYTE aa_comp (BYTE dst, BYTE text, BYTE alpha)
 
static COLORREF aa_colorref (COLORREF dst, COLORREF text, BYTE glyph)
 
static void draw_text_2 (HDC hdc, const BITMAPINFO *bmi, BYTE *bits, BOOL aa)
 
static void draw_text (HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
 
static void test_simple_graphics (void)
 
 START_TEST (dib)
 

Variables

static HCRYPTPROV crypt_prov
 
static const DWORD rop3 [256]
 
static const charsha1_graphics_a8r8g8b8 []
 
static const charsha1_graphics_a8r8g8b8_bitfields []
 
static const charsha1_graphics_a8b8g8r8 []
 
static const charsha1_graphics_r10g10b10 []
 
static const charsha1_graphics_r6g6b6 []
 
static const charsha1_graphics_24 []
 
static const charsha1_graphics_r5g5b5 []
 
static const charsha1_graphics_r4g4b4 []
 
static const charsha1_graphics_8_color []
 
static const charsha1_graphics_8_grayscale []
 
static const charsha1_graphics_8 []
 
static const charsha1_graphics_4 []
 
static const charsha1_graphics_4_grayscale []
 
static const charsha1_graphics_1 []
 
static const RECT graphics_bounds []
 
static const char ** current_sha1
 
static const RECTcurrent_bounds
 
static const chardst_format
 
static const RECT bias_check []
 
static const RECT hline_clips []
 
static const RECT vline_clips []
 
static const RECT line_clips []
 
static const RECT wide_lines []
 
static const POINT poly_lines []
 
static const POINT polypoly_lines []
 
static const DWORD polypoly_counts []
 
static const RECT patblt_clips []
 
static const RECT rectangles []
 
static const BITMAPINFOHEADER dib_brush_header_8888 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
 
static const BITMAPINFOHEADER dib_brush_header_24 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 24, BI_RGB, 0, 0, 0, 0, 0}
 
static const BITMAPINFOHEADER dib_brush_header_555 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
 
static const BITMAPINFOHEADER dib_brush_header_8 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 8, BI_RGB, 0, 0, 0, 0, 0}
 
static const BITMAPINFOHEADER dib_brush_header_4 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 4, BI_RGB, 0, 0, 0, 0, 0}
 
static const BITMAPINFOHEADER dib_brush_header_1 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 1, BI_RGB, 0, 0, 0, 0, 0}
 
static const BYTE rle8_data [20]
 
static const DWORD four_by_four_data [16]
 
static const DWORD ddb_brush_bits [8]
 
static const RGBQUAD default_palette_1 [2]
 
static const RGBQUAD default_palette_4 [16]
 
static const RGBQUAD default_palette_8 [256]
 
static const BYTE ramp [17]
 
static const BYTE masks [8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}
 

Macro Definition Documentation

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 26 of file dib.c.

Function Documentation

◆ aa_colorref()

static COLORREF aa_colorref ( COLORREF  dst,
COLORREF  text,
BYTE  glyph 
)
inlinestatic

Definition at line 2750 of file dib.c.

2751{
2752 COLORREF ret;
2753
2754 ret = RGB( aa_comp( GetRValue(dst), GetRValue(text), glyph ),
2755 aa_comp( GetGValue(dst), GetGValue(text), glyph ),
2756 aa_comp( GetBValue(dst), GetBValue(text), glyph ) );
2757 return ret;
2758}
const WCHAR * text
Definition: package.c:1799
#define RGB(r, g, b)
Definition: precomp.h:71
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
GLenum GLenum dst
Definition: glext.h:6340
static BYTE aa_comp(BYTE dst, BYTE text, BYTE alpha)
Definition: dib.c:2724
int ret
DWORD COLORREF
Definition: windef.h:300

Referenced by draw_text_2().

◆ aa_comp()

static BYTE aa_comp ( BYTE  dst,
BYTE  text,
BYTE  alpha 
)
inlinestatic

Definition at line 2724 of file dib.c.

2725{
2726 BYTE min_comp, max_comp;
2727
2728 if (alpha == 16) return text;
2729 if (alpha <= 1) return dst;
2730 if (text == dst) return dst;
2731
2732 get_range( alpha, text, &min_comp, &max_comp );
2733
2734 if (dst > text)
2735 {
2736 DWORD diff = dst - text;
2737 DWORD range = max_comp - text;
2738 dst = text + (diff * range ) / (0xff - text);
2739 return dst;
2740 }
2741 else
2742 {
2743 DWORD diff = text - dst;
2744 DWORD range = text - min_comp ;
2745 dst = text - (diff * range) / text;
2746 return dst;
2747 }
2748}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLenum GLint * range
Definition: glext.h:7539
static void get_range(BYTE alpha, DWORD text_comp, BYTE *min_comp, BYTE *max_comp)
Definition: dib.c:2718
unsigned char BYTE
Definition: xxhash.c:193

Referenced by aa_colorref().

◆ compare_bounds()

static void compare_bounds ( HDC  hdc,
const char info 
)
static

Definition at line 1185 of file dib.c.

1186{
1187 RECT rect;
1188
1190
1191 if (current_bounds->left == -1 &&
1192 current_bounds->top == -1 &&
1193 current_bounds->right == -1 &&
1194 current_bounds->bottom == -1)
1195 {
1196 ok( 0, "missing bounds, got %s,\n", wine_dbgstr_rect( &rect ));
1197 return;
1198 }
1199
1200 ok( EqualRect( current_bounds, &rect ), "%s: %s: expected bounds %s got %s\n", dst_format, info,
1203}
#define ok(value,...)
Definition: atltest.h:57
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
HDC hdc
Definition: main.c:9
static const char * dst_format
Definition: dib.c:1133
static const RECT * current_bounds
Definition: dib.c:1132
& rect
Definition: startmenu.cpp:1413
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define DCB_RESET
Definition: wingdi.h:687
UINT WINAPI GetBoundsRect(_In_ HDC, _Out_ LPRECT, _In_ UINT)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by compare_hash_broken_todo().

◆ compare_hash()

static void compare_hash ( HDC  hdc,
const BITMAPINFO bmi,
BYTE bits,
const char info 
)
static

Definition at line 1246 of file dib.c.

1247{
1249}
#define FALSE
Definition: types.h:117
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, const char *info, int num_broken, BOOL todo)
Definition: dib.c:1205

Referenced by draw_graphics().

◆ compare_hash_broken_todo()

static void compare_hash_broken_todo ( HDC  hdc,
const BITMAPINFO bmi,
BYTE bits,
const char info,
int  num_broken,
BOOL  todo 
)
static

Definition at line 1205 of file dib.c.

1206{
1207 char *hash = hash_dib(bmi, bits);
1208 BOOL ok_cond;
1209 int i;
1210
1211 /* reset the bits for the next test */
1212 memset( bits, 0xcc, get_dib_size(bmi) );
1213
1214 if(!hash)
1215 {
1216 skip("SHA1 hashing unavailable on this platform\n");
1217 return;
1218 }
1219
1220 for(i = 0; i <= num_broken; i++)
1221 {
1222 if(current_sha1[i] == NULL)
1223 {
1224 ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash);
1226 return;
1227 }
1228 }
1229
1230 ok_cond = !strcmp(hash, *current_sha1);
1231
1232 for(i = 1; i <= num_broken; i++)
1233 ok_cond = ok_cond || broken( !strcmp(hash, current_sha1[i]) );
1234
1236 ok( ok_cond, "%s: %s: expected hash %s got %s\n",
1238
1239 current_sha1 += num_broken + 1;
1240
1242
1244}
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL todo
Definition: filedlg.c:313
static const char ** current_sha1
Definition: dib.c:1131
static DWORD get_dib_size(const BITMAPINFO *bmi)
Definition: dib.c:1140
static void compare_bounds(HDC hdc, const char *info)
Definition: dib.c:1185
static char * hash_dib(const BITMAPINFO *bmi, const void *bits)
Definition: dib.c:1145
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define memset(x, y, z)
Definition: compat.h:39
Definition: _hash_fun.h:40

Referenced by compare_hash(), and draw_graphics().

◆ create_default_palette()

static HPALETTE create_default_palette ( int  bpp)
static

Definition at line 1479 of file dib.c.

1480{
1481 char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)];
1482 LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
1483 PALETTEENTRY *entries = pal->palPalEntry;
1484 int i;
1485
1486 pal->palVersion = 0x300;
1487 pal->palNumEntries = 1 << bpp;
1488 switch (bpp)
1489 {
1490 case 1:
1491 for (i = 0; i < 2; i++)
1492 {
1493 entries[i].peRed = default_palette_1[i].rgbRed;
1494 entries[i].peGreen = default_palette_1[i].rgbGreen;
1495 entries[i].peBlue = default_palette_1[i].rgbBlue;
1496 entries[i].peFlags = 0;
1497 }
1498 break;
1499 case 4:
1500 for (i = 0; i < 16; i++)
1501 {
1502 entries[i].peRed = default_palette_4[i].rgbRed;
1503 entries[i].peGreen = default_palette_4[i].rgbGreen;
1504 entries[i].peBlue = default_palette_4[i].rgbBlue;
1505 entries[i].peFlags = 0;
1506 }
1507 break;
1508 case 8:
1509 for (i = 0; i < 256; i++)
1510 {
1511 entries[i].peRed = default_palette_8[i].rgbRed;
1512 entries[i].peGreen = default_palette_8[i].rgbGreen;
1513 entries[i].peBlue = default_palette_8[i].rgbBlue;
1514 entries[i].peFlags = 0;
1515 }
1516 break;
1517 }
1518 return CreatePalette( pal );
1519}
DWORD bpp
Definition: surface.c:185
static const RGBQUAD default_palette_4[16]
Definition: dib.c:1403
static const RGBQUAD default_palette_1[2]
Definition: dib.c:1398
static const RGBQUAD default_palette_8[256]
Definition: dib.c:1411
WORD palNumEntries
Definition: wingdi.h:1834
WORD palVersion
Definition: wingdi.h:1833
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
struct tagLOGPALETTE LOGPALETTE

Referenced by test_simple_graphics().

◆ draw_graphics()

static void draw_graphics ( HDC  hdc,
const BITMAPINFO bmi,
BYTE bits 
)
static

Definition at line 1529 of file dib.c.

1530{
1531 char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)];
1532 LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
1533 PALETTEENTRY *entries = pal->palPalEntry;
1534 HPEN solid_pen, dashed_pen, wide_pen, orig_pen;
1535 LOGBRUSH log_brush;
1536 HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush;
1537 HBITMAP bmp;
1538 INT i, j, x, y, hatch_style;
1539 HDC src_dc;
1540 HRGN hrgn, hrgn2;
1541 BYTE dib_src_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
1542 BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */
1543 BITMAPINFO *src_bi = (BITMAPINFO*)dib_src_buf;
1544 BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf;
1545 RGBQUAD *brush_colors = brush_bi->bmiColors;
1546 BYTE *brush_bits, *src_bits;
1547 BOOL ret, dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1);
1548 BOOL dib_is_8bpp_gray = (bmi->bmiHeader.biBitCount == 8 && bmi->bmiColors[1].rgbRed == 1);
1549 BLENDFUNCTION blend;
1550 COLORREF old_text, old_bkgnd;
1551 HPALETTE hpal, old_hpal;
1552
1553 blend.BlendOp = AC_SRC_OVER;
1554 blend.BlendFlags = 0;
1555
1556 reset_bounds( hdc );
1557
1558 memset(bits, 0xcc, get_dib_size(bmi));
1559 compare_hash(hdc, bmi, bits, "empty");
1560
1561 src_dc = CreateCompatibleDC( 0 );
1562 solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
1563 orig_pen = SelectObject(hdc, solid_pen);
1564 SetBrushOrgEx(hdc, 0, 0, NULL);
1565
1566 /* horizontal and vertical lines */
1567 for(i = 1; i <= 16; i++)
1568 {
1569 SetROP2(hdc, i);
1570 MoveToEx(hdc, 10, i * 3, NULL);
1571 LineTo(hdc, 100, i * 3); /* l -> r */
1572 MoveToEx(hdc, 100, 50 + i * 3, NULL);
1573 LineTo(hdc, 10, 50 + i * 3); /* r -> l */
1574 MoveToEx(hdc, 120 + i * 3, 10, NULL);
1575 LineTo(hdc, 120 + i * 3, 100); /* t -> b */
1576 MoveToEx(hdc, 170 + i * 3, 100, NULL);
1577 LineTo(hdc, 170 + i * 3, 10); /* b -> t */
1578 }
1579 compare_hash(hdc, bmi, bits, "h and v solid lines");
1580
1581 /* diagonal lines */
1583 for(i = 0; i < 16; i++)
1584 {
1585 double s = sin(M_PI * i / 8.0);
1586 double c = cos(M_PI * i / 8.0);
1587
1588 MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
1589 LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
1590 }
1591 compare_hash(hdc, bmi, bits, "diagonal solid lines");
1592
1593 for(i = 0; i < sizeof(bias_check) / sizeof(bias_check[0]); i++)
1594 {
1597 }
1598 compare_hash(hdc, bmi, bits, "more diagonal solid lines");
1599
1600 /* solid brush PatBlt */
1601 solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
1602 orig_brush = SelectObject(hdc, solid_brush);
1603
1604 for(i = 0, y = 10; i < 256; i++)
1605 {
1606 ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]);
1607
1608 if(rop_uses_src(rop3[i]))
1609 ok(ret == FALSE, "got TRUE for %x\n", rop3[i]);
1610 else
1611 {
1612 ok(ret, "got FALSE for %x\n", rop3[i]);
1613 y += 20;
1614 }
1615
1616 }
1617 compare_hash(hdc, bmi, bits, "solid patblt");
1618
1619 /* clipped lines */
1620 hrgn = CreateRectRgn(10, 10, 200, 20);
1621 hrgn2 = CreateRectRgn(100, 100, 200, 200);
1623 SetRectRgn(hrgn2, 290, 100, 300, 200);
1627
1628 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1629 {
1632 }
1633 compare_hash(hdc, bmi, bits, "clipped solid hlines");
1634
1635 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1636 {
1639 }
1640 compare_hash(hdc, bmi, bits, "clipped solid vlines");
1641
1642 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1643 {
1646 }
1647 compare_hash(hdc, bmi, bits, "clipped solid diagonal lines");
1648
1649 /* clipped PatBlt */
1650 for(i = 0; i < sizeof(patblt_clips) / sizeof(patblt_clips[0]); i++)
1651 {
1655 }
1656 compare_hash(hdc, bmi, bits, "clipped patblt");
1657
1658 /* clipped dashed lines */
1659 dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0));
1660 SelectObject(hdc, dashed_pen);
1662 SetBkColor(hdc, RGB(0, 0xff, 0));
1663
1664 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1665 {
1668 }
1669 compare_hash(hdc, bmi, bits, "clipped dashed hlines");
1670
1671 for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++)
1672 {
1675 }
1676 compare_hash(hdc, bmi, bits, "clipped dashed hlines r -> l");
1677
1678 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1679 {
1682 }
1683 compare_hash(hdc, bmi, bits, "clipped dashed vlines");
1684
1685 for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++)
1686 {
1689 }
1690 compare_hash(hdc, bmi, bits, "clipped dashed vlines b -> t");
1691
1692 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1693 {
1696 }
1697 compare_hash(hdc, bmi, bits, "clipped dashed diagonal lines");
1698
1700
1701 for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++)
1702 {
1705 }
1706 compare_hash(hdc, bmi, bits, "clipped opaque dashed diagonal lines");
1707
1709
1710 /* 8888 DIB pattern brush */
1711
1712 brush_bi->bmiHeader = dib_brush_header_8888;
1713 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1714 memset(brush_bits, 0, 16 * 16 * sizeof(DWORD));
1715 brush_bits[2] = 0xff;
1716 brush_bits[6] = 0xff;
1717 brush_bits[14] = 0xff;
1718 brush_bits[65] = 0xff;
1719 brush_bits[69] = 0xff;
1720 brush_bits[72] = 0xff;
1721
1722 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1723
1724 SelectObject(hdc, dib_brush);
1725 SetBrushOrgEx(hdc, 1, 1, NULL);
1726
1727 for(i = 0, y = 10; i < 256; i++)
1728 {
1729 if(!rop_uses_src(rop3[i]))
1730 {
1731 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1732 ok(ret, "got FALSE for %x\n", rop3[i]);
1733 y += 25;
1734 }
1735 }
1736 compare_hash_broken_todo(hdc, bmi, bits, "top-down 8888 dib brush patblt", 0, dib_is_1bpp);
1737
1738 SelectObject(hdc, orig_brush);
1739 DeleteObject(dib_brush);
1740
1741 /* 8888 bottom-up DIB pattern brush */
1742
1743 brush_bi->bmiHeader.biHeight = -brush_bi->bmiHeader.biHeight;
1744
1745 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1746
1747 SelectObject(hdc, dib_brush);
1748
1749 /* This used to set the x origin to 100 as well, but
1750 there's a Windows bug for 24 bpp where the brush's x offset
1751 is incorrectly calculated for rops that involve both D and P */
1752 SetBrushOrgEx(hdc, 4, 100, NULL);
1753
1754 for(i = 0, y = 10; i < 256; i++)
1755 {
1756 if(!rop_uses_src(rop3[i]))
1757 {
1758 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1759 ok(ret, "got FALSE for %x\n", rop3[i]);
1760 y += 25;
1761 }
1762 }
1763 compare_hash(hdc, bmi, bits, "bottom-up 8888 dib brush patblt");
1764
1765 SelectObject(hdc, orig_brush);
1766 DeleteObject(dib_brush);
1767
1768 /* 24 bpp dib pattern brush */
1769
1770 brush_bi->bmiHeader = dib_brush_header_24;
1771 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1772 memset(brush_bits, 0, 16 * 16 * 3);
1773 brush_bits[0] = brush_bits[3] = brush_bits[6] = brush_bits[8] = 0xff;
1774 brush_bits[49] = brush_bits[52] = 0xff;
1775
1776 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1777
1778 SelectObject(hdc, dib_brush);
1779 SetBrushOrgEx(hdc, 1, 1, NULL);
1780
1781 for(i = 0, y = 10; i < 256; i++)
1782 {
1783 if(!rop_uses_src(rop3[i]))
1784 {
1785 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1786 ok(ret, "got FALSE for %x\n", rop3[i]);
1787 y += 25;
1788 }
1789 }
1790 compare_hash(hdc, bmi, bits, "top-down 24 bpp brush patblt");
1791
1792 SelectObject(hdc, orig_brush);
1793 DeleteObject(dib_brush);
1794
1795 /* 555 dib pattern brush */
1796
1797 brush_bi->bmiHeader = dib_brush_header_555;
1798 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1799 memset(brush_bits, 0, 16 * 16 * sizeof(WORD));
1800 brush_bits[0] = brush_bits[1] = 0xff;
1801 brush_bits[32] = brush_bits[34] = 0x7c;
1802
1803 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1804
1805 SelectObject(hdc, dib_brush);
1806 SetBrushOrgEx(hdc, 1, 1, NULL);
1807
1808 for(i = 0, y = 10; i < 256; i++)
1809 {
1810 if(!rop_uses_src(rop3[i]))
1811 {
1812 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1813 ok(ret, "got FALSE for %x\n", rop3[i]);
1814 y += 25;
1815 }
1816 }
1817 compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", 0, dib_is_1bpp);
1818
1819 SelectObject(hdc, orig_brush);
1820 DeleteObject(dib_brush);
1821
1822 SetBrushOrgEx(hdc, 0, 0, NULL);
1823
1824 /* 8 bpp dib pattern brush */
1825
1826 brush_bi->bmiHeader = dib_brush_header_8;
1827 brush_bi->bmiHeader.biClrUsed = 3;
1828 memset(brush_colors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD));
1829 brush_colors[0].rgbRed = 0xff;
1830 brush_colors[1].rgbRed = 0xff;
1831 brush_colors[1].rgbGreen = 0xff;
1832 brush_colors[1].rgbBlue = 0xff;
1833
1834 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD);
1835 memset(brush_bits, 0, 16 * 16 * sizeof(BYTE));
1836 brush_bits[0] = brush_bits[1] = 1;
1837 brush_bits[16] = brush_bits[17] = 2;
1838 brush_bits[32] = brush_bits[33] = 6;
1839
1840 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1841
1842 SelectObject(hdc, dib_brush);
1843 SetBrushOrgEx(hdc, 1, 1, NULL);
1844
1845 for(i = 0, y = 10; i < 256; i++)
1846 {
1847 if(!rop_uses_src(rop3[i]))
1848 {
1849 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1850 ok(ret, "got FALSE for %x\n", rop3[i]);
1851 y += 25;
1852 }
1853 }
1854 compare_hash_broken_todo(hdc, bmi, bits, "top-down 8 bpp dib brush patblt", 0, dib_is_1bpp);
1855
1856 SelectObject(hdc, orig_brush);
1857 DeleteObject(dib_brush);
1858
1859 /* 4 bpp dib pattern brush */
1860
1861 brush_bi->bmiHeader = dib_brush_header_4;
1862 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1863
1864 SelectObject(hdc, dib_brush);
1865 SetBrushOrgEx(hdc, 1, 1, NULL);
1866
1867 for(i = 0, y = 10; i < 256; i++)
1868 {
1869 if(!rop_uses_src(rop3[i]))
1870 {
1871 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1872 ok(ret, "got FALSE for %x\n", rop3[i]);
1873 y += 25;
1874 }
1875 }
1876 compare_hash_broken_todo(hdc, bmi, bits, "top-down 4 bpp dib brush patblt", 0, dib_is_1bpp);
1877
1878 SelectObject(hdc, orig_brush);
1879 DeleteObject(dib_brush);
1880
1881 /* 1 bpp dib pattern brush */
1882
1883 brush_bi->bmiHeader = dib_brush_header_1;
1884 brush_bi->bmiHeader.biClrUsed = 2;
1885 memset(brush_bits, 0, 16 * 4);
1886 brush_bits[0] = 0xf0;
1887 brush_bits[4] = 0xf0;
1888 brush_bits[8] = 0xf0;
1889
1890 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1891 SelectObject(hdc, dib_brush);
1892 for(i = 0, y = 10; i < 256; i++)
1893 {
1894 if(!rop_uses_src(rop3[i]))
1895 {
1896 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1897 ok(ret, "got FALSE for %x\n", rop3[i]);
1898 y += 25;
1899 }
1900 }
1901
1902 compare_hash_broken_todo(hdc, bmi, bits, "top-down 1 bpp dib brush patblt", 0, dib_is_1bpp);
1903
1904 SelectObject(hdc, orig_brush);
1905 DeleteObject(dib_brush);
1906
1907 /* 1 bpp ddb pattern brush */
1908
1909 old_text = GetTextColor( hdc );
1910 old_bkgnd = GetBkColor( hdc );
1911 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
1912 dib_brush = CreatePatternBrush( bmp );
1913 SelectObject(hdc, dib_brush);
1914 for(i = 0, y = 10; i < 256; i++)
1915 {
1916 SetTextColor(hdc, RGB( i, 2*i, 255 - i ) );
1917 SetBkColor(hdc, RGB( 255 - i, i / 3, i ) );
1918 if(!rop_uses_src(rop3[i]))
1919 {
1920 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1921 ok(ret, "got FALSE for %x\n", rop3[i]);
1922 y += 25;
1923 }
1924 }
1925
1926 compare_hash_broken_todo(hdc, bmi, bits, "1 bpp ddb brush patblt", 0, dib_is_1bpp);
1927
1929 SelectObject(hdc, orig_brush);
1930 DeleteObject( dib_brush );
1931 SetBrushOrgEx(hdc, 0, 0, NULL);
1932 SetTextColor(hdc, old_text);
1933 SetBkColor(hdc, old_bkgnd);
1934
1935 /* Rectangle */
1936
1937 SelectObject(hdc, solid_pen);
1938 SelectObject(hdc, solid_brush);
1939
1940 for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1941 {
1943 }
1944
1945 SelectObject(hdc, dashed_pen);
1946 for(i = 0; i < sizeof(rectangles)/sizeof(rectangles[0]); i++)
1947 {
1949 }
1950
1951 compare_hash(hdc, bmi, bits, "rectangles");
1952 SelectObject(hdc, solid_pen);
1953
1954 /* PaintRgn */
1955
1956 PaintRgn(hdc, hrgn);
1957 compare_hash(hdc, bmi, bits, "PaintRgn");
1958
1959 /* RTL rectangles */
1960
1962 PaintRgn(hdc, hrgn);
1963 PatBlt(hdc, 10, 250, 10, 10, PATCOPY);
1964 Rectangle(hdc, 100, 250, 110, 260);
1965 compare_hash(hdc, bmi, bits, "rtl");
1967 DeleteObject( hrgn );
1968
1969 for(i = 0, y = 10; i < 256; i++)
1970 {
1971 if(!rop_uses_src(rop3[i]))
1972 {
1973 for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++)
1974 {
1975 hatch_brush = CreateHatchBrush(hatch_style, RGB(0xff, 0, 0));
1976 SelectObject(hdc, hatch_brush);
1977 ret = PatBlt(hdc, 10 + i + 30 * hatch_style, y, 20, 20, rop3[i]);
1978 ok(ret, "got FALSE for %x\n", rop3[i]);
1979 SelectObject(hdc, orig_brush);
1980 DeleteObject(hatch_brush);
1981 }
1982 y += 25;
1983 }
1984 }
1985
1986 compare_hash(hdc, bmi, bits, "hatch brushes");
1987
1988 /* overlapping blits */
1989
1990 orig_brush = SelectObject(hdc, solid_brush);
1991
1992 Rectangle(hdc, 10, 10, 100, 100);
1993 Rectangle(hdc, 20, 15, 30, 40);
1994 Rectangle(hdc, 15, 15, 20, 20);
1995 Rectangle(hdc, 15, 20, 50, 45);
1996 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, SRCCOPY );
1997 compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, +y");
1998
1999 Rectangle(hdc, 10, 10, 100, 100);
2000 Rectangle(hdc, 20, 15, 30, 40);
2001 Rectangle(hdc, 15, 15, 20, 20);
2002 Rectangle(hdc, 15, 20, 50, 45);
2003 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, SRCCOPY );
2004 if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */
2005 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y",1, FALSE);
2006 else
2007 compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y");
2008
2009 Rectangle(hdc, 10, 10, 100, 100);
2010 Rectangle(hdc, 20, 15, 30, 40);
2011 Rectangle(hdc, 15, 15, 20, 20);
2012 Rectangle(hdc, 15, 20, 50, 45);
2013 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, SRCCOPY );
2014 compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, -y");
2015
2016 Rectangle(hdc, 10, 10, 100, 100);
2017 Rectangle(hdc, 20, 15, 30, 40);
2018 Rectangle(hdc, 15, 15, 20, 20);
2019 Rectangle(hdc, 15, 20, 50, 45);
2020 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, SRCCOPY );
2021 if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */
2022 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y", 1, FALSE );
2023 else
2024 compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y" );
2025
2026 Rectangle(hdc, 10, 10, 100, 100);
2027 Rectangle(hdc, 20, 15, 30, 40);
2028 Rectangle(hdc, 15, 15, 20, 20);
2029 Rectangle(hdc, 15, 20, 50, 45);
2030 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, PATPAINT );
2031 compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, +y");
2032
2033 Rectangle(hdc, 10, 10, 100, 100);
2034 Rectangle(hdc, 20, 15, 30, 40);
2035 Rectangle(hdc, 15, 15, 20, 20);
2036 Rectangle(hdc, 15, 20, 50, 45);
2037 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, PATPAINT );
2038 compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, -y");
2039
2040 Rectangle(hdc, 10, 10, 100, 100);
2041 Rectangle(hdc, 20, 15, 30, 40);
2042 Rectangle(hdc, 15, 15, 20, 20);
2043 Rectangle(hdc, 15, 20, 50, 45);
2044 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, PATPAINT );
2045 if (bmi->bmiHeader.biBitCount >= 24) /* Windows gets this one wrong */
2046 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE);
2047 else
2048 compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y");
2049
2050 Rectangle(hdc, 10, 10, 100, 100);
2051 Rectangle(hdc, 20, 15, 30, 40);
2052 Rectangle(hdc, 15, 15, 20, 20);
2053 Rectangle(hdc, 15, 20, 50, 45);
2054 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, PATPAINT );
2055 compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, +y" );
2056
2057 /* blitting with 32-bpp BI_RGB source */
2058
2059 memset( dib_src_buf, 0, sizeof(dib_src_buf) );
2060 src_bi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
2061 src_bi->bmiHeader.biHeight = 256;
2062 src_bi->bmiHeader.biWidth = 256;
2063 src_bi->bmiHeader.biBitCount = 32;
2064 src_bi->bmiHeader.biPlanes = 1;
2065 src_bi->bmiHeader.biCompression = BI_RGB;
2066 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2067 SelectObject( src_dc, bmp );
2068 for (y = 0; y < 256; y++)
2069 for (x = 0; x < 256; x++)
2070 {
2071 BYTE a = (x + y) * 2;
2072 BYTE r = (BYTE)(y + 2 * x) * a / 255;
2073 BYTE g = (BYTE)(x + y / 3) * a / 255;
2074 BYTE b = (BYTE)(x / 3 + 2 * y) * a / 255;
2075 ((DWORD *)src_bits)[y * 256 + x] = (a << 24) | RGB( r, g, b );
2076 }
2077
2078 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2079
2080 /* Interesting cases for 1-bpp dst */
2081 BitBlt( hdc, 1, 4, 2, 2, src_dc, 0, 0, SRCCOPY );
2082 BitBlt( hdc, 1, 8, 16, 2, src_dc, 0, 0, SRCCOPY );
2083 BitBlt( hdc, 1, 12, 15, 2, src_dc, 0, 0, SRCCOPY );
2084 BitBlt( hdc, 0, 16, 8, 2, src_dc, 0, 0, SRCCOPY );
2085 BitBlt( hdc, 0, 20, 9, 2, src_dc, 0, 0, SRCCOPY );
2086 BitBlt( hdc, 7, 24, 1, 2, src_dc, 0, 0, SRCCOPY );
2087 BitBlt( hdc, 7, 28, 2, 2, src_dc, 0, 0, SRCCOPY );
2088 BitBlt( hdc, 7, 32, 9, 2, src_dc, 0, 0, SRCCOPY );
2089 BitBlt( hdc, 7, 36, 10, 2, src_dc, 0, 0, SRCCOPY );
2090 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY" );
2091
2092 blend.SourceConstantAlpha = 0xd0;
2093 blend.AlphaFormat = 0;
2094 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2095 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 0, dib_is_1bpp );
2096
2097 blend.SourceConstantAlpha = 0xb0;
2098 blend.AlphaFormat = AC_SRC_ALPHA;
2099 GdiAlphaBlend( hdc, 50, 50, 256, 256, src_dc, 0, 0, 256, 256, blend );
2100 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 0, dib_is_1bpp );
2101
2102 /* blitting with 32-bpp r10g10b10 source */
2103
2104 src_bi->bmiHeader.biBitCount = 32;
2105 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2106 ((DWORD *)src_bi->bmiColors)[0] = 0x3ff00000;
2107 ((DWORD *)src_bi->bmiColors)[1] = 0x000ffc00;
2108 ((DWORD *)src_bi->bmiColors)[2] = 0x000003ff;
2109 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2110 SelectObject( src_dc, bmp );
2111 for (y = 0; y < 256; y++)
2112 for (x = 0; x < 256; x++)
2113 {
2114 WORD r = (7 * x + 3 * y) % 1024;
2115 WORD g = (11 * x + y / 3) % 1024;
2116 WORD b = (x / 3 + 9 * y) % 1024;
2117 ((DWORD *)src_bits)[y * 256 + x] = r << 20 | g << 10 | b;
2118 }
2119
2120 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2121 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY" );
2122
2123 /* blitting with 32-bpp b6g6r6 source */
2124
2125 src_bi->bmiHeader.biBitCount = 32;
2126 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2127 ((DWORD *)src_bi->bmiColors)[0] = 0x00003f;
2128 ((DWORD *)src_bi->bmiColors)[1] = 0x000fc0;
2129 ((DWORD *)src_bi->bmiColors)[2] = 0x03f000;
2130 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2131 SelectObject( src_dc, bmp );
2132 for (y = 0; y < 256; y++)
2133 for (x = 0; x < 256; x++)
2134 {
2135 BYTE r = (y + 2 * x) % 64;
2136 BYTE g = (x + y / 3) % 64;
2137 BYTE b = (x / 3 + 2 * y) % 64;
2138 ((DWORD *)src_bits)[y * 256 + x] = r | g << 6 | b << 12;
2139 }
2140
2141 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2142 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY" );
2143
2144 /* blitting with 24-bpp source */
2145
2146 src_bi->bmiHeader.biBitCount = 24;
2147 src_bi->bmiHeader.biCompression = BI_RGB;
2148 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2149 DeleteObject( SelectObject( src_dc, bmp ) );
2150 for (y = 0; y < 256; y++)
2151 for (x = 0; x < 256; x++)
2152 {
2153 src_bits[(y * 256 + x) * 3 + 0] = x + 3 * y;
2154 src_bits[(y * 256 + x) * 3 + 1] = 2 * x + 7 * y;
2155 src_bits[(y * 256 + x) * 3 + 2] = 5 * x + 12 * y;
2156 }
2157
2158 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2159 compare_hash(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY" );
2160
2161 blend.SourceConstantAlpha = 0xe0;
2162 blend.AlphaFormat = 0;
2163 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2164 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 0, dib_is_1bpp );
2165
2166 /* blitting with 16-bpp BI_RGB source */
2167
2168 src_bi->bmiHeader.biBitCount = 16;
2169 src_bi->bmiHeader.biCompression = BI_RGB;
2170 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2171 DeleteObject( SelectObject( src_dc, bmp ) );
2172 for (y = 0; y < 256; y++)
2173 for (x = 0; x < 256; x++)
2174 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2175
2176 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2177 compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY" );
2178
2179 /* blitting with 16-bpp b4g4r4 source */
2180
2181 src_bi->bmiHeader.biBitCount = 16;
2182 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2183 ((DWORD *)src_bi->bmiColors)[0] = 0x00000f;
2184 ((DWORD *)src_bi->bmiColors)[1] = 0x0000f0;
2185 ((DWORD *)src_bi->bmiColors)[2] = 0x000f00;
2186 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2187 DeleteObject( SelectObject( src_dc, bmp ) );
2188 for (y = 0; y < 256; y++)
2189 for (x = 0; x < 256; x++)
2190 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2191
2192 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2193 compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY" );
2194
2195 /* blitting with 8-bpp source */
2196
2197 src_bi->bmiHeader.biBitCount = 8;
2198 src_bi->bmiHeader.biCompression = BI_RGB;
2199 src_bi->bmiHeader.biClrUsed = 160;
2200 for (i = 0; i < 256; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 3) << 8 | (i / 2) << 16;
2201 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2202 DeleteObject( SelectObject( src_dc, bmp ) );
2203 for (y = 0; y < 256; y++)
2204 for (x = 0; x < 256; x++)
2205 src_bits[y * 256 + x] = 3 * x + 5 * y;
2206
2207 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2208 compare_hash(hdc, bmi, bits, "BitBlt src 8-bpp SRCCOPY" );
2209
2210 blend.SourceConstantAlpha = 0xd0;
2211 blend.AlphaFormat = 0;
2212 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2213 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 0, dib_is_1bpp );
2214
2215 /* blitting with 4-bpp source */
2216
2217 src_bi->bmiHeader.biBitCount = 4;
2218 src_bi->bmiHeader.biClrUsed = 12;
2219 for (i = 0; i < 16; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 5) << 8 | (i * 19) << 16;
2220 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2221 DeleteObject( SelectObject( src_dc, bmp ) );
2222 for (y = 0; y < 256; y++)
2223 for (x = 0; x < 256; x += 2)
2224 src_bits[(y * 256 + x) / 2] = 7 * x + 3 * y;
2225
2226 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2227 compare_hash(hdc, bmi, bits, "BitBlt src 4-bpp SRCCOPY" );
2228
2229 /* blitting with 1-bpp source */
2230
2231 src_bi->bmiHeader.biBitCount = 1;
2232 src_bi->bmiHeader.biClrUsed = 0;
2233 for (i = 0; i < 2; i++) ((DWORD *)src_bi->bmiColors)[i] = (i + 37) | (i * 91) << 8 | (i * 53) << 16;
2234 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2235 DeleteObject( SelectObject( src_dc, bmp ) );
2236 for (y = 0; y < 256; y++)
2237 for (x = 0; x < 256; x += 8)
2238 src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y;
2239
2240 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2241 /* Some interesting src co-ords */
2242 BitBlt( hdc, 10, 10, 3, 10, src_dc, 0, 0, SRCCOPY );
2243 BitBlt( hdc, 20, 10, 3, 10, src_dc, 2, 0, SRCCOPY );
2244 BitBlt( hdc, 30, 10, 3, 10, src_dc, 5, 0, SRCCOPY );
2245 BitBlt( hdc, 40, 10, 3, 10, src_dc, 6, 0, SRCCOPY );
2246 BitBlt( hdc, 50, 10, 20, 10, src_dc, 6, 0, SRCCOPY );
2247 compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp SRCCOPY" );
2248
2249 blend.SourceConstantAlpha = 0x90;
2250 blend.AlphaFormat = 0;
2251 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2252 compare_hash(hdc, bmi, bits, "AlphaBlend src 1-bpp" );
2253
2254 /* blitting with 1-bpp ddb source */
2255
2256 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2257 DeleteObject( SelectObject( src_dc, bmp ) );
2258
2259 old_text = GetTextColor( hdc );
2260 old_bkgnd = GetBkColor( hdc );
2261 for (i = 0; i < 256; i += 13)
2262 {
2263 SetTextColor(hdc, RGB( i, 2*i, 255 - i ) );
2264 SetBkColor(hdc, RGB( 255 - i, i / 3, i ) );
2265 BitBlt( hdc, i, 0, 13, 13, src_dc, 0, 0, SRCCOPY );
2266 }
2267 for (i = 0; i < 256; i += 13)
2268 {
2270 SetBkColor(hdc, PALETTEINDEX( i + 3 ));
2271 BitBlt( hdc, i, 13, 13, 13, src_dc, 0, 0, SRCCOPY );
2272 }
2273 for (i = 0; i < 256; i += 13)
2274 {
2276 SetBkColor(hdc, DIBINDEX( i + 3 ));
2277 BitBlt( hdc, i, 26, 13, 13, src_dc, 0, 0, SRCCOPY );
2278 }
2279 SetTextColor( hdc, old_text );
2280 SetBkColor( hdc, old_bkgnd );
2281 compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp ddb SRCCOPY" );
2282
2283 DeleteObject( bmp );
2284
2285 /* blitting to 1-bpp ddb dest */
2286
2287 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2288 DeleteObject( SelectObject( src_dc, bmp ) );
2289
2290 for (y = 0; y < 16; y++)
2291 for (x = 0; x < 16; x++)
2292 SetPixel( hdc, x, y, RGB( 16 * x, 16 * y, 8 * (x + y)) );
2293 PatBlt( hdc, 15, 15, 1, 1, WHITENESS );
2294 /* source colors are ignored */
2295 SetTextColor( src_dc, 0xbeef );
2296 SetBkColor( src_dc, RGB( 16 * 2, 16 * 3, 8 * (2 + 3) ));
2297 /* destination text color is also ignored */
2298 SetTextColor( hdc, 0xbedead );
2299
2300 i = 16;
2301 SetBkColor( hdc, 0xffffff );
2302 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2303 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2304 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2305 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2306 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2307 SetBkColor( hdc, 0 );
2308 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2309 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2310 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2311 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2312 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2313 SetBkColor( hdc, RGB( 16 * 2, 16 * 3, 8 * (2 + 3) ));
2314 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2315 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2316 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2317 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2318 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2319 SetBkColor( hdc, RGB( 16 * 13, 16 * 14, 8 * (13 + 14) ));
2320 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2321 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2322 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2323 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2324 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2325 SetBkColor( hdc, PALETTEINDEX( 1 ));
2326 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2327 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2328 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2329 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2330 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2331 SetBkColor( hdc, DIBINDEX( 2 ));
2332 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2333 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2334 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2335 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2336 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2337 SetTextColor( hdc, old_text );
2338 SetBkColor( hdc, old_bkgnd );
2339 compare_hash(hdc, bmi, bits, "BitBlt dst 1-bpp ddb");
2340
2341 DeleteDC( src_dc );
2342 DeleteObject( bmp );
2343
2344 /* RLE StretchDIBits */
2345 src_bi->bmiHeader.biSize = sizeof(src_bi->bmiHeader);
2346 src_bi->bmiHeader.biWidth = 8;
2347 src_bi->bmiHeader.biHeight = 8;
2348 src_bi->bmiHeader.biPlanes = 1;
2349 src_bi->bmiHeader.biBitCount = 8;
2350 src_bi->bmiHeader.biCompression = BI_RLE8;
2351 src_bi->bmiHeader.biClrUsed = 0;
2352 src_bi->bmiHeader.biSizeImage = sizeof(rle8_data);
2353
2354 for (i = 0; i < 256; i++)
2355 {
2356 src_bi->bmiColors[i].rgbRed = i;
2357 src_bi->bmiColors[i].rgbGreen = i;
2358 src_bi->bmiColors[i].rgbBlue = i;
2359 src_bi->bmiColors[i].rgbReserved = 0;
2360 }
2361
2362 StretchDIBits( hdc, 10, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2363 StretchDIBits( hdc, 100, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCAND );
2364 StretchDIBits( hdc, 200, 10, 7, 7, 0, 1, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2365 StretchDIBits( hdc, 300, 10, 7, 7, 1, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2366 StretchDIBits( hdc, 400, 10, 16, 16, 0, 0, 8, 8, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2367 compare_hash_broken_todo(hdc, bmi, bits, "rle stretchdibits", 0, dib_is_1bpp );
2368
2369 /* 32 bpp StretchDIBits */
2370
2371 src_bi->bmiHeader.biWidth = 4;
2372 src_bi->bmiHeader.biHeight = 4;
2373 src_bi->bmiHeader.biPlanes = 1;
2374 src_bi->bmiHeader.biBitCount = 32;
2375 src_bi->bmiHeader.biCompression = BI_RGB;
2376 src_bi->bmiHeader.biClrUsed = 0;
2377 src_bi->bmiHeader.biSizeImage = 0;
2378
2379 ret = StretchDIBits( hdc, 10, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2380 ok(ret == 4, "got %d\n", ret);
2381 ret = StretchDIBits( hdc, 20, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2382 ok(ret == 4, "got %d\n", ret);
2383 ret = StretchDIBits( hdc, 30, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2384 ok(ret == 4, "got %d\n", ret);
2385 ret = StretchDIBits( hdc, 40, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2386 ok(ret == 4, "got %d\n", ret);
2387 ret = StretchDIBits( hdc, 50, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2388 ok(ret == 4, "got %d\n", ret);
2389 ret = StretchDIBits( hdc, 60, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2390 ok(ret == 4, "got %d\n", ret);
2391
2392 src_bi->bmiHeader.biHeight = -4;
2393
2394 ret = StretchDIBits( hdc, 10, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2395 ok(ret == 4, "got %d\n", ret);
2396 ret = StretchDIBits( hdc, 20, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2397 ok(ret == -4, "got %d\n", ret);
2398 ret = StretchDIBits( hdc, 30, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2399 ok(ret == 4, "got %d\n", ret);
2400 ret = StretchDIBits( hdc, 40, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2401 ok(ret == -4, "got %d\n", ret);
2402 ret = StretchDIBits( hdc, 50, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2403 ok(ret == 4, "got %d\n", ret);
2404 ret = StretchDIBits( hdc, 60, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2405 ok(ret == -4, "got %d\n", ret);
2406
2407 compare_hash_broken_todo(hdc, bmi, bits, "stretchdibits", dib_is_8bpp_gray ? 1 : 0, dib_is_8bpp_gray );
2408
2409 /* Solid colors */
2410 for (i = 0; i < 256; i++)
2411 {
2412 solid_patblt( hdc, i * 2, 10, 1, 1, DIBINDEX(i) );
2413 solid_patblt( hdc, i * 2, 20, 1, 1, PALETTEINDEX(i) );
2414 solid_patblt( hdc, i * 2, 30, 1, 1, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2415 solid_patblt( hdc, i * 2, 40, 1, 1, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2416 for (j = 0; j < 256; j++) solid_patblt( hdc, i * 2, 50 + j, 1, 1, (j << 24) | i );
2417 }
2418
2419 /* A few extra colors that are interesting in the 1bpp case */
2420
2421 /* bk color */
2422 solid_patblt( hdc, 0, 50, 1, 1, RGB( 0, 0xff, 0 ) );
2423 solid_patblt( hdc, 2, 50, 1, 1, PALETTERGB( 0, 0xff, 0 ) );
2424
2425 /* color 0 */
2426 solid_patblt( hdc, 4, 50, 1, 1, RGB( 0, 0x1, 0xff ) );
2427 solid_patblt( hdc, 6, 50, 1, 1, PALETTERGB( 0, 0x1, 0xff ) );
2428
2429 /* color 1 */
2430 solid_patblt( hdc, 8, 50, 1, 1, RGB( 0xff, 0, 0 ) );
2431 solid_patblt( hdc, 10, 50, 1, 1, PALETTERGB( 0xff, 0, 0 ) );
2432
2433 compare_hash(hdc, bmi, bits, "Colors");
2434
2435 for (i = 0; i < 256; i++)
2436 {
2437 COLORREF s, g;
2438 s = SetPixel( hdc, i * 2, 10, DIBINDEX(i) );
2439 g = GetPixel( hdc, i * 2, 10 );
2440 ok( s == g, "got %08x and %08x\n", s, g );
2441
2442 s = SetPixel( hdc, i * 2, 20, PALETTEINDEX(i) );
2443 g = GetPixel( hdc, i * 2, 20 );
2444 ok( s == g, "got %08x and %08x\n", s, g );
2445
2446 s = SetPixel( hdc, i * 2, 30, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2447 g = GetPixel( hdc, i * 2, 30 );
2448 ok( s == g, "got %08x and %08x\n", s, g );
2449
2450 s = SetPixel( hdc, i * 2, 40, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2451 g = GetPixel( hdc, i * 2, 40 );
2452 ok( s == g, "got %08x and %08x\n", s, g );
2453
2454 for (j = 0; j < 256; j++)
2455 {
2456 s = SetPixel( hdc, i * 2, 50+j, (j << 24) | RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ));
2457 g = GetPixel( hdc, i * 2, 50+j );
2458 ok( s == g, "got %08x and %08x\n", s, g );
2459
2460 s = SetPixel( hdc, i * 2 + 1, 50+j, (j << 24) | i );
2461 g = GetPixel( hdc, i * 2 + 1, 50+j );
2462 ok( s == g, "got %08x and %08x\n", s, g );
2463 }
2464 }
2465
2466 compare_hash(hdc, bmi, bits, "SetPixel");
2467
2468 /* gradients */
2469
2470 {
2471 TRIVERTEX vrect[] =
2472 {
2473 { 1, 1, 0xff00, 0x8000, 0x0000, 0x8000 },
2474 { 200, 200, 0x0000, 0x0000, 0xff00, 0xff00 },
2475 { 180, 180, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2476 { 300, 300, 0xff00, 0xff00, 0xff00, 0x0000 }
2477 };
2478 GRADIENT_RECT rect[] = { { 0, 1 }, { 2, 3 }, { 2, 1 } };
2479
2480 TRIVERTEX vtri[] =
2481 {
2482 { 250, 0, 0xff00, 0x0000, 0xff00, 0xff00 },
2483 { 500, 500, 0x0000, 0xff00, 0x0000, 0xff00 },
2484 { 0, 500, 0x0000, 0x0000, 0xff00, 0xff00 },
2485
2486 { 10, 0, 0x8000, 0x0000, 0x8000, 0x8000 },
2487 { 0, 20, 0xff00, 0xff00, 0xff00, 0x0000 },
2488 { 5, 30, 0x4000, 0xc000, 0x7000, 0x9000 },
2489
2490 { 30, 0, 0x9000, 0x8800, 0xcc00, 0xff00 },
2491 { 5, 12, 0x9900, 0xaa00, 0xbb00, 0xcc00 },
2492 { 0, 30, 0x5000, 0xd000, 0x9000, 0xbb00 },
2493
2494 { 35, 3, 0xaa00, 0x6500, 0x4300, 0x2100 },
2495 { 50, 6, 0x9800, 0x9800, 0x9800, 0x2000 },
2496 { 60, 10, 0x0100, 0x0200, 0x0300, 0x3000 },
2497
2498 { 60, 2, 0x0700, 0x0800, 0x0900, 0xff00 },
2499 { 73, 10, 0x9900, 0x8800, 0x7700, 0xff00 },
2500 { 66, 23, 0x1100, 0x2200, 0x3300, 0xff00 },
2501
2502 { 80, 1, 0xa000, 0x6000, 0x4000, 0x2000 },
2503 { 76, 9, 0x7000, 0x5000, 0x3000, 0x1000 },
2504 { 85, 23, 0x3300, 0x3300, 0x3300, 0x3300 },
2505
2506 { 90, 4, 0x4400, 0x5500, 0x6600, 0x9900 },
2507 { 95, 12, 0x4500, 0x5600, 0x6700, 0x9900 },
2508 { 85, 14, 0x4600, 0x5700, 0x6800, 0x9900 },
2509 };
2510 GRADIENT_TRIANGLE tri[] =
2511 {
2512 { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 10, 11 }, { 12, 13, 14 }, { 15, 16, 17 }, { 18, 19, 20 },
2513 { 2, 1, 0 }, { 3, 5, 4 }, { 7, 6, 8 }, { 10, 11, 9 }, { 14, 13, 12 }, { 17, 15, 16 }, { 19, 20, 18 }
2514 };
2515
2516 GdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_H );
2517 for (i = 0; i < 4; i++) vrect[i].y += 250;
2518 GdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_V );
2519 /* Wine's 8-bit dithering isn't identical to Windows */
2520 compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, (bmi->bmiHeader.biBitCount <= 8) );
2521
2522 GdiGradientFill( hdc, vtri, 7*3, tri, 7, GRADIENT_FILL_TRIANGLE );
2523 for (i = 0; i < 7*3; i++) vtri[i].y += 100;
2524 GdiGradientFill( hdc, vtri, 7*3, tri + 7, 7, GRADIENT_FILL_TRIANGLE );
2525 /* Wine's 8-bit dithering isn't identical to Windows */
2526 compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, (bmi->bmiHeader.biBitCount <= 8) );
2527 }
2528
2529 /* wide pen */
2530
2531 wide_pen = CreatePen( PS_SOLID, 7, RGB( 0xff, 0, 0 ) );
2532 SelectObject( hdc, wide_pen );
2533
2534 for (i = 0; i < sizeof( wide_lines ) / sizeof( wide_lines[0] ); i++)
2535 {
2538 }
2539
2540 compare_hash(hdc, bmi, bits, "wide pen" );
2541
2542 SelectObject( hdc, orig_pen );
2543 DeleteObject( wide_pen );
2544
2545 log_brush.lbStyle = BS_SOLID;
2546 log_brush.lbColor = RGB(0xff, 0, 0);
2547 log_brush.lbHatch = 0;
2548
2550 9, &log_brush, 0, NULL );
2551 SelectObject( hdc, wide_pen );
2552
2553 Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2554 compare_hash(hdc, bmi, bits, "wide pen - flat caps, mitred" );
2555
2556 SelectObject( hdc, orig_pen );
2557 DeleteObject( wide_pen );
2558
2560 16, &log_brush, 0, NULL );
2561 SelectObject( hdc, wide_pen );
2562
2563 Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2564 compare_hash(hdc, bmi, bits, "wide pen - square caps, bevelled" );
2565
2566 SelectObject( hdc, orig_pen );
2567 DeleteObject( wide_pen );
2568
2570 9, &log_brush, 0, NULL );
2571 SelectObject( hdc, wide_pen );
2572
2574 compare_hash(hdc, bmi, bits, "wide pen - empty segments" );
2575
2576 SelectObject( hdc, orig_pen );
2577 DeleteObject( wide_pen );
2578
2579 /* brushed wide pen */
2580
2581 old_text = GetTextColor( hdc );
2582 old_bkgnd = GetBkColor( hdc );
2583 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2584 log_brush.lbStyle = BS_PATTERN;
2585 log_brush.lbColor = 0;
2586 log_brush.lbHatch = (ULONG_PTR)bmp;
2588 12, &log_brush, 0, NULL );
2589 ok( wide_pen != 0, "failed to create pen\n" );
2590 SelectObject( hdc, wide_pen );
2591 Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) );
2592
2593 for (i = 1; i < 20; i++)
2594 {
2596 i, &log_brush, 0, NULL );
2597 ok( wide_pen != 0, "failed to create pen\n" );
2598 DeleteObject( SelectObject( hdc, wide_pen ));
2599 SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2600 SetBkColor(hdc, RGB( 255 - i, i, i / 3 ) );
2601 MoveToEx( hdc, 10 * i, 10, NULL );
2602 LineTo( hdc, 10 * i, 200 + i );
2603 LineTo( hdc, 20 * i, 200 + i );
2604 }
2605 compare_hash_broken_todo(hdc, bmi, bits, "wide brushed pen", 0, dib_is_1bpp );
2606
2607 for (i = 1; i < 20; i++)
2608 {
2609 wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | (i % 5),
2610 i, &log_brush, 0, NULL );
2611 DeleteObject( SelectObject( hdc, wide_pen ));
2612 SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2613 SetBkColor(hdc, RGB( i, 255 - i, i / 3 ) );
2614 MoveToEx( hdc, 10 * i, 10, NULL );
2615 LineTo( hdc, 10 * i, 200 + i );
2616 LineTo( hdc, 20 * i, 200 + i );
2617 }
2618 compare_hash_broken_todo(hdc, bmi, bits, "dashed wide brushed pen", 0, dib_is_1bpp );
2619
2621 SetTextColor(hdc, old_text);
2622 SetBkColor(hdc, old_bkgnd);
2623 SelectObject( hdc, orig_pen );
2624
2625 /* PALETTEINDEX */
2626
2627 solid_brush = CreateSolidBrush( PALETTEINDEX(3) );
2628 solid_pen = CreatePen( PS_DASH, 1, PALETTEINDEX(5) );
2631 SelectObject( hdc, solid_brush );
2632 SelectObject( hdc, solid_pen );
2633
2634 pal->palVersion = 0x300;
2635 pal->palNumEntries = 40;
2636 for (i = 0; i < 80; i++)
2637 {
2638 entries[i].peRed = i * 3;
2639 entries[i].peGreen = i * 7;
2640 entries[i].peBlue = 128 - i;
2641 entries[i].peFlags = 0;
2642 }
2643 hpal = CreatePalette( pal );
2644 old_hpal = SelectPalette( hdc, hpal, FALSE );
2645
2646 solid_patblt( hdc, 20, 10, 10, 10, PALETTEINDEX(15) );
2647 Rectangle( hdc, 0, 0, 10, 10 );
2648 SetPaletteEntries( hpal, 0, 40, entries + 40 );
2649 Rectangle( hdc, 10, 0, 10, 10 );
2650 SelectObject( hdc, orig_brush );
2651 DeleteObject( solid_brush );
2652
2653 solid_brush = CreateHatchBrush( HS_CROSS, PALETTEINDEX(7) );
2654 DeleteObject( SelectObject( hdc, solid_brush ));
2655 PatBlt( hdc, 20, 0, 10, 10, PATCOPY );
2656 SetPaletteEntries( hpal, 0, 40, entries );
2657 PatBlt( hdc, 30, 0, 10, 10, PATCOPY );
2658 SelectObject( hdc, orig_brush );
2659 DeleteObject( solid_brush );
2660
2661 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2662 dib_brush = CreatePatternBrush( bmp );
2663 SelectObject( hdc, dib_brush );
2664 PatBlt( hdc, 40, 0, 10, 10, PATCOPY );
2665 SetPaletteEntries( hpal, 0, 40, entries + 40 );
2666 PatBlt( hdc, 50, 0, 10, 10, PATCOPY );
2667 DeleteObject( bmp );
2668 SelectObject( hdc, orig_brush );
2669 DeleteObject( dib_brush );
2670
2671 SelectPalette( hdc, old_hpal, FALSE );
2672 DeleteObject( hpal );
2673
2674 compare_hash_broken_todo(hdc, bmi, bits, "PALETTEINDEX", 0, dib_is_1bpp );
2675
2676 /* ExtFloodFill */
2677
2678 solid_patblt( hdc, 0, 0, 512, 512, RGB( 0, 0, 0xff ) );
2679 solid_patblt( hdc, 10, 10, 200, 200, RGB( 0, 0xff, 0 ) );
2680 solid_patblt( hdc, 10, 50, 50, 50, RGB( 0, 0, 0xff ) );
2681 solid_patblt( hdc, 100, 160, 50, 50, RGB( 0, 0, 0xff ) );
2682 solid_patblt( hdc, 90, 160, 70, 10, RGB( 0, 0, 0xff ) );
2683
2684 /* add a vertical 'bar' to show that the clip rgn stops the flooding */
2685 hrgn = CreateRectRgn( 180, 10, 190, 210 );
2687 DeleteObject( hrgn );
2688
2689 solid_brush = CreateSolidBrush( RGB( 0xff, 0, 0 ) );
2690 SelectObject( hdc, solid_brush );
2691
2692 ret = ExtFloodFill( hdc, 100, 100, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE );
2693 ok (ret, "got ret %d\n", ret);
2694 compare_hash(hdc, bmi, bits, "flood fill" );
2695
2697
2698 ret = ExtFloodFill( hdc, -1, -1, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE );
2699 ok (!ret, "got ret %d\n", ret);
2700
2701 SelectObject(hdc, orig_brush);
2702 SelectObject(hdc, orig_pen);
2703 DeleteObject(solid_brush);
2704 DeleteObject(wide_pen);
2705 DeleteObject(dashed_pen);
2706 DeleteObject(solid_pen);
2707}
static HRGN hrgn2
static HRGN hrgn
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
#define ULONG_PTR
Definition: config.h:101
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const GLubyte * c
Definition: glext.h:8905
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define b
Definition: ke_i.h:79
#define BI_BITFIELDS
Definition: mmreg.h:507
#define DIBINDEX(n)
Definition: mmsystem.h:932
BITMAP bmp
Definition: alphablend.c:62
BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heightDst, HDC hdcSrc, int xSrc, int ySrc, int widthSrc, int heightSrc, BLENDFUNCTION blendFunction)
#define AC_SRC_ALPHA
Definition: alphablend.c:9
BOOL WINAPI GdiGradientFill(HDC hdc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode)
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define LAYOUT_LTR
Definition: dc.c:36
static const RECT hline_clips[]
Definition: dib.c:1263
static const BITMAPINFOHEADER dib_brush_header_24
Definition: dib.c:1379
static const DWORD rop3[256]
Definition: dib.c:31
static const RECT patblt_clips[]
Definition: dib.c:1339
static const RECT bias_check[]
Definition: dib.c:1251
static BOOL rop_uses_src(DWORD rop)
Definition: dib.c:67
static const RECT vline_clips[]
Definition: dib.c:1282
static const RECT line_clips[]
Definition: dib.c:1301
static const DWORD polypoly_counts[]
Definition: dib.c:1334
static const POINT poly_lines[]
Definition: dib.c:1324
static const BYTE rle8_data[20]
Definition: dib.c:1385
static DWORD get_stride(const BITMAPINFO *bmi)
Definition: dib.c:1135
static const BITMAPINFOHEADER dib_brush_header_8888
Definition: dib.c:1378
static const BITMAPINFOHEADER dib_brush_header_4
Definition: dib.c:1382
static const DWORD four_by_four_data[16]
Definition: dib.c:1390
static const RECT wide_lines[]
Definition: dib.c:1312
static const BITMAPINFOHEADER dib_brush_header_8
Definition: dib.c:1381
static const POINT polypoly_lines[]
Definition: dib.c:1329
static const RECT rectangles[]
Definition: dib.c:1360
static const BITMAPINFOHEADER dib_brush_header_1
Definition: dib.c:1383
static void solid_patblt(HDC hdc, int x, int y, int width, int height, COLORREF color)
Definition: dib.c:1521
#define M_PI
Definition: dib.c:26
static const DWORD ddb_brush_bits[8]
Definition: dib.c:1395
static const BITMAPINFOHEADER dib_brush_header_555
Definition: dib.c:1380
static void compare_hash(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, const char *info)
Definition: dib.c:1246
static void reset_bounds(HDC hdc)
Definition: dib.c:1179
#define DWORD
Definition: nt_native.h:44
BYTE BlendOp
Definition: wingdi.h:2759
BYTE BlendFlags
Definition: wingdi.h:2760
BYTE AlphaFormat
Definition: wingdi.h:2762
BYTE SourceConstantAlpha
Definition: wingdi.h:2761
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
RGBQUAD bmiColors[1]
Definition: wingdi.h:1477
UINT lbStyle
Definition: wingdi.h:1747
ULONG_PTR lbHatch
Definition: wingdi.h:1749
COLORREF lbColor
Definition: wingdi.h:1748
UCHAR rgbRed
Definition: bootanim.c:105
int32_t INT
Definition: typedefs.h:58
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define PALETTEINDEX(i)
Definition: wingdi.h:2943
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define PS_DASH
Definition: wingdi.h:587
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define PATPAINT
Definition: wingdi.h:336
#define PS_JOIN_BEVEL
Definition: wingdi.h:597
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define RGN_DIFF
Definition: wingdi.h:358
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:861
#define HS_DIAGCROSS
Definition: wingdi.h:578
#define WHITENESS
Definition: wingdi.h:337
BOOL WINAPI SetBrushOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HBRUSH WINAPI CreateHatchBrush(_In_ int, _In_ COLORREF)
#define PS_ENDCAP_SQUARE
Definition: wingdi.h:595
#define BS_PATTERN
Definition: wingdi.h:1090
#define AC_SRC_OVER
Definition: wingdi.h:1369
#define FLOODFILLSURFACE
Definition: wingdi.h:645
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_GEOMETRIC
Definition: wingdi.h:583
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define PALETTERGB(r, g, b)
Definition: wingdi.h:2942
#define TRANSPARENT
Definition: wingdi.h:950
#define RGN_COPY
Definition: wingdi.h:357
#define HS_CROSS
Definition: wingdi.h:577
#define SRCCOPY
Definition: wingdi.h:333
#define LAYOUT_RTL
Definition: wingdi.h:1371
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
#define PATCOPY
Definition: wingdi.h:335
#define OPAQUE
Definition: wingdi.h:949
#define RGN_OR
Definition: wingdi.h:359
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
struct tagBITMAPINFO BITMAPINFO
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1107
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
#define BI_RLE8
Definition: wingdi.h:35
#define HS_HORIZONTAL
Definition: wingdi.h:580
UINT WINAPI SetPaletteEntries(_In_ HPALETTE hpal, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) CONST PALETTEENTRY *pPalEntries)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI PaintRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:250
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
#define PS_JOIN_MITER
Definition: wingdi.h:598
BOOL WINAPI ExtFloodFill(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF, _In_ UINT)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define BS_SOLID
Definition: wingdi.h:1086
#define R2_COPYPEN
Definition: wingdi.h:339
#define PS_SOLID
Definition: wingdi.h:586
BOOL WINAPI PolyPolyline(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const DWORD *asz, _In_ DWORD csz)
int WINAPI ExtSelectClipRgn(_In_ HDC, _In_opt_ HRGN, _In_ int)
#define PS_ENDCAP_FLAT
Definition: wingdi.h:596
#define SRCAND
Definition: wingdi.h:330
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)

Referenced by test_simple_graphics().

◆ draw_text()

static void draw_text ( HDC  hdc,
const BITMAPINFO bmi,
BYTE bits 
)
static

Definition at line 2878 of file dib.c.

2879{
2880 draw_text_2( hdc, bmi, bits, FALSE );
2881
2882 /* Rounding errors make these cases hard to test */
2883 if ((bmi->bmiHeader.biCompression == BI_BITFIELDS && ((DWORD*)bmi->bmiColors)[0] == 0x3f000) ||
2884 (bmi->bmiHeader.biBitCount == 16))
2885 return;
2886
2887 draw_text_2( hdc, bmi, bits, TRUE );
2888}
#define TRUE
Definition: types.h:120
static void draw_text_2(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, BOOL aa)
Definition: dib.c:2762
ULONG biCompression
Definition: precomp.h:47

Referenced by test_simple_graphics().

◆ draw_text_2()

static void draw_text_2 ( HDC  hdc,
const BITMAPINFO bmi,
BYTE bits,
BOOL  aa 
)
static

Definition at line 2762 of file dib.c.

2763{
2764 DWORD dib_size = get_dib_size(bmi), ret;
2765 LOGFONTA lf;
2766 HFONT font;
2767 GLYPHMETRICS gm;
2768 BYTE g_buf[10000];
2769 int i, stride, x, y;
2770 static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
2771 char *eto_hash = NULL, *diy_hash = NULL;
2772 static const char str[] = "Hello Wine";
2773 POINT origin, g_org;
2774 static const BYTE vals[4] = { 0x00, 0x00, 0x00, 0x00 };
2776 COLORREF text_color;
2777
2778 for(i = 0; i < dib_size; i++)
2779 bits[i] = vals[i % 4];
2780
2781 memset( &lf, 0, sizeof(lf) );
2782 strcpy( lf.lfFaceName, "Tahoma" );
2783 lf.lfHeight = 24;
2785
2786 font = CreateFontIndirectA( &lf );
2787 font = SelectObject( hdc, font );
2788
2789 GetTextMetricsA( hdc, &tm );
2790 if (!(tm.tmPitchAndFamily & TMPF_VECTOR))
2791 {
2792 skip( "skipping as a bitmap font has been selected for Tahoma.\n" );
2794 return;
2795 }
2796
2797 SetTextColor( hdc, RGB(0xff, 0x00, 0x00) );
2800 origin.x = 10;
2801 origin.y = 100;
2802
2803 ExtTextOutA( hdc, origin.x, origin.y, 0, NULL, str, strlen(str), NULL );
2804 eto_hash = hash_dib( bmi, bits );
2805
2806 for(i = 0; i < dib_size; i++)
2807 bits[i] = vals[i % 4];
2808
2809 if (bmi->bmiHeader.biBitCount <= 8) aa = FALSE;
2810
2811 text_color = GetTextColor( hdc );
2812 for (i = 0; i < strlen(str); i++)
2813 {
2814 DWORD ggo_flags = aa ? GGO_GRAY4_BITMAP : GGO_BITMAP;
2815
2816 ret = GetGlyphOutlineA( hdc, str[i], ggo_flags, &gm, 0, NULL, &identity );
2817
2818 if (ret == GDI_ERROR) continue;
2819
2820 if (ret) GetGlyphOutlineA( hdc, str[i], ggo_flags, &gm, sizeof(g_buf), g_buf, &identity );
2821
2822 g_org.x = origin.x + gm.gmptGlyphOrigin.x;
2823 g_org.y = origin.y - gm.gmptGlyphOrigin.y;
2824
2825 origin.x += gm.gmCellIncX;
2826 origin.y += gm.gmCellIncY;
2827
2828 if (!ret) continue;
2829
2830 if (aa)
2831 {
2832 stride = (gm.gmBlackBoxX + 3) & ~3;
2833
2834 for (y = 0; y < gm.gmBlackBoxY; y++)
2835 {
2836 BYTE *g_ptr = g_buf + y * stride;
2837 COLORREF val;
2838
2839 for (x = 0; x < gm.gmBlackBoxX; x++)
2840 {
2841 if (g_ptr[x] <= 1) continue;
2842 if (g_ptr[x] >= 16) val = text_color;
2843 else
2844 {
2845 val = GetPixel( hdc, g_org.x + x, g_org.y + y );
2846 val = aa_colorref( val, text_color, g_ptr[x] );
2847 }
2848 SetPixel( hdc, g_org.x + x, g_org.y + y, val );
2849 }
2850 }
2851 }
2852 else
2853 {
2854 stride = ((gm.gmBlackBoxX + 31) >> 3) & ~3;
2855
2856 for (y = 0; y < gm.gmBlackBoxY; y++)
2857 {
2858 BYTE *g_ptr = g_buf + y * stride;
2859 for (x = 0; x < gm.gmBlackBoxX; x++)
2860 {
2861 if (g_ptr[x / 8] & masks[x % 8])
2862 SetPixel( hdc, g_org.x + x, g_org.y + y, text_color );
2863 }
2864 }
2865 }
2866 }
2867
2868 diy_hash = hash_dib( bmi, bits );
2869 ok( !strcmp( eto_hash, diy_hash ), "hash mismatch - aa %d\n", aa );
2870
2871 HeapFree( GetProcessHeap(), 0, diy_hash );
2872 HeapFree( GetProcessHeap(), 0, eto_hash );
2873
2874 font = SelectObject( hdc, font );
2875 DeleteObject( font );
2876}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLsizei stride
Definition: glext.h:5848
GLuint GLfloat * val
Definition: glext.h:7180
voidpf uLong int origin
Definition: ioapi.h:144
static COLORREF aa_colorref(COLORREF dst, COLORREF text, BYTE glyph)
Definition: dib.c:2750
static const BYTE masks[8]
Definition: dib.c:2760
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
Definition: mk_font.cpp:20
const WCHAR * str
BYTE lfQuality
Definition: dimm.idl:53
LONG lfHeight
Definition: dimm.idl:42
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
short gmCellIncX
Definition: wingdi.h:2445
UINT gmBlackBoxY
Definition: wingdi.h:2443
UINT gmBlackBoxX
Definition: wingdi.h:2442
short gmCellIncY
Definition: wingdi.h:2446
POINT gmptGlyphOrigin
Definition: wingdi.h:2444
Definition: wingdi.h:2472
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
Definition: time.h:68
#define ANTIALIASED_QUALITY
Definition: wingdi.h:440
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define TMPF_VECTOR
Definition: wingdi.h:1312
#define GDI_ERROR
Definition: wingdi.h:1309
#define TA_BASELINE
Definition: wingdi.h:928
#define GGO_BITMAP
Definition: wingdi.h:849
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define GGO_GRAY4_BITMAP
Definition: wingdi.h:853
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:439
DWORD WINAPI GetGlyphOutlineA(_In_ HDC hdc, _In_ UINT uChar, _In_ UINT fuFormat, _Out_ LPGLYPHMETRICS lpgm, _In_ DWORD cjBuffer, _Out_writes_bytes_opt_(cjBuffer) LPVOID pvBuffer, _In_ CONST MAT2 *lpmat2)

Referenced by draw_text().

◆ get_dib_size()

static DWORD get_dib_size ( const BITMAPINFO bmi)
inlinestatic

Definition at line 1140 of file dib.c.

1141{
1142 return get_stride(bmi) * abs(bmi->bmiHeader.biHeight);
1143}
#define abs(i)
Definition: fconv.c:206

Referenced by compare_hash_broken_todo(), draw_graphics(), draw_text_2(), and hash_dib().

◆ get_range()

static void get_range ( BYTE  alpha,
DWORD  text_comp,
BYTE min_comp,
BYTE max_comp 
)
inlinestatic

Definition at line 2718 of file dib.c.

2719{
2720 *min_comp = (ramp[alpha] * text_comp) / 0xff;
2721 *max_comp = ramp[16 - alpha] + ((0xff - ramp[16 - alpha]) * text_comp) / 0xff;
2722}
static const BYTE ramp[17]
Definition: dib.c:2709

Referenced by aa_comp().

◆ get_stride()

static DWORD get_stride ( const BITMAPINFO bmi)
inlinestatic

Definition at line 1135 of file dib.c.

1136{
1137 return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3;
1138}

Referenced by draw_graphics(), and get_dib_size().

◆ hash_dib()

static char * hash_dib ( const BITMAPINFO bmi,
const void bits 
)
static

Definition at line 1145 of file dib.c.

1146{
1147 DWORD dib_size = get_dib_size(bmi);
1149 char *buf;
1150 BYTE hash_buf[20];
1151 DWORD hash_size = sizeof(hash_buf);
1152 int i;
1153 static const char *hex = "0123456789abcdef";
1154
1155 if(!crypt_prov) return NULL;
1156
1157 if(!CryptCreateHash(crypt_prov, CALG_SHA1, 0, 0, &hash)) return NULL;
1158
1159 CryptHashData(hash, bits, dib_size, 0);
1160
1161 CryptGetHashParam(hash, HP_HASHVAL, NULL, &hash_size, 0);
1162 if(hash_size != sizeof(hash_buf)) return NULL;
1163
1164 CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
1166
1167 buf = HeapAlloc(GetProcessHeap(), 0, hash_size * 2 + 1);
1168
1169 for(i = 0; i < hash_size; i++)
1170 {
1171 buf[i * 2] = hex[hash_buf[i] >> 4];
1172 buf[i * 2 + 1] = hex[hash_buf[i] & 0xf];
1173 }
1174 buf[i * 2] = '\0';
1175
1176 return buf;
1177}
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:740
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1610
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:890
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1771
#define HeapAlloc
Definition: compat.h:733
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int hex(char ch)
static HCRYPTPROV crypt_prov
Definition: dib.c:29
#define CALG_SHA1
Definition: wincrypt.h:1807
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:50
#define HP_HASHVAL
Definition: wincrypt.h:2183

Referenced by compare_hash_broken_todo(), and draw_text_2().

◆ reset_bounds()

static void reset_bounds ( HDC  hdc)
static

Definition at line 1179 of file dib.c.

1180{
1183}
static const RECT graphics_bounds[]
Definition: dib.c:1061
#define DCB_ENABLE
Definition: wingdi.h:686
UINT WINAPI SetBoundsRect(_In_ HDC, _In_opt_ LPCRECT, _In_ UINT)

Referenced by draw_graphics().

◆ rop_uses_src()

static BOOL rop_uses_src ( DWORD  rop)
inlinestatic

Definition at line 67 of file dib.c.

68{
69 return (((rop & 0xcc0000) >> 2) != (rop & 0x330000));
70}
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124

Referenced by draw_graphics().

◆ solid_patblt()

static void solid_patblt ( HDC  hdc,
int  x,
int  y,
int  width,
int  height,
COLORREF  color 
)
inlinestatic

Definition at line 1521 of file dib.c.

1522{
1523 HBRUSH brush = CreateSolidBrush( color );
1524 brush = SelectObject( hdc, brush );
1525 PatBlt( hdc, x, y, width, height, PATCOPY );
1526 DeleteObject( SelectObject( hdc, brush ) );
1527}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint color
Definition: glext.h:6243

Referenced by draw_graphics().

◆ START_TEST()

START_TEST ( dib  )

Definition at line 3250 of file dib.c.

3251{
3253
3255
3257}
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
static void test_simple_graphics(void)
Definition: dib.c:2890
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069

◆ test_simple_graphics()

static void test_simple_graphics ( void  )
static

Definition at line 2890 of file dib.c.

2891{
2892 char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
2893 BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
2894 RGBQUAD *colors = bmi->bmiColors;
2895 DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
2896 HDC mem_dc;
2897 BYTE *bits;
2898 HBITMAP dib, orig_bm;
2899 DIBSECTION ds;
2900 HPALETTE default_palette, old_hpal;
2901 int i;
2902
2903 mem_dc = CreateCompatibleDC(NULL);
2904
2905 /* a8r8g8b8 */
2906 trace("8888\n");
2907 memset(bmi, 0, sizeof(bmibuf));
2908 bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
2909 bmi->bmiHeader.biHeight = 512;
2910 bmi->bmiHeader.biWidth = 512;
2911 bmi->bmiHeader.biBitCount = 32;
2912 bmi->bmiHeader.biPlanes = 1;
2914
2915 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2916 ok(dib != NULL, "ret NULL\n");
2917 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2918 ok(ds.dsBitfields[0] == 0, "got %08x\n", ds.dsBitfields[0]);
2919 ok(ds.dsBitfields[1] == 0, "got %08x\n", ds.dsBitfields[1]);
2920 ok(ds.dsBitfields[2] == 0, "got %08x\n", ds.dsBitfields[2]);
2921 ok(ds.dsBmih.biCompression == BI_RGB, "got %x\n", ds.dsBmih.biCompression);
2922
2923 orig_bm = SelectObject(mem_dc, dib);
2924
2925 default_palette = create_default_palette( 8 );
2926 old_hpal = SelectPalette( mem_dc, default_palette, FALSE );
2927
2928 dst_format = "8888";
2930 draw_graphics(mem_dc, bmi, bits);
2931 draw_text(mem_dc, bmi, bits);
2932
2933 SelectObject(mem_dc, orig_bm);
2935
2936 /* a8r8g8b8 - bitfields. Should be the same as the regular 32 bit case.*/
2937 trace("8888 - bitfields\n");
2938 bmi->bmiHeader.biBitCount = 32;
2940 bit_fields[0] = 0xff0000;
2941 bit_fields[1] = 0x00ff00;
2942 bit_fields[2] = 0x0000ff;
2943
2944 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2945 ok(dib != NULL, "ret NULL\n");
2946 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2947 ok(ds.dsBitfields[0] == 0xff0000, "got %08x\n", ds.dsBitfields[0]);
2948 ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
2949 ok(ds.dsBitfields[2] == 0x0000ff, "got %08x\n", ds.dsBitfields[2]);
2950 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2951
2952 orig_bm = SelectObject(mem_dc, dib);
2953 SelectPalette( mem_dc, default_palette, FALSE );
2954
2955 dst_format = "8888 - bitfields";
2957 draw_graphics(mem_dc, bmi, bits);
2958 draw_text(mem_dc, bmi, bits);
2959
2960 SelectObject(mem_dc, orig_bm);
2962
2963 /* a8b8g8r8. */
2964 trace("a8b8g8r8\n");
2965 bmi->bmiHeader.biBitCount = 32;
2967 bit_fields[0] = 0x0000ff;
2968 bit_fields[1] = 0x00ff00;
2969 bit_fields[2] = 0xff0000;
2970
2971 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2972 ok(dib != NULL, "ret NULL\n");
2973 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
2974 ok(ds.dsBitfields[0] == 0x0000ff, "got %08x\n", ds.dsBitfields[0]);
2975 ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
2976 ok(ds.dsBitfields[2] == 0xff0000, "got %08x\n", ds.dsBitfields[2]);
2977 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
2978
2979 orig_bm = SelectObject(mem_dc, dib);
2980
2981 dst_format = "a8b8g8r8";
2983 draw_graphics(mem_dc, bmi, bits);
2984 draw_text(mem_dc, bmi, bits);
2985
2986 SelectObject(mem_dc, orig_bm);
2988
2989 /* r10g10b10. */
2990 trace("r10g10b10\n");
2991 bmi->bmiHeader.biBitCount = 32;
2993 bit_fields[0] = 0x3ff00000;
2994 bit_fields[1] = 0x000ffc00;
2995 bit_fields[2] = 0x000003ff;
2996
2997 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
2998 ok(dib != NULL, "ret NULL\n");
2999 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3000 ok(ds.dsBitfields[0] == 0x3ff00000, "got %08x\n", ds.dsBitfields[0]);
3001 ok(ds.dsBitfields[1] == 0x000ffc00, "got %08x\n", ds.dsBitfields[1]);
3002 ok(ds.dsBitfields[2] == 0x000003ff, "got %08x\n", ds.dsBitfields[2]);
3003 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3004
3005 orig_bm = SelectObject(mem_dc, dib);
3006
3007 dst_format = "r10g10b10";
3009 draw_graphics(mem_dc, bmi, bits);
3010 draw_text(mem_dc, bmi, bits);
3011
3012 SelectObject(mem_dc, orig_bm);
3014
3015 /* r6g6b6. */
3016 trace("r6g6b6\n");
3017 bmi->bmiHeader.biBitCount = 32;
3019 bit_fields[0] = 0x0003f000;
3020 bit_fields[1] = 0x00000fc0;
3021 bit_fields[2] = 0x0000003f;
3022
3023 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3024 ok(dib != NULL, "ret NULL\n");
3025 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3026 ok(ds.dsBitfields[0] == 0x0003f000, "got %08x\n", ds.dsBitfields[0]);
3027 ok(ds.dsBitfields[1] == 0x00000fc0, "got %08x\n", ds.dsBitfields[1]);
3028 ok(ds.dsBitfields[2] == 0x0000003f, "got %08x\n", ds.dsBitfields[2]);
3029 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3030
3031 orig_bm = SelectObject(mem_dc, dib);
3032
3033 dst_format = "r6g6b6";
3035 draw_graphics(mem_dc, bmi, bits);
3036 draw_text(mem_dc, bmi, bits);
3037
3038 SelectObject(mem_dc, orig_bm);
3040
3041 /* 24 */
3042 trace("24\n");
3043 bmi->bmiHeader.biBitCount = 24;
3045
3046 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3047 ok(dib != NULL, "ret NULL\n");
3048 orig_bm = SelectObject(mem_dc, dib);
3049
3050 dst_format = "24";
3052 draw_graphics(mem_dc, bmi, bits);
3053 draw_text(mem_dc, bmi, bits);
3054
3055 SelectObject(mem_dc, orig_bm);
3057
3058 /* r5g5b5 */
3059 trace("555\n");
3060 bmi->bmiHeader.biBitCount = 16;
3062
3063 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3064 ok(dib != NULL, "ret NULL\n");
3065 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3066 ok(ds.dsBitfields[0] == 0x7c00, "got %08x\n", ds.dsBitfields[0]);
3067 ok(ds.dsBitfields[1] == 0x03e0, "got %08x\n", ds.dsBitfields[1]);
3068 ok(ds.dsBitfields[2] == 0x001f, "got %08x\n", ds.dsBitfields[2]);
3069 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3070
3071 orig_bm = SelectObject(mem_dc, dib);
3072
3073 dst_format = "r5g5b5";
3075 draw_graphics(mem_dc, bmi, bits);
3076 draw_text(mem_dc, bmi, bits);
3077
3078 SelectObject(mem_dc, orig_bm);
3080
3081 /* r4g4b4 */
3082 trace("444\n");
3083 bmi->bmiHeader.biBitCount = 16;
3085 bit_fields[0] = 0x0f00;
3086 bit_fields[1] = 0x00f0;
3087 bit_fields[2] = 0x000f;
3088 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3089 ok(dib != NULL, "ret NULL\n");
3090 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3091 ok(ds.dsBitfields[0] == 0x0f00, "got %08x\n", ds.dsBitfields[0]);
3092 ok(ds.dsBitfields[1] == 0x00f0, "got %08x\n", ds.dsBitfields[1]);
3093 ok(ds.dsBitfields[2] == 0x000f, "got %08x\n", ds.dsBitfields[2]);
3094 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
3095
3096 orig_bm = SelectObject(mem_dc, dib);
3097
3098 dst_format = "r4g4b4";
3100 draw_graphics(mem_dc, bmi, bits);
3101 draw_text(mem_dc, bmi, bits);
3102
3103 SelectObject(mem_dc, orig_bm);
3105
3106 /* 8 color */
3107 trace("8 color\n");
3108 bmi->bmiHeader.biBitCount = 8;
3110 bmi->bmiHeader.biClrUsed = 236;
3111 for (i = 0; i < 236; i++)
3112 {
3113 colors[i].rgbRed = (i & 0x07) << 5;
3114 colors[i].rgbGreen = (i & 0x38) << 2;
3115 colors[i].rgbBlue = i & 0xc0;
3116 }
3117 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3118 ok(dib != NULL, "ret NULL\n");
3119
3120 orig_bm = SelectObject(mem_dc, dib);
3121
3122 dst_format = "8 color";
3124 draw_graphics(mem_dc, bmi, bits);
3125 draw_text(mem_dc, bmi, bits);
3126
3127 SelectObject(mem_dc, orig_bm);
3129
3130 /* 8 grayscale */
3131 trace("8 grayscale\n");
3132 bmi->bmiHeader.biBitCount = 8;
3134 bmi->bmiHeader.biClrUsed = 256;
3135 for (i = 0; i < 256; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i;
3136
3137 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3138 ok(dib != NULL, "ret NULL\n");
3139
3140 orig_bm = SelectObject(mem_dc, dib);
3141
3142 dst_format = "8 grayscale";
3144 draw_graphics(mem_dc, bmi, bits);
3145 draw_text(mem_dc, bmi, bits);
3146
3147 SelectObject(mem_dc, orig_bm);
3149
3150 /* 8 */
3151 trace("8\n");
3152 bmi->bmiHeader.biBitCount = 8;
3154 bmi->bmiHeader.biClrUsed = 5;
3155 colors[0].rgbRed = 0xff;
3156 colors[0].rgbGreen = 0xff;
3157 colors[0].rgbBlue = 0xff;
3158 colors[1].rgbRed = 0;
3159 colors[1].rgbGreen = 0;
3160 colors[1].rgbBlue = 0;
3161 colors[2].rgbRed = 0xff;
3162 colors[2].rgbGreen = 0;
3163 colors[2].rgbBlue = 0;
3164 colors[3].rgbRed = 0;
3165 colors[3].rgbGreen = 0xff;
3166 colors[3].rgbBlue = 0;
3167 colors[4].rgbRed = 0;
3168 colors[4].rgbGreen = 0;
3169 colors[4].rgbBlue = 0xff;
3170
3171 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3172 ok(dib != NULL, "ret NULL\n");
3173
3174 orig_bm = SelectObject(mem_dc, dib);
3175
3176 dst_format = "8";
3178 draw_graphics(mem_dc, bmi, bits);
3179 draw_text(mem_dc, bmi, bits);
3180
3181 SelectObject(mem_dc, orig_bm);
3183
3184 /* 4 */
3185 trace("4\n");
3186 bmi->bmiHeader.biBitCount = 4;
3187
3188 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3189 ok(dib != NULL, "ret NULL\n");
3190
3191 orig_bm = SelectObject(mem_dc, dib);
3193
3194 dst_format = "4";
3196 draw_graphics(mem_dc, bmi, bits);
3197 draw_text(mem_dc, bmi, bits);
3198
3199 SelectObject(mem_dc, orig_bm);
3201
3202 /* 4 grayscale */
3203 trace("4 grayscale\n");
3204 bmi->bmiHeader.biClrUsed = 16;
3205 for (i = 0; i < 16; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i * 17;
3206
3207 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3208 ok(dib != NULL, "ret NULL\n");
3209
3210 orig_bm = SelectObject(mem_dc, dib);
3211
3212 dst_format = "4 grayscale";
3214 draw_graphics(mem_dc, bmi, bits);
3215 draw_text(mem_dc, bmi, bits);
3216
3217 SelectObject(mem_dc, orig_bm);
3219
3220 /* 1 */
3221 trace("1\n");
3222 bmi->bmiHeader.biBitCount = 1;
3223 bmi->bmiHeader.biClrUsed = 2;
3224
3225 colors[0].rgbRed = 0x00;
3226 colors[0].rgbGreen = 0x01;
3227 colors[0].rgbBlue = 0xff;
3228 colors[1].rgbRed = 0xff;
3229 colors[1].rgbGreen = 0x00;
3230 colors[1].rgbBlue = 0x00;
3231
3232 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3233 ok(dib != NULL, "ret NULL\n");
3234
3235 orig_bm = SelectObject(mem_dc, dib);
3237
3238 dst_format = "1";
3240 draw_graphics(mem_dc, bmi, bits);
3241 draw_text(mem_dc, bmi, bits);
3242
3243 DeleteObject( SelectPalette( mem_dc, old_hpal, FALSE ));
3244 SelectObject(mem_dc, orig_bm);
3246
3247 DeleteDC(mem_dc);
3248}
#define trace
Definition: atltest.h:70
#define ds
Definition: i386-dis.c:443
#define bits
Definition: infblock.c:15
static const char * sha1_graphics_r6g6b6[]
Definition: dib.c:356
static const char * sha1_graphics_4[]
Definition: dib.c:849
static const char * sha1_graphics_r5g5b5[]
Definition: dib.c:498
static const char * sha1_graphics_a8r8g8b8[]
Definition: dib.c:72
static const char * sha1_graphics_8_grayscale[]
Definition: dib.c:708
static const char * sha1_graphics_24[]
Definition: dib.c:427
static const char * sha1_graphics_a8r8g8b8_bitfields[]
Definition: dib.c:143
static const char * sha1_graphics_a8b8g8r8[]
Definition: dib.c:214
static const char * sha1_graphics_r10g10b10[]
Definition: dib.c:285
static void draw_graphics(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
Definition: dib.c:1529
static void draw_text(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
Definition: dib.c:2878
static const char * sha1_graphics_8_color[]
Definition: dib.c:638
static const char * sha1_graphics_r4g4b4[]
Definition: dib.c:568
static const char * sha1_graphics_1[]
Definition: dib.c:989
static const char * sha1_graphics_8[]
Definition: dib.c:779
static HPALETTE create_default_palette(int bpp)
Definition: dib.c:1479
static const char * sha1_graphics_4_grayscale[]
Definition: dib.c:919
static const BYTE dib[]
Definition: ole2.c:201
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)

Referenced by START_TEST().

Variable Documentation

◆ bias_check

const RECT bias_check[]
static
Initial value:
=
{
{100, 100, 200, 150},
{100, 100, 150, 200},
{100, 100, 50, 200},
{100, 100, 0, 150},
{100, 100, 0, 50},
{100, 100, 50, 0},
{100, 100, 150, 0},
{100, 100, 200, 50}
}

Definition at line 1251 of file dib.c.

Referenced by draw_graphics().

◆ crypt_prov

HCRYPTPROV crypt_prov
static

Definition at line 29 of file dib.c.

Referenced by CSignedMsgData_ConstructSignerHandles(), hash_dib(), and START_TEST().

◆ current_bounds

const RECT* current_bounds
static

Definition at line 1132 of file dib.c.

Referenced by compare_bounds(), and reset_bounds().

◆ current_sha1

const char** current_sha1
static

Definition at line 1131 of file dib.c.

Referenced by compare_hash_broken_todo(), and test_simple_graphics().

◆ ddb_brush_bits

const DWORD ddb_brush_bits[8]
static
Initial value:
= { 0x11112222, 0x33334444, 0x55556666, 0x77778888,
0xaaaaaaaa, 0x00000000, 0x98765432, 0xabcdef00 }

Definition at line 1395 of file dib.c.

Referenced by draw_graphics().

◆ default_palette_1

const RGBQUAD default_palette_1[2]
static
Initial value:
=
{
{ 0x00, 0x00, 0x00 }, { 0xff, 0xff, 0xff }
}

Definition at line 1398 of file dib.c.

Referenced by create_default_palette().

◆ default_palette_4

const RGBQUAD default_palette_4[16]
static
Initial value:
=
{
{ 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x80 }, { 0x00, 0x80, 0x00 }, { 0x00, 0x80, 0x80 },
{ 0x80, 0x00, 0x00 }, { 0x80, 0x00, 0x80 }, { 0x80, 0x80, 0x00 }, { 0x80, 0x80, 0x80 },
{ 0xc0, 0xc0, 0xc0 }, { 0x00, 0x00, 0xff }, { 0x00, 0xff, 0x00 }, { 0x00, 0xff, 0xff },
{ 0xff, 0x00, 0x00 }, { 0xff, 0x00, 0xff }, { 0xff, 0xff, 0x00 }, { 0xff, 0xff, 0xff },
}

Definition at line 1403 of file dib.c.

Referenced by create_default_palette().

◆ default_palette_8

const RGBQUAD default_palette_8[256]
static

Definition at line 1411 of file dib.c.

Referenced by create_default_palette().

◆ dib_brush_header_1

const BITMAPINFOHEADER dib_brush_header_1 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 1, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1383 of file dib.c.

Referenced by draw_graphics().

◆ dib_brush_header_24

const BITMAPINFOHEADER dib_brush_header_24 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 24, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1379 of file dib.c.

Referenced by draw_graphics().

◆ dib_brush_header_4

const BITMAPINFOHEADER dib_brush_header_4 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 4, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1382 of file dib.c.

Referenced by draw_graphics().

◆ dib_brush_header_555

const BITMAPINFOHEADER dib_brush_header_555 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 16, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1380 of file dib.c.

Referenced by draw_graphics().

◆ dib_brush_header_8

const BITMAPINFOHEADER dib_brush_header_8 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 8, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1381 of file dib.c.

Referenced by draw_graphics().

◆ dib_brush_header_8888

const BITMAPINFOHEADER dib_brush_header_8888 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 32, BI_RGB, 0, 0, 0, 0, 0}
static

Definition at line 1378 of file dib.c.

Referenced by draw_graphics().

◆ dst_format

◆ four_by_four_data

const DWORD four_by_four_data[16]
static
Initial value:
= { 0x000000, 0xff0000, 0x00ff00, 0x0000ff,
0xffffff, 0x00ffff, 0xff00ff, 0xffff00,
0x000000, 0xff0000, 0x00ff00, 0x0000ff,
0xffffff, 0x00ffff, 0xff00ff, 0xffff00 }

Definition at line 1390 of file dib.c.

Referenced by draw_graphics().

◆ graphics_bounds

const RECT graphics_bounds[]
static

Definition at line 1061 of file dib.c.

Referenced by GdipDrawImagePointsRect(), reset_bounds(), and SOFTWARE_GdipFillRegion().

◆ hline_clips

const RECT hline_clips[]
static
Initial value:
=
{
{120, 120, 140, 120},
{100, 122, 140, 122},
{ 99, 124, 140, 124},
{120, 126, 200, 126},
{120, 128, 201, 128},
{ 99, 130, 201, 130},
{120, 100, 140, 100},
{120, 99, 140, 99},
{120, 199, 140, 199},
{120, 200, 140, 200},
{120, 132, 310, 132},
{ 10, 134, 101, 134},
{ 10, 136, 100, 136},
{199, 138, 220, 138},
{200, 140, 220, 140}
}

Definition at line 1263 of file dib.c.

Referenced by draw_graphics().

◆ line_clips

const RECT line_clips[]
static
Initial value:
=
{
{ 90, 110, 310, 120},
{ 90, 120, 295, 130},
{ 90, 190, 110, 240},
{ 90, 130, 100, 135},
{ 90, 132, 101, 137},
{200, 140, 210, 141},
{199, 142, 210, 143}
}

Definition at line 1301 of file dib.c.

Referenced by draw_graphics().

◆ masks

const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}
static

◆ patblt_clips

const RECT patblt_clips[]
static
Initial value:
=
{
{120, 120, 140, 126},
{100, 130, 140, 136},
{ 99, 140, 140, 146},
{180, 130, 200, 136},
{180, 140, 201, 146},
{120, 100, 130, 110},
{140, 99, 150, 110},
{120, 180, 130, 200},
{140, 180, 150, 201},
{199, 150, 210, 156},
{200, 160, 210, 166},
{ 90, 150, 101, 156},
{ 90, 160, 100, 166},
{160, 90, 166, 101},
{170, 90, 176, 101},
{160, 199, 166, 210},
{170, 200, 176, 210},
}

Definition at line 1339 of file dib.c.

Referenced by draw_graphics().

◆ poly_lines

const POINT poly_lines[]
static
Initial value:
=
{
{100, 100}, {200, 100}, {200, 200}, {100, 200}
}

Definition at line 1324 of file dib.c.

Referenced by draw_graphics().

◆ polypoly_counts

const DWORD polypoly_counts[]
static
Initial value:
=
{
sizeof(polypoly_lines)/sizeof(polypoly_lines[0])
}

Definition at line 1334 of file dib.c.

Referenced by draw_graphics().

◆ polypoly_lines

const POINT polypoly_lines[]
static
Initial value:
=
{
{100, 100}, {200, 100}, {200, 100}, {200, 200}
}

Definition at line 1329 of file dib.c.

Referenced by draw_graphics().

◆ ramp

◆ rectangles

const RECT rectangles[]
static
Initial value:
=
{
{10, 11, 100, 101},
{250, 100, 350, 10},
{120, 10, 120, 20},
{120, 10, 130, 10},
{120, 40, 121, 41},
{130, 50, 132, 52},
{140, 60, 143, 63},
{150, 70, 154, 74},
{120, 20, 121, 30},
{130, 20, 132, 30},
{140, 20, 143, 30},
{200, 20, 210, 21},
{200, 30, 210, 32},
{200, 40, 210, 43}
}

Definition at line 1360 of file dib.c.

Referenced by draw_graphics().

◆ rle8_data

const BYTE rle8_data[20]
static
Initial value:
= { 0x03, 0x02, 0x04, 0xf0, 0x00, 0x00,
0x00, 0x03, 0x04, 0x05, 0x06, 0x00,
0x00, 0x02, 0x01, 0x02, 0x05, 0x80,
0x00, 0x01 }

Definition at line 1385 of file dib.c.

Referenced by draw_graphics(), test_SetDIBits_RLE8(), and test_SetDIBitsToDevice_RLE8().

◆ rop3

const DWORD rop3[256]
static

Definition at line 31 of file dib.c.

Referenced by draw_graphics().

◆ sha1_graphics_1

const char* sha1_graphics_1[]
static

Definition at line 989 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_24

const char* sha1_graphics_24[]
static

Definition at line 427 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_4

const char* sha1_graphics_4[]
static

Definition at line 849 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_4_grayscale

const char* sha1_graphics_4_grayscale[]
static

Definition at line 919 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8

const char* sha1_graphics_8[]
static

Definition at line 779 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8_color

const char* sha1_graphics_8_color[]
static

Definition at line 638 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8_grayscale

const char* sha1_graphics_8_grayscale[]
static

Definition at line 708 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8b8g8r8

const char* sha1_graphics_a8b8g8r8[]
static

Definition at line 214 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8r8g8b8

const char* sha1_graphics_a8r8g8b8[]
static

Definition at line 72 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8r8g8b8_bitfields

const char* sha1_graphics_a8r8g8b8_bitfields[]
static

Definition at line 143 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r10g10b10

const char* sha1_graphics_r10g10b10[]
static

Definition at line 285 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r4g4b4

const char* sha1_graphics_r4g4b4[]
static

Definition at line 568 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r5g5b5

const char* sha1_graphics_r5g5b5[]
static

Definition at line 498 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r6g6b6

const char* sha1_graphics_r6g6b6[]
static

Definition at line 356 of file dib.c.

Referenced by test_simple_graphics().

◆ vline_clips

const RECT vline_clips[]
static
Initial value:
=
{
{120, 120, 120, 140},
{100, 120, 100, 140},
{ 99, 120, 99, 140},
{199, 120, 199, 140},
{200, 120, 200, 140},
{122, 99, 122, 201},
{124, 100, 124, 140},
{126, 99, 126, 140},
{128, 120, 128, 200},
{130, 120, 130, 201},
{132, 12, 132, 140},
{134, 90, 134, 101},
{136, 90, 136, 100},
{138, 199, 138, 220},
{140, 200, 140, 220}
}

Definition at line 1282 of file dib.c.

Referenced by draw_graphics().

◆ wide_lines

const RECT wide_lines[]
static
Initial value:
=
{
{100, 10, 200, 10},
{100, 21, 200, 21},
{200, 40, 100, 40},
{200, 61, 100, 61},
{ 10, 100, 10, 200},
{ 21, 100, 21, 200},
{ 40, 200, 40, 100},
{ 61, 200, 61, 100},
}

Definition at line 1312 of file dib.c.

Referenced by draw_graphics().