ReactOS  0.4.14-dev-41-g31d7680
PatBlt.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for ...
5  * PROGRAMMERS: Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
13 
15 {
16  BOOL ret;
17  ULONG i, rop;
18  HDC hdc;
19 
20  /* Test a rop that contains only the operation index */
21  ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
22  ok_long(ret, 1);
23 
24  /* Test a rop that contains arbitrary values outside the operation index */
25  ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
26  ok_long(ret, 1);
27 
28  /* Test an invalid rop */
29  SetLastError(0);
30  ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
31  ok_err(0);
32 
33  /* Test all rops */
34  for (i = 0; i < 256; i++)
35  {
36  rop = i << 16;
37  ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop);
38 
39  /* Only these should succeed (they use no source) */
40  if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) ||
41  (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) ||
42  (i == 170) || (i == 175) || (i == 240) || (i == 245) ||
43  (i == 250) || (i == 255))
44  {
45  ok(ret == 1, "index %ld failed, but should succeed\n", i);
46  }
47  else
48  {
49  ok(ret == 0, "index %ld succeeded, but should fail\n", i);
50  }
51  }
52 
53  /* Test quaternary rop, the background part is simply ignored */
54  ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT));
55  ok_long(ret, 1);
56  ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY));
57  ok_long(ret, 1);
58  ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY));
59  ok_long(ret, 0);
60 
61  /* Test an info DC */
62  hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
63  ok(hdc != 0, "\n");
64  SetLastError(0);
65  ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
66  ok_err(0);
67  DeleteDC(hdc);
68 
69  /* Test a mem DC without selecting a bitmap */
71  ok(hdc != 0, "\n");
72  ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1);
73  ok_err(0);
74  DeleteDC(hdc);
75 
76 
77 
78 }
79 
81 {
82  ULONG aulBits[2] = {0x5555AAAA, 0};
83  HBITMAP hbmp;
84  HBRUSH hbr;
85  BOOL ret;
86 
87  hbmp = CreateBitmap(2, 2, 1, 1, aulBits);
88  if (!hbmp)
89  {
90  printf("Couln not create a bitmap\n");
91  return;
92  }
93 
94  hbr = CreatePatternBrush(hbmp);
95  if (!hbr)
96  {
97  printf("Couln not create a bitmap\n");
98  return;
99  }
100 
101  if (!SelectObject(hdcTarget, hbr))
102  {
103  printf("failed to select pattern brush\n");
104  return;
105  }
106 
107  ret = PatBlt(hdcTarget, 0, 0, 2, 2, PATCOPY);
108  ok_long(ret, 1);
109  ok_long(gpulTargetBits[0], 0xffffff);
110  ok_long(gpulTargetBits[1], 0);
111  ok_long(gpulTargetBits[16], 0);
112  ok_long(gpulTargetBits[17], 0xffffff);
113  //printf("0x%lx, 0x%lx\n", gpulTargetBits[0], gpulTargetBits[1]);
114 
115  ret = PatBlt(hdcTarget, 1, 0, 2, 2, PATCOPY);
116  ok_long(ret, 1);
117  ok_long(gpulTargetBits[0], 0xffffff);
118  ok_long(gpulTargetBits[1], 0);
119  ok_long(gpulTargetBits[2], 0xffffff);
120  ok_long(gpulTargetBits[16], 0);
121  ok_long(gpulTargetBits[17], 0xffffff);
122  ok_long(gpulTargetBits[18], 0);
123 
124 }
125 
127 {
128  BITMAPINFO bmi;
129 
130  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
131  bmi.bmiHeader.biWidth = 16;
132  bmi.bmiHeader.biHeight = -16;
133  bmi.bmiHeader.biPlanes = 1;
134  bmi.bmiHeader.biBitCount = 32;
136  bmi.bmiHeader.biSizeImage = 0;
137  bmi.bmiHeader.biXPelsPerMeter = 1;
138  bmi.bmiHeader.biYPelsPerMeter = 1;
139  bmi.bmiHeader.biClrUsed = 0;
140  bmi.bmiHeader.biClrImportant = 0;
142  &bmi,
145  NULL,
146  0);
147  if (!ghbmpTarget)
148  {
149  printf("Couln not create target bitmap\n");
150  return;
151  }
152 
154  if (!hdcTarget)
155  {
156  printf("Couln not create target dc\n");
157  return;
158  }
159 
160 
162  {
163  printf("Failed to select bitmap\n");
164  return;
165  }
166 
168 
170 
171 
172 }
173 
HBITMAP ghbmpTarget
Definition: PatBlt.c:10
#define PATINVERT
Definition: wingdi.h:327
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
void Test_BrushOrigin()
Definition: PatBlt.c:80
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define ok_long(expression, result)
Definition: atltest.h:133
LONG biYPelsPerMeter
Definition: amvideo.idl:38
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
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
unsigned int BOOL
Definition: ntddk_ex.h:94
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
#define MAKEROP4(f, b)
Definition: wingdi.h:2941
HBITMAP hbmp
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
DWORD biSizeImage
Definition: amvideo.idl:36
#define SetLastError(x)
Definition: compat.h:409
PULONG gpulTargetBits
Definition: PatBlt.c:11
int ret
void Test_PatBlt_Params()
Definition: PatBlt.c:14
HDC hdc
Definition: main.c:9
#define ok_err(error)
Definition: atltest.h:124
HDC hdcTarget
Definition: PatBlt.c:12
#define PATCOPY
Definition: wingdi.h:334
BOOL WINAPI DeleteDC(_In_ HDC)
START_TEST(PatBlt)
Definition: PatBlt.c:126
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define ok(value,...)
Definition: atltest.h:57
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define BI_RGB
Definition: precomp.h:34
#define SRCCOPY
Definition: wingdi.h:332
#define printf
Definition: config.h:203
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)