ReactOS 0.4.16-dev-340-g0540c21
FrameRgn.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 FrameRgn
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
10#include "init.h"
11
12#if 0
13BOOL
14MyFrameRgn(
15 HDC hdc,
16 HRGN hrgn,
17 HBRUSH hbr,
18 INT cx,
19 INT cy)
20{
21 HRGN hrgnTemp;
22
23 hrgnTemp = CreateRectRgn(0, 0, 0, 0);
24 if (hrgnTemp == NULL)
25 {
26 return FALSE;
27 }
28
29 if (CombineRgn(hrgnTemp, hrgn, NULL, RGN_COPY) == ERROR)
30 goto Failure;
31
32 if (OffsetRgn(hrgn, cx, cy) == ERROR)
33 goto Failure;
34
35 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
36 goto Failure;
37
38 if (OffsetRgn(hrgn, -2 * cx, 0) == ERROR)
39 goto Failure;
40
41 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
42 goto Failure;
43
44 if (OffsetRgn(hrgn, 0, -2 * cy) == ERROR)
45 goto Failure;
46
47 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
48 goto Failure;
49
50 if (OffsetRgn(hrgn, 2 * cx, 0) == ERROR)
51 goto Failure;
52
53 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
54 goto Failure;
55
56 if (OffsetRgn(hrgn, -cx, cy) == ERROR)
57 goto Failure;
58
59 if (CombineRgn(hrgnTemp, hrgn, hrgnTemp, RGN_DIFF) == ERROR)
60 goto Failure;
61
62 if (!FillRgn(hdc, hrgnTemp, hbr))
63 goto Failure;
64
65 DeleteObject(hrgnTemp);
66 return TRUE;
67
68Failure:
69 DeleteObject(hrgnTemp);
70 return FALSE;
71}
72#endif // 0
73
74static
75void
77 ULONG Line,
78 HDC hdc,
79 UINT cx,
80 UINT cy,
81 PUCHAR pjBits,
82 COLORREF *pcrColors)
83{
84 UINT x, y, i;
85
86 for (y = 0; y < cy; y++)
87 {
88 for (x = 0; x < cy; x++)
89 {
90 i = y * cx + x;
91 ok(GetPixel(hdc, x, y) == pcrColors[pjBits[i]],
92 "Wrong pixel at (%u,%u): expected 0x%08lx, got 0x%08lx\n",
93 x, y, pcrColors[pjBits[i]], GetPixel(hdc, x, y));
94 }
95 }
96}
97
98#define CheckBitmapBits(hdc,cx,cy,pj,pcr) \
99 CheckBitmapBitsWithLine(__LINE__, hdc,cx,cy,pj,pcr)
100
102{
103 RECT rc = {0, 0, 8, 8 };
104 HRGN hrgn1, hrgn2;
105 BOOL bRet;
106 UCHAR ajBits[64] = {
107 0, 0, 0, 0, 0, 0, 0, 0, // 0000000
108 0, 1, 1, 1, 1, 0, 0, 0, // 0****00
109 0, 1, 2, 2, 1, 0, 0, 0, // 0*xx**0
110 0, 1, 2, 2, 1, 1, 1, 0, // 0*xxx*0
111 0, 1, 1, 1, 2, 2, 1, 0, // 0**xx*0
112 0, 0, 0, 1, 2, 2, 1, 0, // 00****0
113 0, 0, 0, 1, 1, 1, 1, 0, // 0000000
114 0, 0, 0, 0, 0, 0, 0, 0 // 0000000
115 };
116 COLORREF acrColors[16] = {RGB(0,0,0), RGB(255,255,255), RGB(128,128,128), 0};
117
119
120 hrgn1 = CreateRectRgn(1, 1, 5, 5);
121 ok(hrgn1 != NULL, "failed to create region\n");
122
123 hrgn2 = CreateRectRgn(3, 3, 7, 7);
124 ok(hrgn1 != NULL, "failed to create region\n");
125
126 CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR);
127
129 ok(bRet != 0, "FrameRgn failed\n");
130
131 bRet = FrameRgn(ghdcDIB32, hrgn1, GetStockObject(WHITE_BRUSH), 1, 1);
132 ok(bRet != 0, "FrameRgn failed\n");
133
134 CheckBitmapBits(ghdcDIB32, 8, 8, ajBits, acrColors);
135
136}
137
138
139
141{
142 InitStuff();
144}
145
static void CheckBitmapBitsWithLine(ULONG Line, HDC hdc, UINT cx, UINT cy, PUCHAR pjBits, COLORREF *pcrColors)
Definition: FrameRgn.c:76
void Test_FrameRgn()
Definition: FrameRgn.c:101
#define CheckBitmapBits(hdc, cx, cy, pj, pcr)
Definition: FrameRgn.c:98
static HRGN hrgn2
static HRGN hrgn
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71
#define ERROR(name)
Definition: error_private.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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 ghdcDIB32
Definition: init.c:8
BOOL InitStuff(void)
Definition: init.c:95
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
Definition: ncftp.h:79
int32_t INT
Definition: typedefs.h:58
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define RGN_DIFF
Definition: wingdi.h:358
BOOL WINAPI FrameRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH, _In_ int, _In_ int)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_COPY
Definition: wingdi.h:357
#define RGN_AND
Definition: wingdi.h:356
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#define RGN_OR
Definition: wingdi.h:359
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH)
Definition: painting.c:183
int WINAPI OffsetRgn(_In_ HRGN, _In_ int, _In_ int)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
unsigned char UCHAR
Definition: xmlstorage.h:181