ReactOS 0.4.16-dev-306-g647d351
PatBlt.c File Reference
#include "precomp.h"
Include dependency graph for PatBlt.c:

Go to the source code of this file.

Functions

void Test_PatBlt_Params ()
 
void Test_BrushOrigin ()
 
 START_TEST (PatBlt)
 

Variables

HBITMAP ghbmpTarget
 
PULONG gpulTargetBits
 
HDC hdcTarget
 

Function Documentation

◆ START_TEST()

START_TEST ( PatBlt  )

Definition at line 156 of file PatBlt.c.

157{
158 BITMAPINFO bmi;
159
160 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
161 bmi.bmiHeader.biWidth = 16;
162 bmi.bmiHeader.biHeight = -16;
163 bmi.bmiHeader.biPlanes = 1;
164 bmi.bmiHeader.biBitCount = 32;
166 bmi.bmiHeader.biSizeImage = 0;
169 bmi.bmiHeader.biClrUsed = 0;
172 &bmi,
175 NULL,
176 0);
177 if (!ghbmpTarget)
178 {
179 printf("Couln not create target bitmap\n");
180 return;
181 }
182
184 if (!hdcTarget)
185 {
186 printf("Couln not create target dc\n");
187 return;
188 }
189
191 {
192 printf("Failed to select bitmap\n");
193 return;
194 }
195
197
199}
PULONG gpulTargetBits
Definition: PatBlt.c:12
HDC hdcTarget
Definition: PatBlt.c:13
HBITMAP ghbmpTarget
Definition: PatBlt.c:11
void Test_PatBlt_Params()
Definition: PatBlt.c:15
void Test_BrushOrigin()
Definition: PatBlt.c:111
#define NULL
Definition: types.h:112
#define BI_RGB
Definition: precomp.h:56
#define printf
Definition: freeldr.h:97
ULONG biClrImportant
Definition: precomp.h:52
USHORT biBitCount
Definition: precomp.h:46
LONG biYPelsPerMeter
Definition: precomp.h:50
ULONG biCompression
Definition: precomp.h:47
LONG biXPelsPerMeter
Definition: precomp.h:49
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)

◆ Test_BrushOrigin()

void Test_BrushOrigin ( )

Definition at line 111 of file PatBlt.c.

112{
113 ULONG aulBits[2] = {0x5555AAAA, 0};
115 HBRUSH hbr;
116 BOOL ret;
117
118 hbmp = CreateBitmap(2, 2, 1, 1, aulBits);
119 if (!hbmp)
120 {
121 printf("Couln not create a bitmap\n");
122 return;
123 }
124
126 if (!hbr)
127 {
128 printf("Couln not create a bitmap\n");
129 return;
130 }
131
132 if (!SelectObject(hdcTarget, hbr))
133 {
134 printf("failed to select pattern brush\n");
135 return;
136 }
137
138 ret = PatBlt(hdcTarget, 0, 0, 2, 2, PATCOPY);
139 ok_long(ret, 1);
140 ok_long(gpulTargetBits[0], 0xffffff);
141 ok_long(gpulTargetBits[1], 0);
142 ok_long(gpulTargetBits[16], 0);
143 ok_long(gpulTargetBits[17], 0xffffff);
144 //printf("0x%lx, 0x%lx\n", gpulTargetBits[0], gpulTargetBits[1]);
145
146 ret = PatBlt(hdcTarget, 1, 0, 2, 2, PATCOPY);
147 ok_long(ret, 1);
148 ok_long(gpulTargetBits[0], 0xffffff);
149 ok_long(gpulTargetBits[1], 0);
150 ok_long(gpulTargetBits[2], 0xffffff);
151 ok_long(gpulTargetBits[16], 0);
152 ok_long(gpulTargetBits[17], 0xffffff);
153 ok_long(gpulTargetBits[18], 0);
154}
#define ok_long(expression, result)
Definition: atltest.h:133
HBITMAP hbmp
unsigned int BOOL
Definition: ntddk_ex.h:94
static HBITMAP
Definition: button.c:44
uint32_t ULONG
Definition: typedefs.h:59
int ret
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)

Referenced by START_TEST().

◆ Test_PatBlt_Params()

void Test_PatBlt_Params ( )

Definition at line 15 of file PatBlt.c.

