ReactOS 0.4.15-dev-5672-gf73ac17
NtGdiGetDIBits.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiGetDIBits.c:

Go to the source code of this file.

Functions

UINT FASTCALL DIB_BitmapMaxBitsSize (PBITMAPINFO Info, UINT ScanLines)
 
 START_TEST (NtGdiGetDIBitsInternal)
 

Function Documentation

◆ DIB_BitmapMaxBitsSize()

UINT FASTCALL DIB_BitmapMaxBitsSize ( PBITMAPINFO  Info,
UINT  ScanLines 
)

Definition at line 13 of file NtGdiGetDIBits.c.

14{
15 UINT MaxBits = 0;
16
17 if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
18 {
20 MaxBits = Core->bcBitCount * Core->bcPlanes * Core->bcWidth;
21 }
22 else /* assume BITMAPINFOHEADER */
23 {
24 if ((Info->bmiHeader.biCompression) && (Info->bmiHeader.biCompression != BI_BITFIELDS))
25 return Info->bmiHeader.biSizeImage;
26 // Planes are over looked by Yuan. I guess assumed always 1.
27 MaxBits = Info->bmiHeader.biBitCount * Info->bmiHeader.biPlanes * Info->bmiHeader.biWidth;
28 }
29 MaxBits = ((MaxBits + 31) & ~31 ) / 8; // From Yuan, ScanLineSize = (Width * bitcount + 31)/32
30 return (MaxBits * ScanLines); // ret the full Size.
31}
#define BI_BITFIELDS
Definition: mmreg.h:507
unsigned int UINT
Definition: ndis.h:50
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
struct tagBITMAPCOREHEADER * PBITMAPCOREHEADER

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( NtGdiGetDIBitsInternal  )

Definition at line 34 of file NtGdiGetDIBits.c.

35{
37 struct
38 {
39 BITMAPINFO bi;
40 RGBQUAD Colors[20];
41 } bmp;
42// BITMAPINFO bi;
43 INT ScreenBpp;
45 DWORD data[20*16];
46
47 HDC hDCScreen = GetDC(NULL);
48 ok(hDCScreen != NULL, "hDCScreen was NULL.\n");
49
50 hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16);
51 ok(hBitmap != NULL, "hBitmap was NULL.\n");
52
54 ok_int(NtGdiGetDIBitsInternal(0, 0, 0, 0, NULL, NULL, 0, 0, 0), 0);
56
58 ok_int(NtGdiGetDIBitsInternal((HDC)2345, 0, 0, 0, NULL, NULL, 0, 0, 0), 0);
60
62 ok_int(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 0, NULL, NULL, 0, 0, 0), 0);
64
66 ok_int(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 0, NULL, NULL, 0, 0, 0), 0);
68
70 ok_int(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, NULL, 0, 0, 0), 0);
72
73 ZeroMemory(&bmp, sizeof(bmp));
74 bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
75 FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44);
76
78 ok(NtGdiGetDIBitsInternal((HDC)0, hBitmap, 0, 15, NULL, &bmp.bi, 0, 0, 0) > 0,
79 "NtGdiGetDIBitsInternal((HDC)0, hBitmap, 0, 15, NULL, &bmp.bi, 0, 0, 0) <= 0.\n");
81 ok_int(bmp.Colors[0].rgbRed, 0x44);
82
83 ZeroMemory(&bmp, sizeof(bmp));
84 bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
85 FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44);
86
88 ok(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 15, NULL, &bmp.bi, 0, 0, 0) > 0,
89 "The return value was <= 0.\n");
91 ok_int(bmp.Colors[0].rgbRed, 0x44);
92
93 ZeroMemory(&bmp, sizeof(bmp));
94 bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
95 FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x44);
96
98 ok(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, &bmp.bi, DIB_RGB_COLORS,
99 DIB_BitmapMaxBitsSize(&bmp.bi, 15), 0) > 0, "The return value was <= 0.\n");
101
102 ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
103
104 ok_long(bmp.bi.bmiHeader.biWidth, 16);
105 ok_long(bmp.bi.bmiHeader.biHeight, 16);
106 ok_long(bmp.bi.bmiHeader.biBitCount, ScreenBpp);
107 ok_long(bmp.bi.bmiHeader.biSizeImage, (16 * 16) * (ScreenBpp / 8));
108
109 ok_int(bmp.Colors[0].rgbRed, 0x44);
110
111 /* Test with pointer */
112// ZeroMemory(&bmp.bi, sizeof(BITMAPINFO));
113 bmp.bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
114// FillMemory(&bmp.Colors, sizeof(bmp.Colors), 0x11223344);
115
117 ok(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, (void*)data, &bmp.bi, DIB_RGB_COLORS,
118 DIB_BitmapMaxBitsSize(&bmp.bi, 15), 0) > 0, "The return value was <= 0.\n");
120
121 ok_long(bmp.bi.bmiHeader.biWidth, 16);
122 ok_long(bmp.bi.bmiHeader.biHeight, 16);
123 ok_long(bmp.bi.bmiHeader.biBitCount, ScreenBpp);
124 ok_long(bmp.bi.bmiHeader.biSizeImage, (16 * 16) * (ScreenBpp / 8));
125
126 ok(bmp.Colors[0].rgbRed != 0x44, "bmp.Colors[0].rgbRed was 0x44.\n");
127
128 /* Test a BITMAPCOREINFO structure */
130 ZeroMemory(&bic, sizeof(BITMAPCOREINFO));
131 bic.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER);
132 ok(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, (PBITMAPINFO)&bic, DIB_RGB_COLORS,
133 DIB_BitmapMaxBitsSize((PBITMAPINFO)&bic, 15), 0) > 0, "The return value was <= 0.\n");
135
136
137 ReleaseDC(NULL, hDCScreen);
139
140}
UINT FASTCALL DIB_BitmapMaxBitsSize(PBITMAPINFO Info, UINT ScanLines)
Colors
Definition: ansiprsr.h:4
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_int(expression, result)
Definition: atltest.h:134
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
static HBITMAP hBitmap
Definition: timezone.c:26
#define SetLastError(x)
Definition: compat.h:752
ULONG RGBQUAD
Definition: precomp.h:50
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BITMAP bmp
Definition: alphablend.c:62
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1453
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1670
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define BITSPIXEL
Definition: wingdi.h:720
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)