ReactOS 0.4.17-dev-116-ga4b6fe9
dib.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wincrypt.h"
#include "mmsystem.h"
#include "wine/test.h"
Include dependency graph for dib.c:

Go to the source code of this file.

Functions

static BOOL rop_uses_src (DWORD rop)
 
static DWORD get_stride (const BITMAPINFO *bmi)
 
static DWORD get_dib_size (const BITMAPINFO *bmi)
 
static void reset_bits (HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
 
static charhash_dib (HDC hdc, 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 charsha1_graphics_1_ddb []
 
static const charsha1_graphics_1_ddb_inverted []
 
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}
 

Function Documentation

◆ aa_colorref()

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

Definition at line 2998 of file dib.c.

2999{
3000 COLORREF ret;
3001
3002 ret = RGB( aa_comp( GetRValue(dst), GetRValue(text), glyph ),
3003 aa_comp( GetGValue(dst), GetGValue(text), glyph ),
3004 aa_comp( GetBValue(dst), GetBValue(text), glyph ) );
3005 return ret;
3006}
const WCHAR * text
Definition: package.c:1794
#define RGB(r, g, b)
Definition: precomp.h:67
#define GetBValue(quad)
Definition: precomp.h:71
#define GetGValue(quad)
Definition: precomp.h:70
#define GetRValue(quad)
Definition: precomp.h:69
return ret
Definition: mutex.c:146
GLenum GLenum dst
Definition: glext.h:6340
static BYTE aa_comp(BYTE dst, BYTE text, BYTE alpha)
Definition: dib.c:2972
DWORD COLORREF
Definition: windef.h:100

Referenced by draw_text_2().

◆ aa_comp()

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

Definition at line 2972 of file dib.c.

2973{
2974 BYTE min_comp, max_comp;
2975
2976 if (alpha == 16) return text;
2977 if (alpha <= 1) return dst;
2978 if (text == dst) return dst;
2979
2980 get_range( alpha, text, &min_comp, &max_comp );
2981
2982 if (dst > text)
2983 {
2984 DWORD diff = dst - text;
2985 DWORD range = max_comp - text;
2986 dst = text + (diff * range ) / (0xff - text);
2987 return dst;
2988 }
2989 else
2990 {
2991 DWORD diff = text - dst;
2992 DWORD range = text - min_comp ;
2993 dst = text - (diff * range) / text;
2994 return dst;
2995 }
2996}
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:2966
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 1411 of file dib.c.

1412{
1413 RECT rect;
1414
1416
1417 if (current_bounds->left == -1 &&
1418 current_bounds->top == -1 &&
1419 current_bounds->right == -1 &&
1420 current_bounds->bottom == -1)
1421 {
1422 ok( 0, "missing bounds, got %s,\n", wine_dbgstr_rect( &rect ));
1423 return;
1424 }
1425
1426 ok( EqualRect( current_bounds, &rect ), "%s: %s: expected bounds %s got %s\n", dst_format, info,
1429}
#define ok(value,...)
Definition: atltest.h:57
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
RECT rect
Definition: combotst.c:67
HDC hdc
Definition: main.c:9
static const char * dst_format
Definition: dib.c:1339
static const RECT * current_bounds
Definition: dib.c:1338
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#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 1472 of file dib.c.

1473{
1475}
#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:1431

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 1431 of file dib.c.

1432{
1433 char *hash = hash_dib(hdc, bmi, bits);
1434 BOOL ok_cond;
1435 int i;
1436
1437 /* reset the bits for the next test */
1438 reset_bits( hdc, bmi, bits );
1439
1440 if(!hash)
1441 {
1442 skip("SHA1 hashing unavailable on this platform\n");
1443 return;
1444 }
1445
1446 for(i = 0; i <= num_broken; i++)
1447 {
1448 if(current_sha1[i] == NULL)
1449 {
1450 ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash);
1451 free(hash);
1452 return;
1453 }
1454 }
1455
1456 ok_cond = !strcmp(hash, *current_sha1);
1457
1458 for(i = 1; i <= num_broken; i++)
1459 ok_cond = ok_cond || broken( !strcmp(hash, current_sha1[i]) );
1460
1462 ok( ok_cond, "%s: %s: expected hash %s got %s\n",
1464
1465 current_sha1 += num_broken + 1;
1466
1467 free( hash );
1468
1470}
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
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
#define todo_wine_if(is_todo)
Definition: minitest.h:81
BOOL todo
Definition: filedlg.c:313
static char * hash_dib(HDC hdc, const BITMAPINFO *bmi, const void *bits)
Definition: dib.c:1364
static const char ** current_sha1
Definition: dib.c:1337
static void reset_bits(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
Definition: dib.c:1351
static void compare_bounds(HDC hdc, const char *info)
Definition: dib.c:1411
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 1705 of file dib.c.

1706{
1707 char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)];
1708 LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
1709 PALETTEENTRY *entries = pal->palPalEntry;
1710 int i;
1711
1712 pal->palVersion = 0x300;
1713 pal->palNumEntries = 1 << bpp;
1714 switch (bpp)
1715 {
1716 case 1:
1717 for (i = 0; i < 2; i++)
1718 {
1719 entries[i].peRed = default_palette_1[i].rgbRed;
1720 entries[i].peGreen = default_palette_1[i].rgbGreen;
1721 entries[i].peBlue = default_palette_1[i].rgbBlue;
1722 entries[i].peFlags = 0;
1723 }
1724 break;
1725 case 4:
1726 for (i = 0; i < 16; i++)
1727 {
1728 entries[i].peRed = default_palette_4[i].rgbRed;
1729 entries[i].peGreen = default_palette_4[i].rgbGreen;
1730 entries[i].peBlue = default_palette_4[i].rgbBlue;
1731 entries[i].peFlags = 0;
1732 }
1733 break;
1734 case 8:
1735 for (i = 0; i < 256; i++)
1736 {
1737 entries[i].peRed = default_palette_8[i].rgbRed;
1738 entries[i].peGreen = default_palette_8[i].rgbGreen;
1739 entries[i].peBlue = default_palette_8[i].rgbBlue;
1740 entries[i].peFlags = 0;
1741 }
1742 break;
1743 }
1744 return CreatePalette( pal );
1745}
DWORD bpp
Definition: surface.c:185
static const RGBQUAD default_palette_4[16]
Definition: dib.c:1629
static const RGBQUAD default_palette_1[2]
Definition: dib.c:1624
static const RGBQUAD default_palette_8[256]
Definition: dib.c:1637
WORD palNumEntries
Definition: wingdi.h:2280
WORD palVersion
Definition: wingdi.h:2279
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 1755 of file dib.c.

1756{
1757 char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)];
1758 LOGPALETTE *pal = (LOGPALETTE *)pal_buffer;
1759 PALETTEENTRY *entries = pal->palPalEntry;
1760 HPEN solid_pen, dashed_pen, wide_pen, orig_pen;
1761 LOGBRUSH log_brush;
1762 HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush;
1763 HBITMAP bmp;
1764 INT i, j, x, y, hatch_style;
1765 HDC src_dc;
1766 HRGN hrgn, hrgn2;
1767 BYTE dib_src_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
1768 BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */
1769 BITMAPINFO *src_bi = (BITMAPINFO*)dib_src_buf;
1770 BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf;
1771 RGBQUAD *brush_colors = brush_bi->bmiColors;
1772 BYTE *brush_bits, *src_bits;
1773 BOOL is_ddb = !bits;
1774 BOOL ret, dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1);
1775 BOOL dib_is_8bpp_gray = (bmi->bmiHeader.biBitCount == 8 && bmi->bmiColors[1].rgbRed == 1);
1776 BLENDFUNCTION blend;
1777 COLORREF old_text, old_bkgnd;
1778 HPALETTE hpal, old_hpal;
1779
1780 blend.BlendOp = AC_SRC_OVER;
1781 blend.BlendFlags = 0;
1782
1783 reset_bounds( hdc );
1784 reset_bits( hdc, bmi, bits );
1785 compare_hash(hdc, bmi, bits, "empty");
1786
1787 src_dc = CreateCompatibleDC( 0 );
1788 solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
1789 orig_pen = SelectObject(hdc, solid_pen);
1790 SetBrushOrgEx(hdc, 0, 0, NULL);
1791
1792 /* horizontal and vertical lines */
1793 for(i = 1; i <= 16; i++)
1794 {
1795 SetROP2(hdc, i);
1796 MoveToEx(hdc, 10, i * 3, NULL);
1797 LineTo(hdc, 100, i * 3); /* l -> r */
1798 MoveToEx(hdc, 100, 50 + i * 3, NULL);
1799 LineTo(hdc, 10, 50 + i * 3); /* r -> l */
1800 MoveToEx(hdc, 120 + i * 3, 10, NULL);
1801 LineTo(hdc, 120 + i * 3, 100); /* t -> b */
1802 MoveToEx(hdc, 170 + i * 3, 100, NULL);
1803 LineTo(hdc, 170 + i * 3, 10); /* b -> t */
1804 }
1805 compare_hash(hdc, bmi, bits, "h and v solid lines");
1806
1807 /* diagonal lines */
1809 for(i = 0; i < 16; i++)
1810 {
1811 double s = sin(M_PI * i / 8.0);
1812 double c = cos(M_PI * i / 8.0);
1813
1814 MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL);
1815 LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s);
1816 }
1817 compare_hash(hdc, bmi, bits, "diagonal solid lines");
1818
1819 for(i = 0; i < ARRAY_SIZE(bias_check); i++)
1820 {
1823 }
1824 compare_hash(hdc, bmi, bits, "more diagonal solid lines");
1825
1826 /* solid brush PatBlt */
1827 solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff));
1828 orig_brush = SelectObject(hdc, solid_brush);
1829
1830 for(i = 0, y = 10; i < 256; i++)
1831 {
1832 ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]);
1833
1834 if(rop_uses_src(rop3[i]))
1835 ok(ret == FALSE || broken(is_ddb), "got TRUE for %lx\n", rop3[i]);
1836 else
1837 {
1838 ok(ret, "got FALSE for %lx\n", rop3[i]);
1839 y += 20;
1840 }
1841
1842 }
1843 compare_hash_broken_todo(hdc, bmi, bits, "solid patblt", is_ddb, is_ddb);
1844
1845 /* clipped lines */
1846 hrgn = CreateRectRgn(10, 10, 200, 20);
1847 hrgn2 = CreateRectRgn(100, 100, 200, 200);
1849 SetRectRgn(hrgn2, 290, 100, 300, 200);
1853
1854 for(i = 0; i < ARRAY_SIZE(hline_clips); i++)
1855 {
1858 }
1859 compare_hash(hdc, bmi, bits, "clipped solid hlines");
1860
1861 for(i = 0; i < ARRAY_SIZE(vline_clips); i++)
1862 {
1865 }
1866 compare_hash(hdc, bmi, bits, "clipped solid vlines");
1867
1868 for(i = 0; i < ARRAY_SIZE(line_clips); i++)
1869 {
1872 }
1873 compare_hash(hdc, bmi, bits, "clipped solid diagonal lines");
1874
1875 /* clipped PatBlt */
1876 for(i = 0; i < ARRAY_SIZE(patblt_clips); i++)
1877 {
1881 }
1882 compare_hash_broken_todo(hdc, bmi, bits, "clipped patblt", is_ddb, is_ddb);
1883
1884 /* clipped dashed lines */
1885 dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0));
1886 SelectObject(hdc, dashed_pen);
1888 SetBkColor(hdc, RGB(0, 0xff, 0));
1889
1890 for(i = 0; i < ARRAY_SIZE(hline_clips); i++)
1891 {
1894 }
1895 compare_hash(hdc, bmi, bits, "clipped dashed hlines");
1896
1897 for(i = 0; i < ARRAY_SIZE(hline_clips); i++)
1898 {
1901 }
1902 compare_hash(hdc, bmi, bits, "clipped dashed hlines r -> l");
1903
1904 for(i = 0; i < ARRAY_SIZE(vline_clips); i++)
1905 {
1908 }
1909 compare_hash(hdc, bmi, bits, "clipped dashed vlines");
1910
1911 for(i = 0; i < ARRAY_SIZE(vline_clips); i++)
1912 {
1915 }
1916 compare_hash(hdc, bmi, bits, "clipped dashed vlines b -> t");
1917
1918 for(i = 0; i < ARRAY_SIZE(line_clips); i++)
1919 {
1922 }
1923 compare_hash(hdc, bmi, bits, "clipped dashed diagonal lines");
1924
1926
1927 for(i = 0; i < ARRAY_SIZE(line_clips); i++)
1928 {
1931 }
1932 compare_hash(hdc, bmi, bits, "clipped opaque dashed diagonal lines");
1933
1935
1936 /* 8888 DIB pattern brush */
1937
1938 brush_bi->bmiHeader = dib_brush_header_8888;
1939 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1940 memset(brush_bits, 0, 16 * 16 * sizeof(DWORD));
1941 brush_bits[2] = 0xff;
1942 brush_bits[6] = 0xff;
1943 brush_bits[14] = 0xff;
1944 brush_bits[65] = 0xff;
1945 brush_bits[69] = 0xff;
1946 brush_bits[72] = 0xff;
1947
1948 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1949
1950 SelectObject(hdc, dib_brush);
1951 SetBrushOrgEx(hdc, 1, 1, NULL);
1952
1953 for(i = 0, y = 10; i < 256; i++)
1954 {
1955 if(!rop_uses_src(rop3[i]))
1956 {
1957 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1958 ok(ret, "got FALSE for %lx\n", rop3[i]);
1959 y += 25;
1960 }
1961 }
1962 compare_hash(hdc, bmi, bits, "top-down 8888 dib brush patblt");
1963
1964 SelectObject(hdc, orig_brush);
1965 DeleteObject(dib_brush);
1966
1967 /* 8888 bottom-up DIB pattern brush */
1968
1969 brush_bi->bmiHeader.biHeight = -brush_bi->bmiHeader.biHeight;
1970
1971 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
1972
1973 SelectObject(hdc, dib_brush);
1974
1975 /* This used to set the x origin to 100 as well, but
1976 there's a Windows bug for 24 bpp where the brush's x offset
1977 is incorrectly calculated for rops that involve both D and P */
1978 SetBrushOrgEx(hdc, 4, 100, NULL);
1979
1980 for(i = 0, y = 10; i < 256; i++)
1981 {
1982 if(!rop_uses_src(rop3[i]))
1983 {
1984 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
1985 ok(ret, "got FALSE for %lx\n", rop3[i]);
1986 y += 25;
1987 }
1988 }
1989 compare_hash(hdc, bmi, bits, "bottom-up 8888 dib brush patblt");
1990
1991 SelectObject(hdc, orig_brush);
1992 DeleteObject(dib_brush);
1993
1994 /* 24 bpp dib pattern brush */
1995
1996 brush_bi->bmiHeader = dib_brush_header_24;
1997 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
1998 memset(brush_bits, 0, 16 * 16 * 3);
1999 brush_bits[0] = brush_bits[3] = brush_bits[6] = brush_bits[8] = 0xff;
2000 brush_bits[49] = brush_bits[52] = 0xff;
2001
2002 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
2003
2004 SelectObject(hdc, dib_brush);
2005 SetBrushOrgEx(hdc, 1, 1, NULL);
2006
2007 for(i = 0, y = 10; i < 256; i++)
2008 {
2009 if(!rop_uses_src(rop3[i]))
2010 {
2011 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2012 ok(ret, "got FALSE for %lx\n", rop3[i]);
2013 y += 25;
2014 }
2015 }
2016 compare_hash(hdc, bmi, bits, "top-down 24 bpp brush patblt");
2017
2018 SelectObject(hdc, orig_brush);
2019 DeleteObject(dib_brush);
2020
2021 /* 555 dib pattern brush */
2022
2023 brush_bi->bmiHeader = dib_brush_header_555;
2024 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER);
2025 memset(brush_bits, 0, 16 * 16 * sizeof(WORD));
2026 brush_bits[0] = brush_bits[1] = 0xff;
2027 brush_bits[32] = brush_bits[34] = 0x7c;
2028
2029 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
2030
2031 SelectObject(hdc, dib_brush);
2032 SetBrushOrgEx(hdc, 1, 1, NULL);
2033
2034 for(i = 0, y = 10; i < 256; i++)
2035 {
2036 if(!rop_uses_src(rop3[i]))
2037 {
2038 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2039 ok(ret, "got FALSE for %lx\n", rop3[i]);
2040 y += 25;
2041 }
2042 }
2043 compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", 0, dib_is_1bpp);
2044
2045 SelectObject(hdc, orig_brush);
2046 DeleteObject(dib_brush);
2047
2048 SetBrushOrgEx(hdc, 0, 0, NULL);
2049
2050 /* 8 bpp dib pattern brush */
2051
2052 brush_bi->bmiHeader = dib_brush_header_8;
2053 brush_bi->bmiHeader.biClrUsed = 3;
2054 memset(brush_colors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD));
2055 brush_colors[0].rgbRed = 0xff;
2056 brush_colors[1].rgbRed = 0xff;
2057 brush_colors[1].rgbGreen = 0xff;
2058 brush_colors[1].rgbBlue = 0xff;
2059
2060 brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD);
2061 memset(brush_bits, 0, 16 * 16 * sizeof(BYTE));
2062 brush_bits[0] = brush_bits[1] = 1;
2063 brush_bits[16] = brush_bits[17] = 2;
2064 brush_bits[32] = brush_bits[33] = 6;
2065
2066 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
2067
2068 SelectObject(hdc, dib_brush);
2069 SetBrushOrgEx(hdc, 1, 1, NULL);
2070
2071 for(i = 0, y = 10; i < 256; i++)
2072 {
2073 if(!rop_uses_src(rop3[i]))
2074 {
2075 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2076 ok(ret, "got FALSE for %lx\n", rop3[i]);
2077 y += 25;
2078 }
2079 }
2080 compare_hash_broken_todo(hdc, bmi, bits, "top-down 8 bpp dib brush patblt", 0, dib_is_1bpp);
2081
2082 SelectObject(hdc, orig_brush);
2083 DeleteObject(dib_brush);
2084
2085 /* 4 bpp dib pattern brush */
2086
2087 brush_bi->bmiHeader = dib_brush_header_4;
2088 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
2089
2090 SelectObject(hdc, dib_brush);
2091 SetBrushOrgEx(hdc, 1, 1, NULL);
2092
2093 for(i = 0, y = 10; i < 256; i++)
2094 {
2095 if(!rop_uses_src(rop3[i]))
2096 {
2097 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2098 ok(ret, "got FALSE for %lx\n", rop3[i]);
2099 y += 25;
2100 }
2101 }
2102 compare_hash_broken_todo(hdc, bmi, bits, "top-down 4 bpp dib brush patblt", 0, dib_is_1bpp);
2103
2104 SelectObject(hdc, orig_brush);
2105 DeleteObject(dib_brush);
2106
2107 /* 1 bpp dib pattern brush */
2108
2109 brush_bi->bmiHeader = dib_brush_header_1;
2110 brush_bi->bmiHeader.biClrUsed = 2;
2111 memset(brush_bits, 0, 16 * 4);
2112 brush_bits[0] = 0xf0;
2113 brush_bits[4] = 0xf0;
2114 brush_bits[8] = 0xf0;
2115
2116 dib_brush = CreateDIBPatternBrushPt(brush_bi, DIB_RGB_COLORS);
2117 SelectObject(hdc, dib_brush);
2118 for(i = 0, y = 10; i < 256; i++)
2119 {
2120 if(!rop_uses_src(rop3[i]))
2121 {
2122 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2123 ok(ret, "got FALSE for %lx\n", rop3[i]);
2124 y += 25;
2125 }
2126 }
2127
2128 compare_hash_broken_todo(hdc, bmi, bits, "top-down 1 bpp dib brush patblt", 0, dib_is_1bpp);
2129
2130 SelectObject(hdc, orig_brush);
2131 DeleteObject(dib_brush);
2132
2133 /* 1 bpp ddb pattern brush */
2134
2135 old_text = GetTextColor( hdc );
2136 old_bkgnd = GetBkColor( hdc );
2137 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2138 dib_brush = CreatePatternBrush( bmp );
2139 SelectObject(hdc, dib_brush);
2140 for(i = 0, y = 10; i < 256; i++)
2141 {
2142 SetTextColor(hdc, RGB( i, 2*i, 255 - i ) );
2143 SetBkColor(hdc, RGB( 255 - i, i / 3, i ) );
2144 if(!rop_uses_src(rop3[i]))
2145 {
2146 ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]);
2147 ok(ret, "got FALSE for %lx\n", rop3[i]);
2148 y += 25;
2149 }
2150 }
2151
2152 compare_hash_broken_todo(hdc, bmi, bits, "1 bpp ddb brush patblt", 0, dib_is_1bpp);
2153
2155 SelectObject(hdc, orig_brush);
2156 DeleteObject( dib_brush );
2157 SetBrushOrgEx(hdc, 0, 0, NULL);
2158 SetTextColor(hdc, old_text);
2159 SetBkColor(hdc, old_bkgnd);
2160
2161 /* Rectangle */
2162
2163 SelectObject(hdc, solid_pen);
2164 SelectObject(hdc, solid_brush);
2165
2166 for(i = 0; i < ARRAY_SIZE(rectangles); i++)
2167 {
2169 }
2170
2171 SelectObject(hdc, dashed_pen);
2172 for(i = 0; i < ARRAY_SIZE(rectangles); i++)
2173 {
2175 }
2176
2177 compare_hash_broken_todo(hdc, bmi, bits, "rectangles", is_ddb, is_ddb);
2178 SelectObject(hdc, solid_pen);
2179
2180 /* PaintRgn */
2181
2182 PaintRgn(hdc, hrgn);
2183 compare_hash_broken_todo(hdc, bmi, bits, "PaintRgn", is_ddb, is_ddb);
2184
2185 /* RTL rectangles */
2186
2188 PaintRgn(hdc, hrgn);
2189 PatBlt(hdc, 10, 250, 10, 10, PATCOPY);
2190 Rectangle(hdc, 100, 250, 110, 260);
2191 compare_hash_broken_todo(hdc, bmi, bits, "rtl", is_ddb, is_ddb);
2193 DeleteObject( hrgn );
2194
2195 for(i = 0, y = 10; i < 256; i++)
2196 {
2197 if(!rop_uses_src(rop3[i]))
2198 {
2199 for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++)
2200 {
2201 hatch_brush = CreateHatchBrush(hatch_style, RGB(0xff, 0, 0));
2202 SelectObject(hdc, hatch_brush);
2203 ret = PatBlt(hdc, 10 + i + 30 * hatch_style, y, 20, 20, rop3[i]);
2204 ok(ret, "got FALSE for %lx\n", rop3[i]);
2205 SelectObject(hdc, orig_brush);
2206 DeleteObject(hatch_brush);
2207 }
2208 y += 25;
2209 }
2210 }
2211
2212 compare_hash(hdc, bmi, bits, "hatch brushes");
2213
2214 /* overlapping blits */
2215
2216 orig_brush = SelectObject(hdc, solid_brush);
2217
2218 Rectangle(hdc, 10, 10, 100, 100);
2219 Rectangle(hdc, 20, 15, 30, 40);
2220 Rectangle(hdc, 15, 15, 20, 20);
2221 Rectangle(hdc, 15, 20, 50, 45);
2222 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, SRCCOPY );
2223 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, +y", is_ddb, is_ddb);
2224
2225 Rectangle(hdc, 10, 10, 100, 100);
2226 Rectangle(hdc, 20, 15, 30, 40);
2227 Rectangle(hdc, 15, 15, 20, 20);
2228 Rectangle(hdc, 15, 20, 50, 45);
2229 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, SRCCOPY );
2230 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y", dib_is_1bpp + is_ddb, is_ddb);
2231
2232 Rectangle(hdc, 10, 10, 100, 100);
2233 Rectangle(hdc, 20, 15, 30, 40);
2234 Rectangle(hdc, 15, 15, 20, 20);
2235 Rectangle(hdc, 15, 20, 50, 45);
2236 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, SRCCOPY );
2237 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, -y", is_ddb, is_ddb);
2238
2239 Rectangle(hdc, 10, 10, 100, 100);
2240 Rectangle(hdc, 20, 15, 30, 40);
2241 Rectangle(hdc, 15, 15, 20, 20);
2242 Rectangle(hdc, 15, 20, 50, 45);
2243 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, SRCCOPY );
2244 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y", dib_is_1bpp + is_ddb, is_ddb);
2245
2246 Rectangle(hdc, 10, 10, 100, 100);
2247 Rectangle(hdc, 20, 15, 30, 40);
2248 Rectangle(hdc, 15, 15, 20, 20);
2249 Rectangle(hdc, 15, 20, 50, 45);
2250 BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, PATPAINT );
2251 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, +y", is_ddb, is_ddb);
2252
2253 Rectangle(hdc, 10, 10, 100, 100);
2254 Rectangle(hdc, 20, 15, 30, 40);
2255 Rectangle(hdc, 15, 15, 20, 20);
2256 Rectangle(hdc, 15, 20, 50, 45);
2257 BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, PATPAINT );
2258 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, -y", is_ddb, is_ddb);
2259
2260 Rectangle(hdc, 10, 10, 100, 100);
2261 Rectangle(hdc, 20, 15, 30, 40);
2262 Rectangle(hdc, 15, 15, 20, 20);
2263 Rectangle(hdc, 15, 20, 50, 45);
2264 BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, PATPAINT );
2265 if (bmi->bmiHeader.biBitCount >= 24) /* Windows gets this one wrong */
2266 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE);
2267 else
2268 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y", is_ddb, is_ddb);
2269
2270 Rectangle(hdc, 10, 10, 100, 100);
2271 Rectangle(hdc, 20, 15, 30, 40);
2272 Rectangle(hdc, 15, 15, 20, 20);
2273 Rectangle(hdc, 15, 20, 50, 45);
2274 BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, PATPAINT );
2275 compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, +y", is_ddb, is_ddb);
2276
2277 /* blitting with 32-bpp BI_RGB source */
2278
2279 memset( dib_src_buf, 0, sizeof(dib_src_buf) );
2280 src_bi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
2281 src_bi->bmiHeader.biHeight = 256;
2282 src_bi->bmiHeader.biWidth = 256;
2283 src_bi->bmiHeader.biBitCount = 32;
2284 src_bi->bmiHeader.biPlanes = 1;
2285 src_bi->bmiHeader.biCompression = BI_RGB;
2286 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2287 SelectObject( src_dc, bmp );
2288 for (y = 0; y < 256; y++)
2289 for (x = 0; x < 256; x++)
2290 {
2291 BYTE a = (x + y) * 2;
2292 BYTE r = (BYTE)(y + 2 * x) * a / 255;
2293 BYTE g = (BYTE)(x + y / 3) * a / 255;
2294 BYTE b = (BYTE)(x / 3 + 2 * y) * a / 255;
2295 ((DWORD *)src_bits)[y * 256 + x] = (a << 24) | RGB( r, g, b );
2296 }
2297
2298 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2299
2300 /* Interesting cases for 1-bpp dst */
2301 BitBlt( hdc, 1, 4, 2, 2, src_dc, 0, 0, SRCCOPY );
2302 BitBlt( hdc, 1, 8, 16, 2, src_dc, 0, 0, SRCCOPY );
2303 BitBlt( hdc, 1, 12, 15, 2, src_dc, 0, 0, SRCCOPY );
2304 BitBlt( hdc, 0, 16, 8, 2, src_dc, 0, 0, SRCCOPY );
2305 BitBlt( hdc, 0, 20, 9, 2, src_dc, 0, 0, SRCCOPY );
2306 BitBlt( hdc, 7, 24, 1, 2, src_dc, 0, 0, SRCCOPY );
2307 BitBlt( hdc, 7, 28, 2, 2, src_dc, 0, 0, SRCCOPY );
2308 BitBlt( hdc, 7, 32, 9, 2, src_dc, 0, 0, SRCCOPY );
2309 BitBlt( hdc, 7, 36, 10, 2, src_dc, 0, 0, SRCCOPY );
2310 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY" );
2311
2312 blend.SourceConstantAlpha = 0xd0;
2313 blend.AlphaFormat = 0;
2314 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2315 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 0, dib_is_1bpp );
2316
2317 blend.SourceConstantAlpha = 0xb0;
2318 blend.AlphaFormat = AC_SRC_ALPHA;
2319 GdiAlphaBlend( hdc, 50, 50, 256, 256, src_dc, 0, 0, 256, 256, blend );
2320 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 0, dib_is_1bpp );
2321
2322 /* blitting with 32-bpp r10g10b10 source */
2323
2324 src_bi->bmiHeader.biBitCount = 32;
2325 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2326 ((DWORD *)src_bi->bmiColors)[0] = 0x3ff00000;
2327 ((DWORD *)src_bi->bmiColors)[1] = 0x000ffc00;
2328 ((DWORD *)src_bi->bmiColors)[2] = 0x000003ff;
2329 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2330 SelectObject( src_dc, bmp );
2331 for (y = 0; y < 256; y++)
2332 for (x = 0; x < 256; x++)
2333 {
2334 WORD r = (7 * x + 3 * y) % 1024;
2335 WORD g = (11 * x + y / 3) % 1024;
2336 WORD b = (x / 3 + 9 * y) % 1024;
2337 ((DWORD *)src_bits)[y * 256 + x] = r << 20 | g << 10 | b;
2338 }
2339
2340 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2341 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY" );
2342
2343 /* blitting with 32-bpp b6g6r6 source */
2344
2345 src_bi->bmiHeader.biBitCount = 32;
2346 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2347 ((DWORD *)src_bi->bmiColors)[0] = 0x00003f;
2348 ((DWORD *)src_bi->bmiColors)[1] = 0x000fc0;
2349 ((DWORD *)src_bi->bmiColors)[2] = 0x03f000;
2350 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2351 SelectObject( src_dc, bmp );
2352 for (y = 0; y < 256; y++)
2353 for (x = 0; x < 256; x++)
2354 {
2355 BYTE r = (y + 2 * x) % 64;
2356 BYTE g = (x + y / 3) % 64;
2357 BYTE b = (x / 3 + 2 * y) % 64;
2358 ((DWORD *)src_bits)[y * 256 + x] = r | g << 6 | b << 12;
2359 }
2360
2361 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2362 compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY" );
2363
2364 /* blitting with 24-bpp source */
2365
2366 src_bi->bmiHeader.biBitCount = 24;
2367 src_bi->bmiHeader.biCompression = BI_RGB;
2368 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2369 DeleteObject( SelectObject( src_dc, bmp ) );
2370 for (y = 0; y < 256; y++)
2371 for (x = 0; x < 256; x++)
2372 {
2373 src_bits[(y * 256 + x) * 3 + 0] = x + 3 * y;
2374 src_bits[(y * 256 + x) * 3 + 1] = 2 * x + 7 * y;
2375 src_bits[(y * 256 + x) * 3 + 2] = 5 * x + 12 * y;
2376 }
2377
2378 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2379 compare_hash(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY" );
2380
2381 blend.SourceConstantAlpha = 0xe0;
2382 blend.AlphaFormat = 0;
2383 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2384 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 0, dib_is_1bpp );
2385
2386 /* blitting with 16-bpp BI_RGB source */
2387
2388 src_bi->bmiHeader.biBitCount = 16;
2389 src_bi->bmiHeader.biCompression = BI_RGB;
2390 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2391 DeleteObject( SelectObject( src_dc, bmp ) );
2392 for (y = 0; y < 256; y++)
2393 for (x = 0; x < 256; x++)
2394 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2395
2396 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2397 compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY" );
2398
2399 /* blitting with 16-bpp b4g4r4 source */
2400
2401 src_bi->bmiHeader.biBitCount = 16;
2402 src_bi->bmiHeader.biCompression = BI_BITFIELDS;
2403 ((DWORD *)src_bi->bmiColors)[0] = 0x00000f;
2404 ((DWORD *)src_bi->bmiColors)[1] = 0x0000f0;
2405 ((DWORD *)src_bi->bmiColors)[2] = 0x000f00;
2406 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2407 DeleteObject( SelectObject( src_dc, bmp ) );
2408 for (y = 0; y < 256; y++)
2409 for (x = 0; x < 256; x++)
2410 ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7;
2411
2412 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2413 compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY" );
2414
2415 /* blitting with 8-bpp source */
2416
2417 src_bi->bmiHeader.biBitCount = 8;
2418 src_bi->bmiHeader.biCompression = BI_RGB;
2419 src_bi->bmiHeader.biClrUsed = 160;
2420 for (i = 0; i < 256; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 3) << 8 | (i / 2) << 16;
2421 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2422 DeleteObject( SelectObject( src_dc, bmp ) );
2423 for (y = 0; y < 256; y++)
2424 for (x = 0; x < 256; x++)
2425 src_bits[y * 256 + x] = 3 * x + 5 * y;
2426
2427 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2428 compare_hash(hdc, bmi, bits, "BitBlt src 8-bpp SRCCOPY" );
2429
2430 blend.SourceConstantAlpha = 0xd0;
2431 blend.AlphaFormat = 0;
2432 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2433 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 0, dib_is_1bpp );
2434
2435 /* blitting with 4-bpp source */
2436
2437 src_bi->bmiHeader.biBitCount = 4;
2438 src_bi->bmiHeader.biClrUsed = 12;
2439 for (i = 0; i < 16; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 5) << 8 | (i * 19) << 16;
2440 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2441 DeleteObject( SelectObject( src_dc, bmp ) );
2442 for (y = 0; y < 256; y++)
2443 for (x = 0; x < 256; x += 2)
2444 src_bits[(y * 256 + x) / 2] = 7 * x + 3 * y;
2445
2446 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2447 compare_hash(hdc, bmi, bits, "BitBlt src 4-bpp SRCCOPY" );
2448
2449 /* blitting with 1-bpp source */
2450
2451 src_bi->bmiHeader.biBitCount = 1;
2452 src_bi->bmiHeader.biClrUsed = 0;
2453 for (i = 0; i < 2; i++) ((DWORD *)src_bi->bmiColors)[i] = (i + 37) | (i * 91) << 8 | (i * 53) << 16;
2454 bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0);
2455 DeleteObject( SelectObject( src_dc, bmp ) );
2456 for (y = 0; y < 256; y++)
2457 for (x = 0; x < 256; x += 8)
2458 src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y;
2459
2460 BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY );
2461 /* Some interesting src co-ords */
2462 BitBlt( hdc, 10, 10, 3, 10, src_dc, 0, 0, SRCCOPY );
2463 BitBlt( hdc, 20, 10, 3, 10, src_dc, 2, 0, SRCCOPY );
2464 BitBlt( hdc, 30, 10, 3, 10, src_dc, 5, 0, SRCCOPY );
2465 BitBlt( hdc, 40, 10, 3, 10, src_dc, 6, 0, SRCCOPY );
2466 BitBlt( hdc, 50, 10, 20, 10, src_dc, 6, 0, SRCCOPY );
2467 compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp SRCCOPY" );
2468
2469 blend.SourceConstantAlpha = 0x90;
2470 blend.AlphaFormat = 0;
2471 GdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend );
2472 compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 1-bpp", 0, is_ddb );
2473
2474 /* blitting with 1-bpp ddb source */
2475
2476 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2477 DeleteObject( SelectObject( src_dc, bmp ) );
2478
2479 old_text = GetTextColor( hdc );
2480 old_bkgnd = GetBkColor( hdc );
2481 for (i = 0; i < 256; i += 13)
2482 {
2483 SetTextColor(hdc, RGB( i, 2*i, 255 - i ) );
2484 SetBkColor(hdc, RGB( 255 - i, i / 3, i ) );
2485 BitBlt( hdc, i, 0, 13, 13, src_dc, 0, 0, SRCCOPY );
2486 }
2487 for (i = 0; i < 256; i += 13)
2488 {
2490 SetBkColor(hdc, PALETTEINDEX( i + 3 ));
2491 BitBlt( hdc, i, 13, 13, 13, src_dc, 0, 0, SRCCOPY );
2492 }
2493 for (i = 0; i < 256; i += 13)
2494 {
2496 SetBkColor(hdc, DIBINDEX( i + 3 ));
2497 BitBlt( hdc, i, 26, 13, 13, src_dc, 0, 0, SRCCOPY );
2498 }
2499 SetTextColor( hdc, old_text );
2500 SetBkColor( hdc, old_bkgnd );
2501 compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp ddb SRCCOPY" );
2502
2503 DeleteObject( bmp );
2504
2505 /* blitting to 1-bpp ddb dest */
2506
2507 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2508 DeleteObject( SelectObject( src_dc, bmp ) );
2509
2510 for (y = 0; y < 16; y++)
2511 for (x = 0; x < 16; x++)
2512 SetPixel( hdc, x, y, RGB( 16 * x, 16 * y, 8 * (x + y)) );
2513 PatBlt( hdc, 15, 15, 1, 1, WHITENESS );
2514 /* source colors are ignored */
2515 SetTextColor( src_dc, 0xbeef );
2516 SetBkColor( src_dc, RGB( 16 * 2, 16 * 3, 8 * (2 + 3) ));
2517 /* destination text color is also ignored */
2518 SetTextColor( hdc, 0xbedead );
2519
2520 if (bits)
2521 {
2522 i = 16;
2523 SetBkColor( hdc, 0xffffff );
2524 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2525 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2526 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2527 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2528 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2529 SetBkColor( hdc, 0 );
2530 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2531 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2532 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2533 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2534 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2535 SetBkColor( hdc, RGB( 16 * 2, 16 * 3, 8 * (2 + 3) ));
2536 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2537 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2538 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2539 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2540 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2541 SetBkColor( hdc, RGB( 16 * 13, 16 * 14, 8 * (13 + 14) ));
2542 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2543 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2544 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2545 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2546 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2547 SetBkColor( hdc, PALETTEINDEX( 1 ));
2548 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2549 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2550 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2551 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2552 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2553 SetBkColor( hdc, DIBINDEX( 2 ));
2554 BitBlt( src_dc, 0, 0, 16, 16, hdc, 0, 0, SRCCOPY );
2555 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2556 StretchDIBits( src_dc, 0, 0, 16, 16, 0,
2557 bmi->bmiHeader.biHeight - 16, 16, 16, bits, bmi, DIB_RGB_COLORS, SRCCOPY );
2558 GetBitmapBits( bmp, 32, bits + get_stride(bmi) * i++ );
2559 SetTextColor( hdc, old_text );
2560 SetBkColor( hdc, old_bkgnd );
2561 }
2562 compare_hash(hdc, bmi, bits, "BitBlt dst 1-bpp ddb");
2563
2564 DeleteDC( src_dc );
2565 DeleteObject( bmp );
2566
2567 /* RLE StretchDIBits */
2568 src_bi->bmiHeader.biSize = sizeof(src_bi->bmiHeader);
2569 src_bi->bmiHeader.biWidth = 8;
2570 src_bi->bmiHeader.biHeight = 8;
2571 src_bi->bmiHeader.biPlanes = 1;
2572 src_bi->bmiHeader.biBitCount = 8;
2573 src_bi->bmiHeader.biCompression = BI_RLE8;
2574 src_bi->bmiHeader.biClrUsed = 0;
2575 src_bi->bmiHeader.biSizeImage = sizeof(rle8_data);
2576
2577 for (i = 0; i < 256; i++)
2578 {
2579 src_bi->bmiColors[i].rgbRed = i;
2580 src_bi->bmiColors[i].rgbGreen = i;
2581 src_bi->bmiColors[i].rgbBlue = i;
2582 src_bi->bmiColors[i].rgbReserved = 0;
2583 }
2584
2585 StretchDIBits( hdc, 10, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2586 StretchDIBits( hdc, 100, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCAND );
2587 StretchDIBits( hdc, 200, 10, 7, 7, 0, 1, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2588 StretchDIBits( hdc, 300, 10, 7, 7, 1, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2589 StretchDIBits( hdc, 400, 10, 16, 16, 0, 0, 8, 8, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2590 compare_hash_broken_todo(hdc, bmi, bits, "rle stretchdibits", 0, dib_is_1bpp );
2591
2592 /* 32 bpp StretchDIBits */
2593
2594 src_bi->bmiHeader.biWidth = 4;
2595 src_bi->bmiHeader.biHeight = 4;
2596 src_bi->bmiHeader.biPlanes = 1;
2597 src_bi->bmiHeader.biBitCount = 32;
2598 src_bi->bmiHeader.biCompression = BI_RGB;
2599 src_bi->bmiHeader.biClrUsed = 0;
2600 src_bi->bmiHeader.biSizeImage = 0;
2601
2602 ret = StretchDIBits( hdc, 10, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2603 ok(ret == 4, "got %d\n", ret);
2604 ret = StretchDIBits( hdc, 20, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2605 ok(ret == 4, "got %d\n", ret);
2606 ret = StretchDIBits( hdc, 30, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2607 ok(ret == 4, "got %d\n", ret);
2608 ret = StretchDIBits( hdc, 40, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2609 ok(ret == 4, "got %d\n", ret);
2610 ret = StretchDIBits( hdc, 50, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2611 ok(ret == 4, "got %d\n", ret);
2612 ret = StretchDIBits( hdc, 60, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2613 ok(ret == 4, "got %d\n", ret);
2614
2615 src_bi->bmiHeader.biHeight = -4;
2616
2617 ret = StretchDIBits( hdc, 10, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2618 ok(ret == 4, "got %d\n", ret);
2619 ret = StretchDIBits( hdc, 20, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2620 ok(ret == -4, "got %d\n", ret);
2621 ret = StretchDIBits( hdc, 30, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2622 ok(ret == 4, "got %d\n", ret);
2623 ret = StretchDIBits( hdc, 40, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2624 ok(ret == -4, "got %d\n", ret);
2625 ret = StretchDIBits( hdc, 50, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY );
2626 ok(ret == 4, "got %d\n", ret);
2627 ret = StretchDIBits( hdc, 60, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND );
2628 ok(ret == -4, "got %d\n", ret);
2629
2630 compare_hash_broken_todo(hdc, bmi, bits, "stretchdibits", dib_is_8bpp_gray ? 1 : 0, dib_is_8bpp_gray );
2631
2632 /* Solid colors */
2633
2634 for (i = 0; i < 16; i++)
2635 {
2636 for (j = 0; j < 16; j++)
2637 {
2638 solid_patblt( hdc, 16 * j, 16 * i, 16, 16, RGB( i*16+j, i*16+j, i*16+j ));
2639 solid_patblt( hdc, 16 * j, 256 + 16 * i, 16, 16, RGB( 3*(i*16+j), i*16+j, i*16+j ));
2640 solid_patblt( hdc, 256 + 16 * j, 16 * i, 16, 16, RGB( i*16+j, 3*(i*16+j), i*16+j ));
2641 solid_patblt( hdc, 256 + 16 * j, 256 + 16 * i, 16, 16, RGB( i*16+j, i*16+j, 3*(i*16+j) ));
2642 }
2643 }
2644 compare_hash_broken_todo(hdc, bmi, bits, "color fills", is_ddb, is_ddb);
2645
2646 for (i = 0; i < 256; i++)
2647 {
2648 solid_patblt( hdc, i * 2, 10, 1, 1, DIBINDEX(i) );
2649 solid_patblt( hdc, i * 2, 20, 1, 1, PALETTEINDEX(i) );
2650 solid_patblt( hdc, i * 2, 30, 1, 1, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2651 solid_patblt( hdc, i * 2, 40, 1, 1, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2652 for (j = 0; j < 256; j++) solid_patblt( hdc, i * 2, 50 + j, 1, 1, (j << 24) | i );
2653 }
2654
2655 /* A few extra colors that are interesting in the 1bpp case */
2656
2657 /* bk color */
2658 solid_patblt( hdc, 0, 50, 1, 1, RGB( 0, 0xff, 0 ) );
2659 solid_patblt( hdc, 2, 50, 1, 1, PALETTERGB( 0, 0xff, 0 ) );
2660
2661 /* color 0 */
2662 solid_patblt( hdc, 4, 50, 1, 1, RGB( 0, 0x1, 0xff ) );
2663 solid_patblt( hdc, 6, 50, 1, 1, PALETTERGB( 0, 0x1, 0xff ) );
2664
2665 /* color 1 */
2666 solid_patblt( hdc, 8, 50, 1, 1, RGB( 0xff, 0, 0 ) );
2667 solid_patblt( hdc, 10, 50, 1, 1, PALETTERGB( 0xff, 0, 0 ) );
2668
2669 compare_hash_broken_todo(hdc, bmi, bits, "Colors", is_ddb, is_ddb);
2670
2671 for (i = 0; i < 256; i++)
2672 {
2673 COLORREF s, g;
2674
2675 for (j = 0; j < 16; j++)
2676 {
2677 SetROP2( hdc, (j + R2_COPYPEN - 1) % 16 + 1 ); /* Start with R2_COPYPEN */
2678
2679 s = SetPixel( hdc, i * 2, j, DIBINDEX(i) );
2680 g = GetPixel( hdc, i * 2, 0 ); /* retrieve value set with R2_COPYPEN */
2681 ok( s == g, "got %08lx and %08lx\n", s, g );
2682
2683 s = SetPixel( hdc, i * 2, 20 + j, PALETTEINDEX(i) );
2684 g = GetPixel( hdc, i * 2, 20 + 0 ); /* retrieve value set with R2_COPYPEN */
2685 ok( s == g, "got %08lx and %08lx\n", s, g );
2686
2687 s = SetPixel( hdc, i * 2, 40 + j, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2688 g = GetPixel( hdc, i * 2, 40 + 0 ); /* retrieve value set with R2_COPYPEN */
2689 ok( s == g, "got %08lx and %08lx\n", s, g );
2690
2691 s = SetPixel( hdc, i * 2, 60 + j, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) );
2692 g = GetPixel( hdc, i * 2, 60 + 0 ); /* retrieve value set with R2_COPYPEN */
2693 ok( s == g, "got %08lx and %08lx\n", s, g );
2694 }
2695
2697
2698 for (j = 0; j < 256; j++)
2699 {
2700 s = SetPixel( hdc, i * 2, 80 + j, (j << 24) | RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ));
2701 g = GetPixel( hdc, i * 2, 80 + j );
2702 ok( s == g, "got %08lx and %08lx\n", s, g );
2703
2704 s = SetPixel( hdc, i * 2 + 1, 80 + j, (j << 24) | i );
2705 g = GetPixel( hdc, i * 2 + 1, 80 + j );
2706 ok( s == g, "got %08lx and %08lx\n", s, g );
2707 }
2708 }
2709
2710 compare_hash(hdc, bmi, bits, "SetPixel");
2711
2712 /* gradients */
2713
2714 {
2715 TRIVERTEX vrect[] =
2716 {
2717 { 1, 1, 0xff00, 0x8000, 0x0000, 0x8000 },
2718 { 200, 200, 0x0000, 0x0000, 0xff00, 0xff00 },
2719 { 180, 180, 0x1234, 0x5678, 0x9abc, 0xdef0 },
2720 { 300, 300, 0xff00, 0xff00, 0xff00, 0x0000 }
2721 };
2722 GRADIENT_RECT rect[] = { { 0, 1 }, { 2, 3 }, { 2, 1 } };
2723
2724 TRIVERTEX vtri[] =
2725 {
2726 { 250, 0, 0xff00, 0x0000, 0xff00, 0xff00 },
2727 { 500, 500, 0x0000, 0xff00, 0x0000, 0xff00 },
2728 { 0, 500, 0x0000, 0x0000, 0xff00, 0xff00 },
2729
2730 { 10, 0, 0x8000, 0x0000, 0x8000, 0x8000 },
2731 { 0, 20, 0xff00, 0xff00, 0xff00, 0x0000 },
2732 { 5, 30, 0x4000, 0xc000, 0x7000, 0x9000 },
2733
2734 { 30, 0, 0x9000, 0x8800, 0xcc00, 0xff00 },
2735 { 5, 12, 0x9900, 0xaa00, 0xbb00, 0xcc00 },
2736 { 0, 30, 0x5000, 0xd000, 0x9000, 0xbb00 },
2737
2738 { 35, 3, 0xaa00, 0x6500, 0x4300, 0x2100 },
2739 { 50, 6, 0x9800, 0x9800, 0x9800, 0x2000 },
2740 { 60, 10, 0x0100, 0x0200, 0x0300, 0x3000 },
2741
2742 { 60, 2, 0x0700, 0x0800, 0x0900, 0xff00 },
2743 { 73, 10, 0x9900, 0x8800, 0x7700, 0xff00 },
2744 { 66, 23, 0x1100, 0x2200, 0x3300, 0xff00 },
2745
2746 { 80, 1, 0xa000, 0x6000, 0x4000, 0x2000 },
2747 { 76, 9, 0x7000, 0x5000, 0x3000, 0x1000 },
2748 { 85, 23, 0x3300, 0x3300, 0x3300, 0x3300 },
2749
2750 { 90, 4, 0x4400, 0x5500, 0x6600, 0x9900 },
2751 { 95, 12, 0x4500, 0x5600, 0x6700, 0x9900 },
2752 { 85, 14, 0x4600, 0x5700, 0x6800, 0x9900 },
2753 };
2754 GRADIENT_TRIANGLE tri[] =
2755 {
2756 { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 10, 11 }, { 12, 13, 14 }, { 15, 16, 17 }, { 18, 19, 20 },
2757 { 2, 1, 0 }, { 3, 5, 4 }, { 7, 6, 8 }, { 10, 11, 9 }, { 14, 13, 12 }, { 17, 15, 16 }, { 19, 20, 18 }
2758 };
2759
2760 GdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_H );
2761 for (i = 0; i < 4; i++) vrect[i].y += 250;
2762 GdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_V );
2763 /* Wine's 8-bit dithering isn't identical to Windows */
2764 compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, (bmi->bmiHeader.biBitCount <= 8) );
2765
2766 GdiGradientFill( hdc, vtri, 7*3, tri, 7, GRADIENT_FILL_TRIANGLE );
2767 for (i = 0; i < 7*3; i++) vtri[i].y += 100;
2768 GdiGradientFill( hdc, vtri, 7*3, tri + 7, 7, GRADIENT_FILL_TRIANGLE );
2769 /* Wine's 8-bit dithering isn't identical to Windows */
2770 compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, (bmi->bmiHeader.biBitCount <= 8) );
2771 }
2772
2773 /* wide pen */
2774
2775 wide_pen = CreatePen( PS_SOLID, 7, RGB( 0xff, 0, 0 ) );
2776 SelectObject( hdc, wide_pen );
2777
2778 for (i = 0; i < ARRAY_SIZE(wide_lines); i++)
2779 {
2782 }
2783
2784 compare_hash( hdc, bmi, bits, "wide pen" );
2785
2786 SelectObject( hdc, orig_pen );
2787 DeleteObject( wide_pen );
2788
2789 log_brush.lbStyle = BS_SOLID;
2790 log_brush.lbColor = RGB(0xff, 0, 0);
2791 log_brush.lbHatch = 0;
2792
2794 9, &log_brush, 0, NULL );
2795 SelectObject( hdc, wide_pen );
2796 SetBrushOrgEx( hdc, 3, 3, NULL );
2798 compare_hash_broken_todo( hdc, bmi, bits, "wide pen - flat caps, mitred", is_ddb, is_ddb );
2799 SetBrushOrgEx( hdc, 0, 0, NULL );
2800
2801 SelectObject( hdc, orig_pen );
2802 DeleteObject( wide_pen );
2803
2805 16, &log_brush, 0, NULL );
2806 SelectObject( hdc, wide_pen );
2807
2809 compare_hash_broken_todo( hdc, bmi, bits, "wide pen - square caps, bevelled", is_ddb, is_ddb );
2810
2811 SelectObject( hdc, orig_pen );
2812 DeleteObject( wide_pen );
2813
2815 9, &log_brush, 0, NULL );
2816 SelectObject( hdc, wide_pen );
2817
2819 compare_hash_broken_todo( hdc, bmi, bits, "wide pen - empty segments", is_ddb, is_ddb );
2820
2821 SelectObject( hdc, orig_pen );
2822 DeleteObject( wide_pen );
2823
2824 /* brushed wide pen */
2825
2826 old_text = GetTextColor( hdc );
2827 old_bkgnd = GetBkColor( hdc );
2828 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2829 log_brush.lbStyle = BS_PATTERN;
2830 log_brush.lbColor = 0;
2831 log_brush.lbHatch = (ULONG_PTR)bmp;
2833 12, &log_brush, 0, NULL );
2834 ok( wide_pen != 0, "failed to create pen\n" );
2835 SelectObject( hdc, wide_pen );
2837
2838 for (i = 1; i < 20; i++)
2839 {
2841 i, &log_brush, 0, NULL );
2842 ok( wide_pen != 0, "failed to create pen\n" );
2843 DeleteObject( SelectObject( hdc, wide_pen ));
2844 SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2845 SetBkColor(hdc, RGB( 255 - i, i, i / 3 ) );
2846 MoveToEx( hdc, 10 * i, 10, NULL );
2847 LineTo( hdc, 10 * i, 200 + i );
2848 LineTo( hdc, 20 * i, 200 + i );
2849 }
2850 compare_hash_broken_todo(hdc, bmi, bits, "wide brushed pen", 0, dib_is_1bpp );
2851
2852 for (i = 1; i < 20; i++)
2853 {
2854 wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | (i % 5),
2855 i, &log_brush, 0, NULL );
2856 DeleteObject( SelectObject( hdc, wide_pen ));
2857 SetTextColor(hdc, RGB( 2*i, i, 255 - i ) );
2858 SetBkColor(hdc, RGB( i, 255 - i, i / 3 ) );
2859 MoveToEx( hdc, 10 * i, 10, NULL );
2860 LineTo( hdc, 10 * i, 200 + i );
2861 LineTo( hdc, 20 * i, 200 + i );
2862 }
2863 compare_hash_broken_todo(hdc, bmi, bits, "dashed wide brushed pen", 0, dib_is_1bpp );
2864
2866 SetTextColor(hdc, old_text);
2867 SetBkColor(hdc, old_bkgnd);
2868 SelectObject( hdc, orig_pen );
2869
2870 /* PALETTEINDEX */
2871
2872 solid_brush = CreateSolidBrush( PALETTEINDEX(3) );
2873 solid_pen = CreatePen( PS_DASH, 1, PALETTEINDEX(5) );
2876 SelectObject( hdc, solid_brush );
2877 SelectObject( hdc, solid_pen );
2878
2879 pal->palVersion = 0x300;
2880 pal->palNumEntries = 40;
2881 for (i = 0; i < 80; i++)
2882 {
2883 entries[i].peRed = i * 3;
2884 entries[i].peGreen = i * 7;
2885 entries[i].peBlue = 128 - i;
2886 entries[i].peFlags = 0;
2887 }
2888 hpal = CreatePalette( pal );
2889 old_hpal = SelectPalette( hdc, hpal, FALSE );
2890
2891 solid_patblt( hdc, 20, 10, 10, 10, PALETTEINDEX(15) );
2892 Rectangle( hdc, 0, 0, 10, 10 );
2893 SetPaletteEntries( hpal, 0, 40, entries + 40 );
2894 Rectangle( hdc, 10, 0, 10, 10 );
2895 SelectObject( hdc, orig_brush );
2896 DeleteObject( solid_brush );
2897
2898 solid_brush = CreateHatchBrush( HS_CROSS, PALETTEINDEX(7) );
2899 DeleteObject( SelectObject( hdc, solid_brush ));
2900 PatBlt( hdc, 20, 0, 10, 10, PATCOPY );
2901 SetPaletteEntries( hpal, 0, 40, entries );
2902 PatBlt( hdc, 30, 0, 10, 10, PATCOPY );
2903 SelectObject( hdc, orig_brush );
2904 DeleteObject( solid_brush );
2905
2906 bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits );
2907 dib_brush = CreatePatternBrush( bmp );
2908 SelectObject( hdc, dib_brush );
2909 PatBlt( hdc, 40, 0, 10, 10, PATCOPY );
2910 SetPaletteEntries( hpal, 0, 40, entries + 40 );
2911 PatBlt( hdc, 50, 0, 10, 10, PATCOPY );
2912 DeleteObject( bmp );
2913 SelectObject( hdc, orig_brush );
2914 DeleteObject( dib_brush );
2915
2916 SelectPalette( hdc, old_hpal, FALSE );
2917 DeleteObject( hpal );
2918
2919 compare_hash_broken_todo(hdc, bmi, bits, "PALETTEINDEX", is_ddb, dib_is_1bpp );
2920
2921 /* ExtFloodFill */
2922
2923 solid_patblt( hdc, 0, 0, 512, 512, RGB( 0, 0, 0xff ) );
2924 solid_patblt( hdc, 10, 10, 200, 200, RGB( 0, 0xff, 0 ) );
2925 solid_patblt( hdc, 10, 50, 50, 50, RGB( 0, 0, 0xff ) );
2926 solid_patblt( hdc, 100, 160, 50, 50, RGB( 0, 0, 0xff ) );
2927 solid_patblt( hdc, 90, 160, 70, 10, RGB( 0, 0, 0xff ) );
2928
2929 /* add a vertical 'bar' to show that the clip rgn stops the flooding */
2930 hrgn = CreateRectRgn( 180, 10, 190, 210 );
2932 DeleteObject( hrgn );
2933
2934 solid_brush = CreateSolidBrush( RGB( 0xff, 0, 0 ) );
2935 SelectObject( hdc, solid_brush );
2936
2937 ret = ExtFloodFill( hdc, 100, 100, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE );
2938 if (is_ddb)
2939 todo_wine ok (!ret || broken(ret), "got ret %d\n", ret);
2940 else
2941 ok (ret, "got ret %d\n", ret);
2942 compare_hash_broken_todo( hdc, bmi, bits, "flood fill", is_ddb, is_ddb );
2943
2945
2946 ret = ExtFloodFill( hdc, -1, -1, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE );
2947 ok (!ret, "got ret %d\n", ret);
2948
2949 SelectObject(hdc, orig_brush);
2950 SelectObject(hdc, orig_pen);
2951 DeleteObject(solid_brush);
2952 DeleteObject(wide_pen);
2953 DeleteObject(dashed_pen);
2954 DeleteObject(solid_pen);
2955}
#define DIBINDEX(n)
Definition: NtGdiLineTo.c:11
static HRGN hrgn2
static HRGN hrgn
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#define ARRAY_SIZE(A)
Definition: main.h:20
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
_ACRTIMP double __cdecl sin(double)
Definition: sin.c:21
_ACRTIMP double __cdecl cos(double)
Definition: cos.c:21
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
ULONG RGBQUAD
Definition: precomp.h:47
#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 bits
Definition: infblock.c:15
#define b
Definition: ke_i.h:79
#define M_PI
Definition: macros.h:263
#define todo_wine
Definition: minitest.h:80
#define BI_BITFIELDS
Definition: mmreg.h:507
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:88
#define LAYOUT_LTR
Definition: dc.c:33
static const RECT hline_clips[]
Definition: dib.c:1489
static const BITMAPINFOHEADER dib_brush_header_24
Definition: dib.c:1605
static const DWORD rop3[256]
Definition: dib.c:36
static const RECT patblt_clips[]
Definition: dib.c:1565
static const RECT bias_check[]
Definition: dib.c:1477
static BOOL rop_uses_src(DWORD rop)
Definition: dib.c:72
static const RECT vline_clips[]
Definition: dib.c:1508
static const RECT line_clips[]
Definition: dib.c:1527
static const DWORD polypoly_counts[]
Definition: dib.c:1560
static const POINT poly_lines[]
Definition: dib.c:1550
static const BYTE rle8_data[20]
Definition: dib.c:1611
static DWORD get_stride(const BITMAPINFO *bmi)
Definition: dib.c:1341
static const BITMAPINFOHEADER dib_brush_header_8888
Definition: dib.c:1604
static const BITMAPINFOHEADER dib_brush_header_4
Definition: dib.c:1608
static const DWORD four_by_four_data[16]
Definition: dib.c:1616
static const RECT wide_lines[]
Definition: dib.c:1538
static const BITMAPINFOHEADER dib_brush_header_8
Definition: dib.c:1607
static const POINT polypoly_lines[]
Definition: dib.c:1555
static const RECT rectangles[]
Definition: dib.c:1586
static const BITMAPINFOHEADER dib_brush_header_1
Definition: dib.c:1609
static void solid_patblt(HDC hdc, int x, int y, int width, int height, COLORREF color)
Definition: dib.c:1747
static const DWORD ddb_brush_bits[8]
Definition: dib.c:1621
static const BITMAPINFOHEADER dib_brush_header_555
Definition: dib.c:1606
static void compare_hash(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, const char *info)
Definition: dib.c:1472
static void reset_bounds(HDC hdc)
Definition: dib.c:1405
#define DWORD
Definition: nt_native.h:44
#define memset(x, y, z)
Definition: compat.h:39
BYTE BlendOp
Definition: wingdi.h:3205
BYTE BlendFlags
Definition: wingdi.h:3206
BYTE AlphaFormat
Definition: wingdi.h:3208
BYTE SourceConstantAlpha
Definition: wingdi.h:3207
USHORT biBitCount
Definition: precomp.h:34
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
RGBQUAD bmiColors[1]
Definition: wingdi.h:1923
UINT lbStyle
Definition: wingdi.h:2193
ULONG_PTR lbHatch
Definition: wingdi.h:2195
COLORREF lbColor
Definition: wingdi.h:2194
UCHAR rgbRed
Definition: bootanim.c:105
int32_t INT
Definition: typedefs.h:58
#define BI_RGB
Definition: uefivid.c:46
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:3389
#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:860
#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:1546
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:3388
#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:917
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1114
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 3139 of file dib.c.

3140{
3141 draw_text_2( hdc, bmi, bits, FALSE );
3142
3143 /* Rounding errors make these cases hard to test */
3144 if ((bmi->bmiHeader.biCompression == BI_BITFIELDS && ((DWORD*)bmi->bmiColors)[0] == 0x3f000) ||
3145 (bmi->bmiHeader.biBitCount == 16))
3146 return;
3147
3148 draw_text_2( hdc, bmi, bits, TRUE );
3149}
#define TRUE
Definition: types.h:120
static void draw_text_2(HDC hdc, const BITMAPINFO *bmi, BYTE *bits, BOOL aa)
Definition: dib.c:3010
ULONG biCompression
Definition: precomp.h:35

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 3010 of file dib.c.

3011{
3012 DWORD dib_size = get_dib_size(bmi), ret;
3013 LOGFONTA lf;
3014 HFONT font;
3015 GLYPHMETRICS gm;
3016 BYTE g_buf[10000];
3017 int i, stride, x, y;
3018 static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
3019 char *eto_hash = NULL, *diy_hash = NULL;
3020 static const char str[] = "Hello Wine";
3021 POINT origin, g_org;
3022 static const BYTE vals[4] = { 0x00, 0x00, 0x00, 0x00 };
3023 COLORREF bk_color, text_color;
3025 RECT rect;
3026
3027 for(i = 0; i < dib_size; i++)
3028 bits[i] = vals[i % 4];
3029
3030 memset( &lf, 0, sizeof(lf) );
3031 strcpy( lf.lfFaceName, "Tahoma" );
3032 lf.lfHeight = 24;
3034
3035 font = CreateFontIndirectA( &lf );
3036 font = SelectObject( hdc, font );
3037
3038 GetTextMetricsA( hdc, &tm );
3039 if (!(tm.tmPitchAndFamily & TMPF_VECTOR))
3040 {
3041 skip( "skipping as a bitmap font has been selected for Tahoma.\n" );
3043 return;
3044 }
3045
3046 SetTextColor( hdc, RGB(0xff, 0x00, 0x00) );
3049 origin.x = 10;
3050 origin.y = 100;
3051
3052 ExtTextOutA( hdc, origin.x, origin.y, 0, NULL, str, strlen(str), NULL );
3053 eto_hash = hash_dib( hdc, bmi, bits );
3054
3055 for(i = 0; i < dib_size; i++)
3056 bits[i] = vals[i % 4];
3057
3058 if (bmi->bmiHeader.biBitCount <= 8) aa = FALSE;
3059
3060 text_color = GetTextColor( hdc );
3061 for (i = 0; i < strlen(str); i++)
3062 {
3063 DWORD ggo_flags = aa ? GGO_GRAY4_BITMAP : GGO_BITMAP;
3064
3065 ret = GetGlyphOutlineA( hdc, str[i], ggo_flags, &gm, 0, NULL, &identity );
3066
3067 if (ret == GDI_ERROR) continue;
3068
3069 if (ret) GetGlyphOutlineA( hdc, str[i], ggo_flags, &gm, sizeof(g_buf), g_buf, &identity );
3070
3071 g_org.x = origin.x + gm.gmptGlyphOrigin.x;
3072 g_org.y = origin.y - gm.gmptGlyphOrigin.y;
3073
3074 origin.x += gm.gmCellIncX;
3075 origin.y += gm.gmCellIncY;
3076
3077 if (!ret) continue;
3078
3079 if (aa)
3080 {
3081 stride = (gm.gmBlackBoxX + 3) & ~3;
3082
3083 for (y = 0; y < gm.gmBlackBoxY; y++)
3084 {
3085 BYTE *g_ptr = g_buf + y * stride;
3086 COLORREF val;
3087
3088 for (x = 0; x < gm.gmBlackBoxX; x++)
3089 {
3090 if (g_ptr[x] <= 1) continue;
3091 if (g_ptr[x] >= 16) val = text_color;
3092 else
3093 {
3094 val = GetPixel( hdc, g_org.x + x, g_org.y + y );
3095 val = aa_colorref( val, text_color, g_ptr[x] );
3096 }
3097 SetPixel( hdc, g_org.x + x, g_org.y + y, val );
3098 }
3099 }
3100 }
3101 else
3102 {
3103 stride = ((gm.gmBlackBoxX + 31) >> 3) & ~3;
3104
3105 for (y = 0; y < gm.gmBlackBoxY; y++)
3106 {
3107 BYTE *g_ptr = g_buf + y * stride;
3108 for (x = 0; x < gm.gmBlackBoxX; x++)
3109 {
3110 if (g_ptr[x / 8] & masks[x % 8])
3111 SetPixel( hdc, g_org.x + x, g_org.y + y, text_color );
3112 }
3113 }
3114 }
3115 }
3116
3117 diy_hash = hash_dib( hdc, bmi, bits );
3118 ok( !strcmp( eto_hash, diy_hash ), "hash mismatch - aa %d\n", aa );
3119
3120 bk_color = GetBkColor( hdc );
3121 SetBkColor( hdc, RGB(128,64,32) );
3122
3123 SetRect( &rect, 0, 0, bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight );
3124 ret = ExtTextOutA( hdc, 10, 100, ETO_OPAQUE, &rect, str, -1, NULL );
3125 ok( !ret, "ExtTextOutA succeeded\n" );
3126
3127 diy_hash = hash_dib( hdc, bmi, bits );
3128 ok( !strcmp( eto_hash, diy_hash ), "hash mismatch - aa %d\n", aa );
3129
3130 SetBkColor( hdc, bk_color );
3131
3132 free( diy_hash );
3133 free( eto_hash );
3134
3135 font = SelectObject( hdc, font );
3136 DeleteObject( font );
3137}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
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:2998
static const BYTE masks[8]
Definition: dib.c:3008
static DWORD get_dib_size(const BITMAPINFO *bmi)
Definition: dib.c:1346
Definition: mk_font.cpp:20
const WCHAR * str
strcpy
Definition: string.h:131
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:2891
UINT gmBlackBoxY
Definition: wingdi.h:2889
UINT gmBlackBoxX
Definition: wingdi.h:2888
short gmCellIncY
Definition: wingdi.h:2892
POINT gmptGlyphOrigin
Definition: wingdi.h:2890
Definition: wingdi.h:2918
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define ANTIALIASED_QUALITY
Definition: wingdi.h:440
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:882
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 ETO_OPAQUE
Definition: wingdi.h:647
#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)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by draw_text().

◆ get_dib_size()

static DWORD get_dib_size ( const BITMAPINFO bmi)
inlinestatic

Definition at line 1346 of file dib.c.

1347{
1348 return get_stride(bmi) * abs(bmi->bmiHeader.biHeight);
1349}
#define abs(i)
Definition: fconv.c:206

Referenced by draw_text_2(), hash_dib(), and reset_bits().

◆ get_range()

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

Definition at line 2966 of file dib.c.

2967{
2968 *min_comp = (ramp[alpha] * text_comp) / 0xff;
2969 *max_comp = ramp[16 - alpha] + ((0xff - ramp[16 - alpha]) * text_comp) / 0xff;
2970}
static const BYTE ramp[17]
Definition: dib.c:2957

Referenced by aa_comp().

◆ get_stride()

static DWORD get_stride ( const BITMAPINFO bmi)
inlinestatic

Definition at line 1341 of file dib.c.

1342{
1343 return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3;
1344}

Referenced by draw_graphics(), and get_dib_size().

◆ hash_dib()

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

Definition at line 1364 of file dib.c.

1365{
1366 DWORD dib_size = get_dib_size(bmi);
1368 char *buf;
1369 BYTE hash_buf[20];
1370 DWORD hash_size = sizeof(hash_buf);
1371 int i;
1372 static const char *hex = "0123456789abcdef";
1373
1374 if(!crypt_prov) return NULL;
1375
1376 if(!CryptCreateHash(crypt_prov, CALG_SHA1, 0, 0, &hash)) return NULL;
1377
1378 if (!bits)
1379 {
1380 void *ddb_bits = malloc(dib_size);
1381 GetBitmapBits(GetCurrentObject(hdc, OBJ_BITMAP), dib_size, ddb_bits);
1382 CryptHashData(hash, ddb_bits, dib_size, 0);
1383 free(ddb_bits);
1384 }
1385 else CryptHashData(hash, bits, dib_size, 0);
1386
1387 CryptGetHashParam(hash, HP_HASHVAL, NULL, &hash_size, 0);
1388 if(hash_size != sizeof(hash_buf)) return NULL;
1389
1390 CryptGetHashParam(hash, HP_HASHVAL, hash_buf, &hash_size, 0);
1392
1393 buf = malloc(hash_size * 2 + 1);
1394
1395 for(i = 0; i < hash_size; i++)
1396 {
1397 buf[i * 2] = hex[hash_buf[i] >> 4];
1398 buf[i * 2 + 1] = hex[hash_buf[i] & 0xf];
1399 }
1400 buf[i * 2] = '\0';
1401
1402 return buf;
1403}
ios_base &_STLP_CALL hex(ios_base &__s)
Definition: _ios_base.h:324
#define malloc
Definition: debug_ros.c:4
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:753
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1675
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:929
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1836
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HCRYPTPROV crypt_prov
Definition: dib.c:34
#define OBJ_BITMAP
Definition: objidl.idl:1020
#define CALG_SHA1
Definition: wincrypt.h:2060
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:59
#define HP_HASHVAL
Definition: wincrypt.h:2387
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428

Referenced by compare_hash_broken_todo(), and draw_text_2().

◆ reset_bits()

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

Definition at line 1351 of file dib.c.

1352{
1353 DWORD size = get_dib_size( bmi );
1354 if (bits) memset( bits, 0xcc, size );
1355 else
1356 {
1357 void *ddb_bits = malloc( size );
1358 memset( ddb_bits, 0xcc, size );
1360 free( ddb_bits );
1361 }
1362}
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI SetBitmapBits(_In_ HBITMAP hbm, _In_ DWORD cb, _In_reads_bytes_(cb) CONST VOID *pvBits)

Referenced by compare_hash_broken_todo(), and draw_graphics().

◆ reset_bounds()

static void reset_bounds ( HDC  hdc)
static

Definition at line 1405 of file dib.c.

1406{
1409}
static const RECT graphics_bounds[]
Definition: dib.c:1266
#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 72 of file dib.c.

73{
74 return (((rop & 0xcc0000) >> 2) != (rop & 0x330000));
75}
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 1747 of file dib.c.

1748{
1749 HBRUSH brush = CreateSolidBrush( color );
1750 brush = SelectObject( hdc, brush );
1751 PatBlt( hdc, x, y, width, height, PATCOPY );
1752 DeleteObject( SelectObject( hdc, brush ) );
1753}
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 3532 of file dib.c.

3533{
3535
3537
3539}
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:661
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:3151
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2273

◆ test_simple_graphics()

static void test_simple_graphics ( void  )
static

Definition at line 3151 of file dib.c.

3152{
3153 char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
3154 BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
3155 RGBQUAD *colors = bmi->bmiColors;
3156 DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
3157 HDC mem_dc;
3158 BYTE *bits;
3159 HBITMAP dib, orig_bm;
3160 DIBSECTION ds;
3161 HPALETTE default_palette, old_hpal;
3162 int i;
3163
3164 mem_dc = CreateCompatibleDC(NULL);
3165
3166 /* a8r8g8b8 */
3167 trace("8888\n");
3168 memset(bmi, 0, sizeof(bmibuf));
3169 bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
3170 bmi->bmiHeader.biHeight = 512;
3171 bmi->bmiHeader.biWidth = 512;
3172 bmi->bmiHeader.biBitCount = 32;
3173 bmi->bmiHeader.biPlanes = 1;
3175
3176 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3177 ok(dib != NULL, "ret NULL\n");
3178 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3179 ok(ds.dsBitfields[0] == 0, "got %08lx\n", ds.dsBitfields[0]);
3180 ok(ds.dsBitfields[1] == 0, "got %08lx\n", ds.dsBitfields[1]);
3181 ok(ds.dsBitfields[2] == 0, "got %08lx\n", ds.dsBitfields[2]);
3182 ok(ds.dsBmih.biCompression == BI_RGB, "got %lx\n", ds.dsBmih.biCompression);
3183
3184 orig_bm = SelectObject(mem_dc, dib);
3185
3186 default_palette = create_default_palette( 8 );
3187 old_hpal = SelectPalette( mem_dc, default_palette, FALSE );
3188
3189 dst_format = "8888";
3191 draw_graphics(mem_dc, bmi, bits);
3192 draw_text(mem_dc, bmi, bits);
3193
3194 SelectObject(mem_dc, orig_bm);
3195 DeleteObject(dib);
3196
3197 /* a8r8g8b8 - bitfields. Should be the same as the regular 32 bit case.*/
3198 trace("8888 - bitfields\n");
3199 bmi->bmiHeader.biBitCount = 32;
3201 bit_fields[0] = 0xff0000;
3202 bit_fields[1] = 0x00ff00;
3203 bit_fields[2] = 0x0000ff;
3204
3205 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3206 ok(dib != NULL, "ret NULL\n");
3207 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3208 ok(ds.dsBitfields[0] == 0xff0000, "got %08lx\n", ds.dsBitfields[0]);
3209 ok(ds.dsBitfields[1] == 0x00ff00, "got %08lx\n", ds.dsBitfields[1]);
3210 ok(ds.dsBitfields[2] == 0x0000ff, "got %08lx\n", ds.dsBitfields[2]);
3211 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3212
3213 orig_bm = SelectObject(mem_dc, dib);
3214 SelectPalette( mem_dc, default_palette, FALSE );
3215
3216 dst_format = "8888 - bitfields";
3218 draw_graphics(mem_dc, bmi, bits);
3219 draw_text(mem_dc, bmi, bits);
3220
3221 SelectObject(mem_dc, orig_bm);
3222 DeleteObject(dib);
3223
3224 /* a8b8g8r8. */
3225 trace("a8b8g8r8\n");
3226 bmi->bmiHeader.biBitCount = 32;
3228 bit_fields[0] = 0x0000ff;
3229 bit_fields[1] = 0x00ff00;
3230 bit_fields[2] = 0xff0000;
3231
3232 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3233 ok(dib != NULL, "ret NULL\n");
3234 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3235 ok(ds.dsBitfields[0] == 0x0000ff, "got %08lx\n", ds.dsBitfields[0]);
3236 ok(ds.dsBitfields[1] == 0x00ff00, "got %08lx\n", ds.dsBitfields[1]);
3237 ok(ds.dsBitfields[2] == 0xff0000, "got %08lx\n", ds.dsBitfields[2]);
3238 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3239
3240 orig_bm = SelectObject(mem_dc, dib);
3241
3242 dst_format = "a8b8g8r8";
3244 draw_graphics(mem_dc, bmi, bits);
3245 draw_text(mem_dc, bmi, bits);
3246
3247 SelectObject(mem_dc, orig_bm);
3248 DeleteObject(dib);
3249
3250 /* r10g10b10. */
3251 trace("r10g10b10\n");
3252 bmi->bmiHeader.biBitCount = 32;
3254 bit_fields[0] = 0x3ff00000;
3255 bit_fields[1] = 0x000ffc00;
3256 bit_fields[2] = 0x000003ff;
3257
3258 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3259 ok(dib != NULL, "ret NULL\n");
3260 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3261 ok(ds.dsBitfields[0] == 0x3ff00000, "got %08lx\n", ds.dsBitfields[0]);
3262 ok(ds.dsBitfields[1] == 0x000ffc00, "got %08lx\n", ds.dsBitfields[1]);
3263 ok(ds.dsBitfields[2] == 0x000003ff, "got %08lx\n", ds.dsBitfields[2]);
3264 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3265
3266 orig_bm = SelectObject(mem_dc, dib);
3267
3268 dst_format = "r10g10b10";
3270 draw_graphics(mem_dc, bmi, bits);
3271 draw_text(mem_dc, bmi, bits);
3272
3273 SelectObject(mem_dc, orig_bm);
3274 DeleteObject(dib);
3275
3276 /* r6g6b6. */
3277 trace("r6g6b6\n");
3278 bmi->bmiHeader.biBitCount = 32;
3280 bit_fields[0] = 0x0003f000;
3281 bit_fields[1] = 0x00000fc0;
3282 bit_fields[2] = 0x0000003f;
3283
3284 dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3285 ok(dib != NULL, "ret NULL\n");
3286 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3287 ok(ds.dsBitfields[0] == 0x0003f000, "got %08lx\n", ds.dsBitfields[0]);
3288 ok(ds.dsBitfields[1] == 0x00000fc0, "got %08lx\n", ds.dsBitfields[1]);
3289 ok(ds.dsBitfields[2] == 0x0000003f, "got %08lx\n", ds.dsBitfields[2]);
3290 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3291
3292 orig_bm = SelectObject(mem_dc, dib);
3293
3294 dst_format = "r6g6b6";
3296 draw_graphics(mem_dc, bmi, bits);
3297 draw_text(mem_dc, bmi, bits);
3298
3299 SelectObject(mem_dc, orig_bm);
3300 DeleteObject(dib);
3301
3302 /* 24 */
3303 trace("24\n");
3304 bmi->bmiHeader.biBitCount = 24;
3306
3307 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3308 ok(dib != NULL, "ret NULL\n");
3309 orig_bm = SelectObject(mem_dc, dib);
3310
3311 dst_format = "24";
3313 draw_graphics(mem_dc, bmi, bits);
3314 draw_text(mem_dc, bmi, bits);
3315
3316 SelectObject(mem_dc, orig_bm);
3317 DeleteObject(dib);
3318
3319 /* r5g5b5 */
3320 trace("555\n");
3321 bmi->bmiHeader.biBitCount = 16;
3323
3324 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3325 ok(dib != NULL, "ret NULL\n");
3326 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3327 ok(ds.dsBitfields[0] == 0x7c00, "got %08lx\n", ds.dsBitfields[0]);
3328 ok(ds.dsBitfields[1] == 0x03e0, "got %08lx\n", ds.dsBitfields[1]);
3329 ok(ds.dsBitfields[2] == 0x001f, "got %08lx\n", ds.dsBitfields[2]);
3330 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3331
3332 orig_bm = SelectObject(mem_dc, dib);
3333
3334 dst_format = "r5g5b5";
3336 draw_graphics(mem_dc, bmi, bits);
3337 draw_text(mem_dc, bmi, bits);
3338
3339 SelectObject(mem_dc, orig_bm);
3340 DeleteObject(dib);
3341
3342 /* r4g4b4 */
3343 trace("444\n");
3344 bmi->bmiHeader.biBitCount = 16;
3346 bit_fields[0] = 0x0f00;
3347 bit_fields[1] = 0x00f0;
3348 bit_fields[2] = 0x000f;
3349 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3350 ok(dib != NULL, "ret NULL\n");
3351 ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
3352 ok(ds.dsBitfields[0] == 0x0f00, "got %08lx\n", ds.dsBitfields[0]);
3353 ok(ds.dsBitfields[1] == 0x00f0, "got %08lx\n", ds.dsBitfields[1]);
3354 ok(ds.dsBitfields[2] == 0x000f, "got %08lx\n", ds.dsBitfields[2]);
3355 ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %lx\n", ds.dsBmih.biCompression);
3356
3357 orig_bm = SelectObject(mem_dc, dib);
3358
3359 dst_format = "r4g4b4";
3361 draw_graphics(mem_dc, bmi, bits);
3362 draw_text(mem_dc, bmi, bits);
3363
3364 SelectObject(mem_dc, orig_bm);
3365 DeleteObject(dib);
3366
3367 /* 8 color */
3368 trace("8 color\n");
3369 bmi->bmiHeader.biBitCount = 8;
3371 bmi->bmiHeader.biClrUsed = 236;
3372 for (i = 0; i < 236; i++)
3373 {
3374 colors[i].rgbRed = (i & 0x07) << 5;
3375 colors[i].rgbGreen = (i & 0x38) << 2;
3376 colors[i].rgbBlue = i & 0xc0;
3377 }
3378 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3379 ok(dib != NULL, "ret NULL\n");
3380
3381 orig_bm = SelectObject(mem_dc, dib);
3382
3383 dst_format = "8 color";
3385 draw_graphics(mem_dc, bmi, bits);
3386 draw_text(mem_dc, bmi, bits);
3387
3388 SelectObject(mem_dc, orig_bm);
3389 DeleteObject(dib);
3390
3391 /* 8 grayscale */
3392 trace("8 grayscale\n");
3393 bmi->bmiHeader.biBitCount = 8;
3395 bmi->bmiHeader.biClrUsed = 256;
3396 for (i = 0; i < 256; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i;
3397
3398 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3399 ok(dib != NULL, "ret NULL\n");
3400
3401 orig_bm = SelectObject(mem_dc, dib);
3402
3403 dst_format = "8 grayscale";
3405 draw_graphics(mem_dc, bmi, bits);
3406 draw_text(mem_dc, bmi, bits);
3407
3408 SelectObject(mem_dc, orig_bm);
3409 DeleteObject(dib);
3410
3411 /* 8 */
3412 trace("8\n");
3413 bmi->bmiHeader.biBitCount = 8;
3415 bmi->bmiHeader.biClrUsed = 5;
3416 colors[0].rgbRed = 0xff;
3417 colors[0].rgbGreen = 0xff;
3418 colors[0].rgbBlue = 0xff;
3419 colors[1].rgbRed = 0;
3420 colors[1].rgbGreen = 0;
3421 colors[1].rgbBlue = 0;
3422 colors[2].rgbRed = 0xff;
3423 colors[2].rgbGreen = 0;
3424 colors[2].rgbBlue = 0;
3425 colors[3].rgbRed = 0;
3426 colors[3].rgbGreen = 0xff;
3427 colors[3].rgbBlue = 0;
3428 colors[4].rgbRed = 0;
3429 colors[4].rgbGreen = 0;
3430 colors[4].rgbBlue = 0xff;
3431
3432 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3433 ok(dib != NULL, "ret NULL\n");
3434
3435 orig_bm = SelectObject(mem_dc, dib);
3436
3437 dst_format = "8";
3439 draw_graphics(mem_dc, bmi, bits);
3440 draw_text(mem_dc, bmi, bits);
3441
3442 SelectObject(mem_dc, orig_bm);
3443 DeleteObject(dib);
3444
3445 /* 4 */
3446 trace("4\n");
3447 bmi->bmiHeader.biBitCount = 4;
3448
3449 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3450 ok(dib != NULL, "ret NULL\n");
3451
3452 orig_bm = SelectObject(mem_dc, dib);
3454
3455 dst_format = "4";
3457 draw_graphics(mem_dc, bmi, bits);
3458 draw_text(mem_dc, bmi, bits);
3459
3460 SelectObject(mem_dc, orig_bm);
3461 DeleteObject(dib);
3462
3463 /* 4 grayscale */
3464 trace("4 grayscale\n");
3465 bmi->bmiHeader.biClrUsed = 16;
3466 for (i = 0; i < 16; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i * 17;
3467
3468 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3469 ok(dib != NULL, "ret NULL\n");
3470
3471 orig_bm = SelectObject(mem_dc, dib);
3472
3473 dst_format = "4 grayscale";
3475 draw_graphics(mem_dc, bmi, bits);
3476 draw_text(mem_dc, bmi, bits);
3477
3478 SelectObject(mem_dc, orig_bm);
3479 DeleteObject(dib);
3480
3481 /* 1 */
3482 trace("1\n");
3483 bmi->bmiHeader.biBitCount = 1;
3484 bmi->bmiHeader.biClrUsed = 2;
3485
3486 colors[0].rgbRed = 0x00;
3487 colors[0].rgbGreen = 0x01;
3488 colors[0].rgbBlue = 0xff;
3489 colors[1].rgbRed = 0xff;
3490 colors[1].rgbGreen = 0x00;
3491 colors[1].rgbBlue = 0x00;
3492
3493 dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
3494 ok(dib != NULL, "ret NULL\n");
3495
3496 orig_bm = SelectObject(mem_dc, dib);
3498
3499 dst_format = "1";
3501 draw_graphics(mem_dc, bmi, bits);
3502 draw_text(mem_dc, bmi, bits);
3503
3504 DeleteObject( SelectPalette( mem_dc, old_hpal, FALSE ));
3505 SelectObject(mem_dc, orig_bm);
3506 DeleteObject(dib);
3507
3508 /* 1 ddb */
3509 trace("1 ddb\n");
3510
3511 dib = CreateBitmap( 512, 512, 1, 1, NULL );
3512 ok(dib != NULL, "ret NULL\n");
3513
3514 orig_bm = SelectObject(mem_dc, dib);
3515
3516 dst_format = "1 ddb";
3518 draw_graphics(mem_dc, bmi, NULL);
3519
3520 SetTextColor( mem_dc, RGB(240,230,220) );
3521 SetBkColor( mem_dc, RGB(10,20,30) );
3522 dst_format = "1 ddb custom colors inverted";
3524 draw_graphics(mem_dc, bmi, NULL);
3525
3526 SelectObject(mem_dc, orig_bm);
3527 DeleteObject(dib);
3528
3529 DeleteDC(mem_dc);
3530}
#define trace
Definition: atltest.h:70
#define ds
Definition: i386-dis.c:443
static const char * sha1_graphics_r6g6b6[]
Definition: dib.c:365
static const char * sha1_graphics_4[]
Definition: dib.c:865
static const char * sha1_graphics_r5g5b5[]
Definition: dib.c:509
static const char * sha1_graphics_a8r8g8b8[]
Definition: dib.c:77
static const char * sha1_graphics_8_grayscale[]
Definition: dib.c:722
static const char * sha1_graphics_24[]
Definition: dib.c:437
static const char * sha1_graphics_a8r8g8b8_bitfields[]
Definition: dib.c:149
static const char * sha1_graphics_a8b8g8r8[]
Definition: dib.c:221
static const char * sha1_graphics_r10g10b10[]
Definition: dib.c:293
static void draw_graphics(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
Definition: dib.c:1755
static void draw_text(HDC hdc, const BITMAPINFO *bmi, BYTE *bits)
Definition: dib.c:3139
static const char * sha1_graphics_1_ddb[]
Definition: dib.c:1080
static const char * sha1_graphics_8_color[]
Definition: dib.c:651
static const char * sha1_graphics_r4g4b4[]
Definition: dib.c:580
static const char * sha1_graphics_1_ddb_inverted[]
Definition: dib.c:1173
static const char * sha1_graphics_1[]
Definition: dib.c:1007
static const char * sha1_graphics_8[]
Definition: dib.c:794
static HPALETTE create_default_palette(int bpp)
Definition: dib.c:1705
static const char * sha1_graphics_4_grayscale[]
Definition: dib.c:936
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 1477 of file dib.c.

Referenced by draw_graphics().

◆ crypt_prov

HCRYPTPROV crypt_prov
static

Definition at line 34 of file dib.c.

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

◆ current_bounds

const RECT* current_bounds
static

Definition at line 1338 of file dib.c.

Referenced by compare_bounds(), and reset_bounds().

◆ current_sha1

const char** current_sha1
static

Definition at line 1337 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 1621 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 1624 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 1629 of file dib.c.

Referenced by create_default_palette().

◆ default_palette_8

const RGBQUAD default_palette_8[256]
static

Definition at line 1637 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 1609 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 1605 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 1608 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 1606 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 1607 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 1604 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 1616 of file dib.c.

Referenced by draw_graphics().

◆ graphics_bounds

const RECT graphics_bounds[]
static

Definition at line 1266 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 1489 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 1527 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 1565 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 1550 of file dib.c.

Referenced by draw_graphics().

◆ polypoly_counts

const DWORD polypoly_counts[]
static
Initial value:
=
{
}

Definition at line 1560 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 1555 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 1586 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 1611 of file dib.c.

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

◆ rop3

const DWORD rop3[256]
static

Definition at line 36 of file dib.c.

Referenced by draw_graphics().

◆ sha1_graphics_1

const char* sha1_graphics_1[]
static

Definition at line 1007 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_1_ddb

const char* sha1_graphics_1_ddb[]
static

Definition at line 1080 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_1_ddb_inverted

const char* sha1_graphics_1_ddb_inverted[]
static

Definition at line 1173 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_24

const char* sha1_graphics_24[]
static

Definition at line 437 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_4

const char* sha1_graphics_4[]
static

Definition at line 865 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_4_grayscale

const char* sha1_graphics_4_grayscale[]
static

Definition at line 936 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8

const char* sha1_graphics_8[]
static

Definition at line 794 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8_color

const char* sha1_graphics_8_color[]
static

Definition at line 651 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_8_grayscale

const char* sha1_graphics_8_grayscale[]
static

Definition at line 722 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8b8g8r8

const char* sha1_graphics_a8b8g8r8[]
static

Definition at line 221 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8r8g8b8

const char* sha1_graphics_a8r8g8b8[]
static

Definition at line 77 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_a8r8g8b8_bitfields

const char* sha1_graphics_a8r8g8b8_bitfields[]
static

Definition at line 149 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r10g10b10

const char* sha1_graphics_r10g10b10[]
static

Definition at line 293 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r4g4b4

const char* sha1_graphics_r4g4b4[]
static

Definition at line 580 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r5g5b5

const char* sha1_graphics_r5g5b5[]
static

Definition at line 509 of file dib.c.

Referenced by test_simple_graphics().

◆ sha1_graphics_r6g6b6

const char* sha1_graphics_r6g6b6[]
static

Definition at line 365 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 1508 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 1538 of file dib.c.

Referenced by draw_graphics().