ReactOS 0.4.16-dev-319-g6cf4263
SetPixel.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 SetPixel
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
10#include <mmsystem.h>
11
12static struct
13{
17} gpal =
18{
19 0x300, 8,
20 {
21 { 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
22 { 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
23 { 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
24 { 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
25 { 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
26 { 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
27 { 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
28 { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
29 }
30};
31
33{
34 HDC hdc;
35
36 SetLastError(0);
37 ok_long(SetPixel(0, 0, 0, RGB(255,255,255)), -1);
39
40 /* Test an info DC */
41 hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
42 ok(hdc != 0, "\n");
43 SetLastError(0);
44 ok_long(SetPixel(hdc, 0, 0, 0), -1);
45 ok_long(SetPixel(hdc, 0, 0, RGB(255,255,255)), -1);
46 ok_err(0);
48
49 /* Test a mem DC without selecting a bitmap */
51 ok(hdc != 0, "\n");
52 SetLastError(0);
53 ok_long(SetPixel(hdc, 0, 0, 0), -1);
54 ok_err(0);
56
57 /* Test deleted DC */
58 ok_long(SetPixel(hdc, 0, 0, 0), -1);
59
60}
61
63{
64 struct
65 {
66 BITMAPINFOHEADER bmiHeader;
67 WORD bmiColors[8];
68 } bmibuffer;
69 BITMAPINFO *pbmi = (PVOID)&bmibuffer;
71 HDC hdc;
72 HPALETTE hpal, hpalOld;
73 PULONG pulBits;
74 USHORT i;
75
76 /* Initialize the BITMAPINFO */
88 for( i = 0; i < 8; i++ )
89 {
90 bmibuffer.bmiColors[i] = i + 1;
91 }
92
93 /* Create a memory DC */
95 ok(hdc != 0, "failed\n");
96
97 /* Create a DIB section and select it */
98 hbmp = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (PVOID*)&pulBits, 0, 0 );
99 ok(hbmp != NULL, "CreateDIBSection failed with error %ld\n", GetLastError());
100 ok(SelectObject(hdc, hbmp) != 0, "SelectObject failed\n");
101
102 ok_long(SetPixel(hdc, 0, 0, 0), 0);
103 ok_long(pulBits[0], 8);
104 ok_long(SetPixel(hdc, 0, 0, 1), 0);
105 ok_long(pulBits[0], 8);
106 ok_long(SetPixel(hdc, 0, 0, RGB(255,255,255)), 0xc0dcc0);
107 ok_long(pulBits[0], 7);
108
109 ok_long(SetPixel(hdc, 0, 0, RGB(255,0,0)), 0x80);
110 ok_long(pulBits[0], 0);
111
112 /* Test DIBINDEX */
113 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(0)), 0x80);
114 ok_long(pulBits[0], 0);
115 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(1)), 0x8000);
116 ok_long(pulBits[0], 1);
117 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(7)), 0xc0dcc0);
118 ok_long(pulBits[0], 7);
119 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(8)), 0);
120 ok_long(pulBits[0], 8);
121 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(126)), 0);
122 ok_long(pulBits[0], 126);
123 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(0x123456)), 0);
124 ok_long(pulBits[0], 0x56);
125
126 /* Test PALETTEINDEX */
127 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(0)), 0);
128 ok_long(pulBits[0], 8);
129 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(1)), 0x80);
130 ok_long(pulBits[0], 0);
131 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(2)), 0x8000);
132 ok_long(pulBits[0], 1);
133
134 /* Delete the DIB section */
136
137
138 /* Initialize the logical palette and select it */
139 hpal = CreatePalette((LOGPALETTE*)&gpal);
140 hpalOld = SelectPalette(hdc, hpal, FALSE);
141 ok(hpalOld != NULL, "error=%ld\n", GetLastError());
142
143
144 /* Create a DIB section and select it */
145 hbmp = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (PVOID*)&pulBits, 0, 0 );
146 ok(hbmp != NULL, "CreateDIBSection failed with error %ld\n", GetLastError());
147 ok(SelectObject(hdc, hbmp) != 0, "SelectObject failed\n");
148
149 ok_long(SetPixel(hdc, 0, 0, 0), 0);
150 ok_long(pulBits[0], 8);
151
152 ok_long(SetPixel(hdc, 0, 0, RGB(255,0,0)), 0x605040);
153 ok_long(pulBits[0], 2);
154
155 /* Test DIBINDEX */
156 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(0)), 0x403020);
157 ok_long(pulBits[0], 0);
158 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(1)), 0x504030);
159 ok_long(pulBits[0], 1);
160 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(7)), 0x302010);
161 ok_long(pulBits[0], 7);
162 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(8)), 0);
163 ok_long(pulBits[0], 8);
164 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(126)), 0);
165 ok_long(pulBits[0], 126);
166 ok_long(SetPixel(hdc, 0, 0, DIBINDEX(0x123456)), 0);
167 ok_long(pulBits[0], 0x56);
168
169 /* Test PALETTEINDEX */
170 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(0)), 0x302010);
171 ok_long(pulBits[0], 7);
172 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(1)), 0x403020);
173 ok_long(pulBits[0], 0);
174 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(253)), 0x302010);
175 ok_long(pulBits[0], 7);
176 ok_long(SetPixel(hdc, 0, 0, PALETTEINDEX(254)), 0x302010);
177 ok_long(pulBits[0], 7);
178
179
180}
181
183{
186}
187
PALETTEENTRY logpalettedata[8]
Definition: SetPixel.c:16
WORD palVersion
Definition: SetPixel.c:14
WORD palNumEntries
Definition: SetPixel.c:15
void Test_SetPixel_Params()
Definition: SetPixel.c:32
static struct @1601 gpal
void Test_SetPixel_PAL()
Definition: SetPixel.c:62
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define START_TEST(x)
Definition: atltest.h:75
HBITMAP hbmp
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define BI_RGB
Definition: precomp.h:56
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned short WORD
Definition: ntddk_ex.h:93
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
#define DIBINDEX(n)
Definition: mmsystem.h:932
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
unsigned short USHORT
Definition: pedump.c:61
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
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define PALETTEINDEX(i)
Definition: wingdi.h:2943
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DIB_PAL_COLORS
Definition: wingdi.h:366
#define PC_NOCOLLAPSE
Definition: wingdi.h:881
BOOL WINAPI DeleteDC(_In_ HDC)