16{
17 BOOL ret;
18 ULONG i, rop;
19 HDC hdc;
21 HGDIOBJ hOldBitmap;
22
23 /* Test a rop that contains only the operation index */
24 ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
25 ok_long(ret, 1);
26
27 /* Test a rop that contains arbitrary values outside the operation index */
28 ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
29 ok_long(ret, 1);
30
31 /* Test an invalid rop */
32 SetLastError(0);
33 ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
34 ok_err(0);
35
36 /* Test all rops */
37 for (i = 0; i < 256; i++)
38 {
39 rop = i << 16;
40 ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop);
41
42 /* Only these should succeed (they use no source) */
43 if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) ||
44 (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) ||
45 (i == 170) || (i == 175) || (i == 240) || (i == 245) ||
46 (i == 250) || (i == 255))
47 {
48 ok(ret == 1, "index %ld failed, but should succeed\n", i);
49 }
50 else
51 {
52 ok(ret == 0, "index %ld succeeded, but should fail\n", i);
53 }
54 }
55
56 /* Test quaternary rop, the background part is simply ignored */
57 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT));
58 ok_long(ret, 1);
59 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY));
60 ok_long(ret, 1);
61 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY));
62 ok_long(ret, 0);
63
64 /* Test an info DC */
65 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
66 ok(hdc != 0, "\n");
67 SetLastError(0);
68 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
69 ok_err(0);
71
72 /* Test a mem DC without selecting a bitmap */
74 ok(hdc != 0, "\n");
75 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
76 ok_err(0);
78
79 /* Test with bitmap and negative values */
82 hOldBitmap = SelectObject(hdc, hBitmap);
84 ok_long(PatBlt(hdc, 2, 2, -1, 1, PATCOPY), TRUE);
85 ok_long(GetPixel(hdc, 1, 1), RGB(0, 0, 0));
86 ok_long(GetPixel(hdc, 1, 2), RGB(255, 255, 255));
87 ok_long(GetPixel(hdc, 1, 3), RGB(0, 0, 0));
88 ok_long(GetPixel(hdc, 2, 1), RGB(0, 0, 0));
89 ok_long(GetPixel(hdc, 2, 2), RGB(0, 0, 0));
90 SetPixel(hdc, 1, 2, RGB(0, 0, 0));
91 ok_long(PatBlt(hdc, 2, 2, 1, -1, PATCOPY), TRUE);
92 ok_long(GetPixel(hdc, 1, 2), RGB(0, 0, 0));
93 ok_long(GetPixel(hdc, 1, 3), RGB(0, 0, 0));
94 ok_long(GetPixel(hdc, 2, 1), RGB(255, 255, 255));
95 ok_long(GetPixel(hdc, 2, 2), RGB(0, 0, 0));
96 ok_long(GetPixel(hdc, 2, 3), RGB(0, 0, 0));
97 SetPixel(hdc, 2, 1, RGB(0, 0, 0));
98 ok_long(PatBlt(hdc, 3, 2, -2, -1, PATCOPY), TRUE);
99 ok_long(GetPixel(hdc, 0, 2), RGB(0, 0, 0));
100 ok_long(GetPixel(hdc, 0, 3), RGB(0, 0, 0));
101 ok_long(GetPixel(hdc, 1, 1), RGB(255, 255, 255));
102 ok_long(GetPixel(hdc, 1, 2), RGB(0, 0, 0));
103 ok_long(GetPixel(hdc, 1, 3), RGB(0, 0, 0));
104 ok_long(GetPixel(hdc, 2, 1), RGB(255, 255, 255));
105 ok_long(GetPixel(hdc, 2, 2), RGB(0, 0, 0));
106 ok_long(GetPixel(hdc, 2, 3), RGB(0, 0, 0));
107 DeleteObject(SelectObject(hdc, hOldBitmap));
108 DeleteDC(hdc);
109}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define TRUE
Definition: types.h:120
static HBITMAP hBitmap
Definition: timezone.c:26
#define SetLastError(x)
Definition: compat.h:752
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
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
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
HGDIOBJ WINAPI GetStockObject(_In_ int)
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
#define PATINVERT
Definition: wingdi.h:328
#define SRCCOPY
Definition: wingdi.h:333
#define WHITE_BRUSH
Definition: wingdi.h:902
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)
#define MAKEROP4(f, b)
Definition: wingdi.h:2946

Referenced by START_TEST().

Variable Documentation

◆ ghbmpTarget

HBITMAP ghbmpTarget

Definition at line 11 of file PatBlt.c.

Referenced by START_TEST().

◆ gpulTargetBits

PULONG gpulTargetBits

Definition at line 12 of file PatBlt.c.

Referenced by START_TEST(), and Test_BrushOrigin().

◆ hdcTarget