ReactOS  0.4.9-dev-717-g6d91262
bitmap.c File Reference
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/winternl.h"
#include "wine/ddk/d3dkmthk.h"
#include "wine/test.h"
Include dependency graph for bitmap.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define test_color(hdc, color, exp)   _test_color( __LINE__, hdc, color, exp )
 
#define test_mono_1x1_bmp(a)   test_mono_1x1_bmp_dbg((a), __LINE__)
 

Functions

static NTSTATUS (WINAPI *pD3DKMTCreateDCFromMemory)(D3DKMT_CREATEDCFROMMEMORY *desc)
 
static BOOL (WINAPI *pGdiAlphaBlend)(HDC
 
static DWORD (WINAPI *pSetLayout)(HDC hdc
 
static int get_bitmap_stride (int width, int bpp)
 
static int get_dib_stride (int width, int bpp)
 
static int get_dib_image_size (const BITMAPINFO *info)
 
static void test_bitmap_info (HBITMAP hbm, INT expected_depth, const BITMAPINFOHEADER *bmih)
 
static void test_createdibitmap (void)
 
static void test_dib_info (HBITMAP hbm, const void *bits, const BITMAPINFOHEADER *bmih)
 
static void _test_color (int line, HDC hdc, COLORREF color, COLORREF exp)
 
static void test_dib_bits_access (HBITMAP hdib, void *bits)
 
static void test_dibsections (void)
 
static void test_dib_formats (void)
 
static void test_mono_dibsection (void)
 
static void test_bitmap (void)
 
static COLORREF get_nearest (int r, int g, int b)
 
static BOOL is_black_pen (COLORREF fg, COLORREF bg, int r, int g, int b)
 
static void test_bitmap_colors (HDC hdc, COLORREF fg, COLORREF bg, int r, int g, int b)
 
static void test_mono_bitmap (void)
 
static void test_bmBits (void)
 
static void test_GetDIBits_selected_DIB (UINT bpp)
 
static void test_GetDIBits_selected_DDB (BOOL monochrome)
 
static void test_GetDIBits (void)
 
static void test_GetDIBits_BI_BITFIELDS (void)
 
static void test_select_object (void)
 
static void test_mono_1x1_bmp_dbg (HBITMAP hbmp, int line)
 
static void test_CreateBitmap (void)
 
static void test_bitmapinfoheadersize (void)
 
static void test_get16dibits (void)
 
static void check_BitBlt_pixel (HDC hdcDst, HDC hdcSrc, UINT32 *dstBuffer, UINT32 *srcBuffer, DWORD dwRop, UINT32 expected, int line)
 
static void test_BitBlt (void)
 
static void check_StretchBlt_pixel (HDC hdcDst, HDC hdcSrc, UINT32 *dstBuffer, UINT32 *srcBuffer, DWORD dwRop, UINT32 expected, int line)
 
static void check_StretchBlt_stretch (HDC hdcDst, HDC hdcSrc, BITMAPINFO *dst_info, UINT32 *dstBuffer, UINT32 *srcBuffer, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, UINT32 *expected, int line)
 
static void test_StretchBlt (void)
 
static void check_StretchDIBits_pixel (HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer, DWORD dwRop, UINT32 expected, int line)
 
static INT check_StretchDIBits_stretch (HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, UINT32 expected[4], int line)
 
static void test_StretchDIBits (void)
 
static void test_GdiAlphaBlend (void)
 
static void test_GdiGradientFill (void)
 
static void test_clipping (void)
 
static void test_32bit_ddb (void)
 
static void setup_picture (char *picture, int bpp)
 
static void test_GetDIBits_top_down (int bpp)
 
static void test_GetSetDIBits_rtl (void)
 
static void test_GetDIBits_scanlines (void)
 
static void test_SetDIBits (void)
 
static void test_SetDIBits_RLE4 (void)
 
static void test_SetDIBits_RLE8 (void)
 
static void test_SetDIBitsToDevice (void)
 
static void test_SetDIBitsToDevice_RLE8 (void)
 
static void test_D3DKMTCreateDCFromMemory (void)
 
 START_TEST (bitmap)
 

Variables

static int
 
static HDC
 
static BLENDFUNCTION
 
static TRIVERTEX ULONG
 
static DWORD layout
 

Macro Definition Documentation

#define test_color (   hdc,
  color,
  exp 
)    _test_color( __LINE__, hdc, color, exp )

Definition at line 373 of file bitmap.c.

Referenced by test_dibsections(), and test_mono_bitmap().

#define test_mono_1x1_bmp (   a)    test_mono_1x1_bmp_dbg((a), __LINE__)

Definition at line 2769 of file bitmap.c.

Referenced by test_CreateBitmap().

#define WIN32_NO_STATUS

Definition at line 27 of file bitmap.c.

Function Documentation

static void _test_color ( int  line,
HDC  hdc,
COLORREF  color,
COLORREF  exp 
)
static

Definition at line 363 of file bitmap.c.

364 {
365  COLORREF c;
366  c = SetPixel(hdc, 0, 0, color);
367  ok_(__FILE__, line)(c == exp, "SetPixel failed: got 0x%06x expected 0x%06x\n", c, exp);
368  c = GetPixel(hdc, 0, 0);
369  ok_(__FILE__, line)(c == exp, "GetPixel failed: got 0x%06x expected 0x%06x\n", c, exp);
370  c = GetNearestColor(hdc, color);
371  ok_(__FILE__, line)(c == exp, "GetNearestColor failed: got 0x%06x expected 0x%06x\n", c, exp);
372 }
COLORREF WINAPI GetNearestColor(_In_ HDC, _In_ COLORREF)
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
GLuint color
Definition: glext.h:6243
HDC hdc
Definition: msvc.h:53
Definition: parser.c:48
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
#define c
Definition: ke_i.h:80
DWORD exp
Definition: msg.c:15681
DWORD COLORREF
Definition: windef.h:290
#define ok_(x1, x2)
Definition: CString.cpp:56
static BOOL ( WINAPI pGdiAlphaBlend)
static
static void check_BitBlt_pixel ( HDC  hdcDst,
HDC  hdcSrc,
UINT32 dstBuffer,
UINT32 srcBuffer,
DWORD  dwRop,
UINT32  expected,
int  line 
)
static

Definition at line 3013 of file bitmap.c.

Referenced by test_BitBlt().

3015 {
3016  *srcBuffer = 0xFEDCBA98;
3017  *dstBuffer = 0x89ABCDEF;
3018  BitBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, dwRop);
3019  ok(expected == *dstBuffer,
3020  "BitBlt with dwRop %06X. Expected 0x%08X, got 0x%08X from line %d\n",
3021  dwRop, expected, *dstBuffer, line);
3022 }
static HDC hdcSrc
Definition: xlate.c:32
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
Definition: parser.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
static HDC hdcDst
Definition: xlate.c:32
BOOL expected
Definition: store.c:2063
static void check_StretchBlt_pixel ( HDC  hdcDst,
HDC  hdcSrc,
UINT32 dstBuffer,
UINT32 srcBuffer,
DWORD  dwRop,
UINT32  expected,
int  line 
)
static

Definition at line 3090 of file bitmap.c.

Referenced by test_StretchBlt().

3092 {
3093  *srcBuffer = 0xFEDCBA98;
3094  *dstBuffer = 0x89ABCDEF;
3095  StretchBlt(hdcDst, 0, 0, 2, 1, hdcSrc, 0, 0, 1, 1, dwRop);
3096  ok(expected == *dstBuffer,
3097  "StretchBlt with dwRop %06X. Expected 0x%08X, got 0x%08X from line %d\n",
3098  dwRop, expected, *dstBuffer, line);
3099 }
static HDC hdcSrc
Definition: xlate.c:32
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
Definition: parser.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
static HDC hdcDst
Definition: xlate.c:32
BOOL expected
Definition: store.c:2063
static void check_StretchBlt_stretch ( HDC  hdcDst,
HDC  hdcSrc,
BITMAPINFO dst_info,
UINT32 dstBuffer,
UINT32 srcBuffer,
int  nXOriginDest,
int  nYOriginDest,
int  nWidthDest,
int  nHeightDest,
int  nXOriginSrc,
int  nYOriginSrc,
int  nWidthSrc,
int  nHeightSrc,
UINT32 expected,
int  line 
)
static

Definition at line 3101 of file bitmap.c.

Referenced by test_StretchBlt().

3105 {
3106  int dst_size = get_dib_image_size( dst_info );
3107 
3108  memset(dstBuffer, 0, dst_size);
3109  StretchBlt(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
3110  hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, SRCCOPY);
3111  ok(memcmp(dstBuffer, expected, dst_size) == 0,
3112  "StretchBlt expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X } "
3113  "stretching { %d, %d, %d, %d } to { %d, %d, %d, %d } from line %d\n",
3114  expected[0], expected[1], expected[2], expected[3],
3115  dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3],
3116  nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
3117  nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, line);
3118 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static HDC hdcSrc
Definition: xlate.c:32
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
Definition: parser.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
static HDC hdcDst
Definition: xlate.c:32
static int get_dib_image_size(const BITMAPINFO *info)
Definition: bitmap.c:58
#define memset(x, y, z)
Definition: compat.h:39
#define SRCCOPY
Definition: wingdi.h:331
BOOL expected
Definition: store.c:2063
static void check_StretchDIBits_pixel ( HDC  hdcDst,
UINT32 dstBuffer,
UINT32 srcBuffer,
DWORD  dwRop,
UINT32  expected,
int  line 
)
static

Definition at line 3422 of file bitmap.c.

Referenced by test_StretchDIBits().

3424 {
3425  const UINT32 buffer[2] = { 0xFEDCBA98, 0 };
3426  BITMAPINFO bitmapInfo;
3427 
3428  memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
3429  bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3430  bitmapInfo.bmiHeader.biWidth = 2;
3431  bitmapInfo.bmiHeader.biHeight = 1;
3432  bitmapInfo.bmiHeader.biPlanes = 1;
3433  bitmapInfo.bmiHeader.biBitCount = 32;
3434  bitmapInfo.bmiHeader.biCompression = BI_RGB;
3435  bitmapInfo.bmiHeader.biSizeImage = sizeof(buffer);
3436 
3437  *dstBuffer = 0x89ABCDEF;
3438 
3439  StretchDIBits(hdcDst, 0, 0, 2, 1, 0, 0, 1, 1, &buffer, &bitmapInfo, DIB_RGB_COLORS, dwRop);
3440  ok(expected == *dstBuffer,
3441  "StretchDIBits with dwRop %06X. Expected 0x%08X, got 0x%08X from line %d\n",
3442  dwRop, expected, *dstBuffer, line);
3443 }
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
GLuint buffer
Definition: glext.h:5915
int WINAPI StretchDIBits(HDC hdc, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo, UINT iUsage, DWORD dwRop)
Definition: bitmap.c:758
unsigned int UINT32
DWORD biCompression
Definition: amvideo.idl:35
Definition: parser.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
DWORD biSizeImage
Definition: amvideo.idl:36
static HDC hdcDst
Definition: xlate.c:32
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
BOOL expected
Definition: store.c:2063
static INT check_StretchDIBits_stretch ( HDC  hdcDst,
UINT32 dstBuffer,
UINT32 srcBuffer,
int  nXOriginDest,
int  nYOriginDest,
int  nWidthDest,
int  nHeightDest,
int  nXOriginSrc,
int  nYOriginSrc,
int  nWidthSrc,
int  nHeightSrc,
UINT32  expected[4],
int  line 
)
static

Definition at line 3445 of file bitmap.c.

Referenced by test_StretchDIBits().

3449 {
3450  BITMAPINFO bitmapInfo;
3451  INT ret;
3452 
3453  memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
3454  bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3455  bitmapInfo.bmiHeader.biWidth = 2;
3456  bitmapInfo.bmiHeader.biHeight = -2;
3457  bitmapInfo.bmiHeader.biPlanes = 1;
3458  bitmapInfo.bmiHeader.biBitCount = 32;
3459  bitmapInfo.bmiHeader.biCompression = BI_RGB;
3460 
3461  memset(dstBuffer, 0, 16);
3462  ret = StretchDIBits(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
3463  nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
3464  srcBuffer, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY);
3465  ok(memcmp(dstBuffer, expected, 16) == 0,
3466  "StretchDIBits expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X } "
3467  "stretching { %d, %d, %d, %d } to { %d, %d, %d, %d } from line %d\n",
3468  expected[0], expected[1], expected[2], expected[3],
3469  dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3],
3470  nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
3471  nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, line);
3472  return ret;
3473 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
int WINAPI StretchDIBits(HDC hdc, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo, UINT iUsage, DWORD dwRop)
Definition: bitmap.c:758
int32_t INT
Definition: typedefs.h:56
DWORD biCompression
Definition: amvideo.idl:35
Definition: parser.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
int ret
static HDC hdcDst
Definition: xlate.c:32
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:331
BOOL expected
Definition: store.c:2063
static DWORD ( WINAPI pSetLayout)
static
static int get_bitmap_stride ( int  width,
int  bpp 
)
inlinestatic

Definition at line 48 of file bitmap.c.

Referenced by test_bitmap_info(), test_dib_info(), test_GetDIBits(), and test_select_object().

49 {
50  return ((width * bpp + 15) >> 3) & ~1;
51 }
GLint GLint GLsizei width
Definition: gl.h:1546
DWORD bpp
Definition: surface.c:181
static int get_dib_image_size ( const BITMAPINFO info)
inlinestatic

Definition at line 58 of file bitmap.c.

Referenced by check_StretchBlt_stretch(), and test_StretchBlt().

59 {
60  return get_dib_stride( info->bmiHeader.biWidth, info->bmiHeader.biBitCount )
61  * abs( info->bmiHeader.biHeight );
62 }
#define abs(i)
Definition: fconv.c:206
static int get_dib_stride(int width, int bpp)
Definition: bitmap.c:53
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
static int get_dib_stride ( int  width,
int  bpp 
)
inlinestatic

Definition at line 53 of file bitmap.c.

Referenced by get_dib_image_size(), test_D3DKMTCreateDCFromMemory(), and test_dib_info().

54 {
55  return ((width * bpp + 31) >> 3) & ~3;
56 }
GLint GLint GLsizei width
Definition: gl.h:1546
DWORD bpp
Definition: surface.c:181
static COLORREF get_nearest ( int  r,
int  g,
int  b 
)
static

Definition at line 1602 of file bitmap.c.

Referenced by test_bitmap_colors(), and test_mono_bitmap().

1603 {
1604  return (r*r + g*g + b*b < (255-r)*(255-r) + (255-g)*(255-g) + (255-b)*(255-b)) ? 0x000000 : 0xffffff;
1605 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static BOOL is_black_pen ( COLORREF  fg,
COLORREF  bg,
int  r,
int  g,
int  b 
)
static

Definition at line 1607 of file bitmap.c.

Referenced by test_bitmap_colors().

1608 {
1609  if (fg == 0 || bg == 0xffffff) return RGB(r,g,b) != 0xffffff && RGB(r,g,b) != bg;
1610  return RGB(r,g,b) == 0x000000 || RGB(r,g,b) == bg;
1611 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2917
static NTSTATUS ( WINAPI pD3DKMTCreateDCFromMemory)
static
static void setup_picture ( char picture,
int  bpp 
)
static

Definition at line 4087 of file bitmap.c.

Referenced by test_GetDIBits_top_down().

4088 {
4089  int i;
4090 
4091  switch(bpp)
4092  {
4093  case 16:
4094  case 32:
4095  /*Set the first byte in each pixel to the index of that pixel.*/
4096  for (i = 0; i < 4; i++)
4097  picture[i * (bpp / 8)] = i;
4098  break;
4099  case 24:
4100  picture[0] = 0;
4101  picture[3] = 1;
4102  /*Each scanline in a bitmap must be a multiple of 4 bytes long.*/
4103  picture[8] = 2;
4104  picture[11] = 3;
4105  break;
4106  }
4107 }
Definition: id3.c:18
GLenum GLclampf GLint i
Definition: glfuncs.h:14
DWORD bpp
Definition: surface.c:181
START_TEST ( bitmap  )

Definition at line 5941 of file bitmap.c.

5942 {
5943  HMODULE hdll;
5944 
5945  hdll = GetModuleHandleA("gdi32.dll");
5946 #ifndef __REACTOS__ /* CORE-11331 */
5947  pD3DKMTCreateDCFromMemory = (void *)GetProcAddress( hdll, "D3DKMTCreateDCFromMemory" );
5948  pD3DKMTDestroyDCFromMemory = (void *)GetProcAddress( hdll, "D3DKMTDestroyDCFromMemory" );
5949 #endif
5950  pGdiAlphaBlend = (void *)GetProcAddress( hdll, "GdiAlphaBlend" );
5951  pGdiGradientFill = (void *)GetProcAddress( hdll, "GdiGradientFill" );
5952  pSetLayout = (void *)GetProcAddress( hdll, "SetLayout" );
5953 
5955  test_dibsections();
5956  test_dib_formats();
5958  test_bitmap();
5959  test_mono_bitmap();
5960  test_bmBits();
5966  test_GetDIBits();
5970  test_BitBlt();
5971  test_StretchBlt();
5975  test_32bit_ddb();
5977  test_get16dibits();
5978  test_clipping();
5984  test_SetDIBits();
5989 #ifndef __REACTOS__ /* CORE-11331 */
5991 #endif
5992 }
#define TRUE
Definition: types.h:120
static void test_CreateBitmap(void)
Definition: bitmap.c:2771
static void test_BitBlt(void)
Definition: bitmap.c:3024
static void test_StretchDIBits(void)
Definition: bitmap.c:3475
static void test_GdiGradientFill(void)
Definition: bitmap.c:3836
static void test_SetDIBits(void)
Definition: bitmap.c:4584
static void test_GetSetDIBits_rtl(void)
Definition: bitmap.c:4198
#define FALSE
Definition: types.h:117
static void test_get16dibits(void)
Definition: bitmap.c:2973
static void test_GetDIBits_scanlines(void)
Definition: bitmap.c:4265
static void test_bmBits(void)
Definition: bitmap.c:1785
static void test_32bit_ddb(void)
Definition: bitmap.c:3992
static void test_dib_formats(void)
Definition: bitmap.c:916
static void test_SetDIBitsToDevice_RLE8(void)
Definition: bitmap.c:5445
static void test_StretchBlt(void)
Definition: bitmap.c:3120
static void test_GetDIBits_selected_DIB(UINT bpp)
Definition: bitmap.c:1803
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:818
static void test_GetDIBits(void)
Definition: bitmap.c:2025
static void test_bitmapinfoheadersize(void)
Definition: bitmap.c:2874
static void test_GetDIBits_selected_DDB(BOOL monochrome)
Definition: bitmap.c:1912
static void test_GetDIBits_BI_BITFIELDS(void)
Definition: bitmap.c:2431
static void test_dibsections(void)
Definition: bitmap.c:435
static PVOID hdll
Definition: shimdbg.c:126
static void test_GetDIBits_top_down(int bpp)
Definition: bitmap.c:4109
HANDLE HMODULE
Definition: typedefs.h:75
static void test_SetDIBits_RLE8(void)
Definition: bitmap.c:4872
static void test_mono_dibsection(void)
Definition: bitmap.c:1299
static void test_clipping(void)
Definition: bitmap.c:3949
#define GetProcAddress(x, y)
Definition: compat.h:410
static void test_SetDIBits_RLE4(void)
Definition: bitmap.c:4817
static void test_D3DKMTCreateDCFromMemory(void)
Definition: bitmap.c:5667
static void test_createdibitmap(void)
Definition: bitmap.c:128
static void test_select_object(void)
Definition: bitmap.c:2659
static void test_SetDIBitsToDevice(void)
Definition: bitmap.c:5022
static void test_mono_bitmap(void)
Definition: bitmap.c:1725
static void test_bitmap(void)
Definition: bitmap.c:1493
static void test_GdiAlphaBlend(void)
Definition: bitmap.c:3610
static void test_32bit_ddb ( void  )
static

Definition at line 3992 of file bitmap.c.

Referenced by START_TEST().

3993 {
3994  char buffer[sizeof(BITMAPINFOHEADER) + sizeof(DWORD)];
3995  BITMAPINFO *biDst = (BITMAPINFO *)buffer;
3996  HBITMAP bmpSrc, bmpDst;
3997  HBITMAP oldSrc, oldDst;
3998  HDC hdcSrc, hdcDst, hdcScreen;
3999  HBRUSH brush;
4000  DWORD *dstBuffer, *data;
4001  DWORD colorSrc = 0x40201008;
4002 
4003  memset(biDst, 0, sizeof(BITMAPINFOHEADER));
4004  biDst->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
4005  biDst->bmiHeader.biWidth = 1;
4006  biDst->bmiHeader.biHeight = -1;
4007  biDst->bmiHeader.biPlanes = 1;
4008  biDst->bmiHeader.biBitCount = 32;
4009  biDst->bmiHeader.biCompression = BI_RGB;
4010 
4011  hdcScreen = CreateCompatibleDC(0);
4012  if(GetDeviceCaps(hdcScreen, BITSPIXEL) != 32)
4013  {
4014  DeleteDC(hdcScreen);
4015  trace("Skipping 32-bit DDB test\n");
4016  return;
4017  }
4018 
4019  hdcSrc = CreateCompatibleDC(hdcScreen);
4020  bmpSrc = CreateBitmap(1, 1, 1, 32, &colorSrc);
4021  oldSrc = SelectObject(hdcSrc, bmpSrc);
4022 
4023  hdcDst = CreateCompatibleDC(hdcScreen);
4024  bmpDst = CreateDIBSection(hdcDst, biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
4025  oldDst = SelectObject(hdcDst, bmpDst);
4026 
4027  StretchBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, SRCCOPY);
4028  ok(dstBuffer[0] == colorSrc, "Expected color=%x, received color=%x\n", colorSrc, dstBuffer[0]);
4029 
4030  if (pGdiAlphaBlend)
4031  {
4032  BLENDFUNCTION blend;
4033  BOOL ret;
4034 
4035  blend.BlendOp = AC_SRC_OVER;
4036  blend.BlendFlags = 0;
4037  blend.SourceConstantAlpha = 128;
4038  blend.AlphaFormat = 0;
4039  dstBuffer[0] = 0x80808080;
4040  ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend );
4041  ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
4042  ok(dstBuffer[0] == 0x60504844, "wrong color %x\n", dstBuffer[0]);
4043  blend.AlphaFormat = AC_SRC_ALPHA;
4044  dstBuffer[0] = 0x80808080;
4045  ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend );
4046  ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
4047  ok(dstBuffer[0] == 0x90807874, "wrong color %x\n", dstBuffer[0]);
4048  }
4049 
4050  data = (DWORD *)biDst->bmiColors;
4051  data[0] = 0x20304050;
4052  brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS );
4053  ok( brush != 0, "brush creation failed\n" );
4054  SelectObject( hdcSrc, brush );
4055  PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY );
4056  BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY );
4057  ok(dstBuffer[0] == data[0], "Expected color=%x, received color=%x\n", data[0], dstBuffer[0]);
4059  DeleteObject( brush );
4060 
4061  biDst->bmiHeader.biBitCount = 24;
4062  brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS );
4063  ok( brush != 0, "brush creation failed\n" );
4064  SelectObject( hdcSrc, brush );
4065  PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY );
4066  BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY );
4067  ok(dstBuffer[0] == (data[0] & ~0xff000000),
4068  "Expected color=%x, received color=%x\n", data[0] & 0xff000000, dstBuffer[0]);
4070  DeleteObject( brush );
4071 
4072  /* Tidy up */
4073  SelectObject(hdcDst, oldDst);
4074  DeleteObject(bmpDst);
4075  DeleteDC(hdcDst);
4076 
4077  SelectObject(hdcSrc, oldSrc);
4078  DeleteObject(bmpSrc);
4079  DeleteDC(hdcSrc);
4080 
4081  DeleteDC(hdcScreen);
4082 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define BITSPIXEL
Definition: wingdi.h:718
#define trace(...)
Definition: kmt_test.h:217
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint buffer
Definition: glext.h:5915
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HDC hdcSrc
Definition: xlate.c:32
#define AC_SRC_ALPHA
Definition: alphablend.c:9
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
DWORD DWORD
Definition: winlogon.h:75
BYTE BlendOp
Definition: wingdi.h:2736
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
#define BLACK_BRUSH
Definition: wingdi.h:894
unsigned int BOOL
Definition: ntddk_ex.h:94
RGBQUAD bmiColors[1]
Definition: wingdi.h:1454
BYTE SourceConstantAlpha
Definition: wingdi.h:2738
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
BYTE BlendFlags
Definition: wingdi.h:2737
#define AC_SRC_OVER
Definition: wingdi.h:1350
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define PATCOPY
Definition: wingdi.h:333
static HDC hdcDst
Definition: xlate.c:32
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static HDC
Definition: bitmap.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:365
BYTE AlphaFormat
Definition: wingdi.h:2739
#define memset(x, y, z)
Definition: compat.h:39
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:331
static void test_BitBlt ( void  )
static

Definition at line 3024 of file bitmap.c.

Referenced by START_TEST().

3025 {
3026  HBITMAP bmpDst, bmpSrc;
3027  HBITMAP oldDst, oldSrc;
3028  HDC hdcScreen, hdcDst, hdcSrc;
3029  UINT32 *dstBuffer, *srcBuffer;
3030  HBRUSH hBrush, hOldBrush;
3031  BITMAPINFO bitmapInfo;
3032 
3033  memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
3034  bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3035  bitmapInfo.bmiHeader.biWidth = 1;
3036  bitmapInfo.bmiHeader.biHeight = 1;
3037  bitmapInfo.bmiHeader.biPlanes = 1;
3038  bitmapInfo.bmiHeader.biBitCount = 32;
3039  bitmapInfo.bmiHeader.biCompression = BI_RGB;
3040  bitmapInfo.bmiHeader.biSizeImage = sizeof(UINT32);
3041 
3042  hdcScreen = CreateCompatibleDC(0);
3043  hdcDst = CreateCompatibleDC(hdcScreen);
3044  hdcSrc = CreateCompatibleDC(hdcDst);
3045 
3046  /* Setup the destination dib section */
3047  bmpDst = CreateDIBSection(hdcScreen, &bitmapInfo, DIB_RGB_COLORS, (void**)&dstBuffer,
3048  NULL, 0);
3049  oldDst = SelectObject(hdcDst, bmpDst);
3050 
3051  hBrush = CreateSolidBrush(0x12345678);
3052  hOldBrush = SelectObject(hdcDst, hBrush);
3053 
3054  /* Setup the source dib section */
3055  bmpSrc = CreateDIBSection(hdcScreen, &bitmapInfo, DIB_RGB_COLORS, (void**)&srcBuffer,
3056  NULL, 0);
3057  oldSrc = SelectObject(hdcSrc, bmpSrc);
3058 
3059  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, SRCCOPY, 0xFEDCBA98, __LINE__);
3060  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, SRCPAINT, 0xFFFFFFFF, __LINE__);
3061  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, SRCAND, 0x88888888, __LINE__);
3062  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, SRCINVERT, 0x77777777, __LINE__);
3063  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, SRCERASE, 0x76543210, __LINE__);
3064  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, NOTSRCCOPY, 0x01234567, __LINE__);
3065  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, NOTSRCERASE, 0x00000000, __LINE__);
3066  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, MERGECOPY, 0x00581210, __LINE__);
3067  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, MERGEPAINT, 0x89ABCDEF, __LINE__);
3068  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, PATCOPY, 0x00785634, __LINE__);
3069  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, PATPAINT, 0x89FBDFFF, __LINE__);
3070  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, PATINVERT, 0x89D39BDB, __LINE__);
3071  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, DSTINVERT, 0x76543210, __LINE__);
3072  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, BLACKNESS, 0x00000000, __LINE__);
3073  check_BitBlt_pixel(hdcDst, hdcSrc, dstBuffer, srcBuffer, WHITENESS, 0xFFFFFFFF, __LINE__);
3074 
3075  /* Tidy up */
3076  SelectObject(hdcSrc, oldSrc);
3077  DeleteObject(bmpSrc);
3078  DeleteDC(hdcSrc);
3079 
3080  SelectObject(hdcDst, hOldBrush);
3081  DeleteObject(hBrush);
3082  SelectObject(hdcDst, oldDst);
3083  DeleteObject(bmpDst);
3084  DeleteDC(hdcDst);
3085 
3086 
3087  DeleteDC(hdcScreen);
3088 }
#define SRCPAINT
Definition: wingdi.h:332
#define PATINVERT
Definition: wingdi.h:326
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define NOTSRCERASE
Definition: wingdi.h:322
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HDC hdcSrc
Definition: xlate.c:32
#define MERGECOPY
Definition: wingdi.h:330
unsigned int UINT32
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
#define NOTSRCCOPY
Definition: wingdi.h:323
#define DSTINVERT
Definition: wingdi.h:325
DWORD biSizeImage
Definition: amvideo.idl:36
#define WHITENESS
Definition: wingdi.h:335
#define PATCOPY
Definition: wingdi.h:333
static HDC hdcDst
Definition: xlate.c:32
#define SRCERASE
Definition: wingdi.h:324
#define BLACKNESS
Definition: wingdi.h:321
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static HDC
Definition: bitmap.c:44
#define SRCAND
Definition: wingdi.h:328
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define MERGEPAINT
Definition: wingdi.h:329
static void check_BitBlt_pixel(HDC hdcDst, HDC hdcSrc, UINT32 *dstBuffer, UINT32 *srcBuffer, DWORD dwRop, UINT32 expected, int line)
Definition: bitmap.c:3013
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:331
#define SRCINVERT
Definition: wingdi.h:327
#define PATPAINT
Definition: wingdi.h:334
static void test_bitmap ( void  )
static

Definition at line 1493 of file bitmap.c.

Referenced by START_TEST().

1494 {
1495  char buf[256], buf_cmp[256];
1496  HBITMAP hbmp, hbmp_old;
1497  HDC hdc;
1498  BITMAP bm;
1499  BITMAP bma[2];
1500  INT ret;
1501 
1502  hdc = CreateCompatibleDC(0);
1503  assert(hdc != 0);
1504 
1505  SetLastError(0xdeadbeef);
1506  hbmp = CreateBitmap(0x7ffffff, 1, 1, 1, NULL);
1507  if (!hbmp)
1508  {
1509  ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY /* XP */ ||
1510  GetLastError() == ERROR_INVALID_PARAMETER /* Win2k */,
1511  "expected ERROR_NOT_ENOUGH_MEMORY, got %u\n", GetLastError());
1512  }
1513  else
1514  DeleteObject(hbmp);
1515 
1516  SetLastError(0xdeadbeef);
1517  hbmp = CreateBitmap(0x7ffffff, 9, 1, 1, NULL);
1518  if (!hbmp)
1519  {
1520  ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY /* XP */ ||
1521  GetLastError() == ERROR_INVALID_PARAMETER /* Win2k */,
1522  "expected ERROR_NOT_ENOUGH_MEMORY, got %u\n", GetLastError());
1523  }
1524  else
1525  DeleteObject(hbmp);
1526 
1527  SetLastError(0xdeadbeef);
1528  hbmp = CreateBitmap(0x7ffffff + 1, 1, 1, 1, NULL);
1529  ok(!hbmp, "CreateBitmap should fail\n");
1530  if (!hbmp)
1532  "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1533  else
1534  DeleteObject(hbmp);
1535 
1536  hbmp = CreateBitmap(15, 15, 1, 1, NULL);
1537  assert(hbmp != NULL);
1538 
1539  ret = GetObjectW(hbmp, sizeof(bm), &bm);
1540  ok(ret == sizeof(bm), "wrong size %d\n", ret);
1541 
1542  ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
1543  ok(bm.bmWidth == 15, "wrong bm.bmWidth %d\n", bm.bmWidth);
1544  ok(bm.bmHeight == 15, "wrong bm.bmHeight %d\n", bm.bmHeight);
1545  ok(bm.bmWidthBytes == 2, "wrong bm.bmWidthBytes %d\n", bm.bmWidthBytes);
1546  ok(bm.bmPlanes == 1, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
1547  ok(bm.bmBitsPixel == 1, "wrong bm.bmBitsPixel %d\n", bm.bmBitsPixel);
1548  ok(bm.bmBits == NULL, "wrong bm.bmBits %p\n", bm.bmBits);
1549 
1550  assert(sizeof(buf) >= bm.bmWidthBytes * bm.bmHeight);
1551  assert(sizeof(buf) == sizeof(buf_cmp));
1552 
1553  ret = GetBitmapBits(hbmp, 0, NULL);
1554  ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
1555 
1556  memset(buf_cmp, 0xAA, sizeof(buf_cmp));
1557  memset(buf_cmp, 0, bm.bmWidthBytes * bm.bmHeight);
1558 
1559  memset(buf, 0xAA, sizeof(buf));
1560  ret = GetBitmapBits(hbmp, sizeof(buf), buf);
1561  ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
1562  ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
1563 
1564  hbmp_old = SelectObject(hdc, hbmp);
1565 
1566  ret = GetObjectW(hbmp, sizeof(bm), &bm);
1567  ok(ret == sizeof(bm), "wrong size %d\n", ret);
1568 
1569  ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
1570  ok(bm.bmWidth == 15, "wrong bm.bmWidth %d\n", bm.bmWidth);
1571  ok(bm.bmHeight == 15, "wrong bm.bmHeight %d\n", bm.bmHeight);
1572  ok(bm.bmWidthBytes == 2, "wrong bm.bmWidthBytes %d\n", bm.bmWidthBytes);
1573  ok(bm.bmPlanes == 1, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
1574  ok(bm.bmBitsPixel == 1, "wrong bm.bmBitsPixel %d\n", bm.bmBitsPixel);
1575  ok(bm.bmBits == NULL, "wrong bm.bmBits %p\n", bm.bmBits);
1576 
1577  memset(buf, 0xAA, sizeof(buf));
1578  ret = GetBitmapBits(hbmp, sizeof(buf), buf);
1579  ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
1580  ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
1581 
1582  hbmp_old = SelectObject(hdc, hbmp_old);
1583  ok(hbmp_old == hbmp, "wrong old bitmap %p\n", hbmp_old);
1584 
1585  /* test various buffer sizes for GetObject */
1586  ret = GetObjectW(hbmp, sizeof(*bma) * 2, bma);
1587  ok(ret == sizeof(*bma), "wrong size %d\n", ret);
1588 
1589  ret = GetObjectW(hbmp, sizeof(bm) / 2, &bm);
1590  ok(ret == 0, "%d != 0\n", ret);
1591 
1592  ret = GetObjectW(hbmp, 0, &bm);
1593  ok(ret == 0, "%d != 0\n", ret);
1594 
1595  ret = GetObjectW(hbmp, 1, &bm);
1596  ok(ret == 0, "%d != 0\n", ret);
1597 
1598  DeleteObject(hbmp);
1599  DeleteDC(hdc);
1600 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define HBITMAP
Definition: msvc.h:28
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int32_t INT
Definition: typedefs.h:56
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
#define SetLastError(x)
Definition: compat.h:409
int ret
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
static HDC
Definition: bitmap.c:44
HBITMAP hbmp
Definition: msvc.h:60
#define memset(x, y, z)
Definition: compat.h:39
static void test_bitmap_colors ( HDC  hdc,
COLORREF  fg,
COLORREF  bg,
int  r,
int  g,
int  b 
)
static

Definition at line 1613 of file bitmap.c.

Referenced by test_mono_bitmap().

1614 {
1615  static const WORD pattern_bits[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
1616  char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors ) + 256 * sizeof(RGBQUAD)];
1618  RGBQUAD *colors = info->bmiColors;
1619  WORD bits[16];
1620  void *bits_ptr;
1621  COLORREF res;
1622  HBRUSH old_brush;
1623  HPEN old_pen;
1624  HBITMAP bitmap;
1625  HDC memdc;
1626 
1627  res = SetPixel( hdc, 0, 0, RGB(r,g,b) );
1628  ok( res == get_nearest( r, g, b ),
1629  "wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
1630  res = GetPixel( hdc, 0, 0 );
1631  ok( res == get_nearest( r, g, b ),
1632  "wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
1633  res = GetNearestColor( hdc, RGB(r,g,b) );
1634  ok( res == get_nearest( r, g, b ),
1635  "wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
1636 
1637  /* solid pen */
1638  old_pen = SelectObject( hdc, CreatePen( PS_SOLID, 1, RGB(r,g,b) ));
1639  MoveToEx( hdc, 0, 0, NULL );
1640  LineTo( hdc, 16, 0 );
1641  res = GetPixel( hdc, 0, 0 );
1642  ok( res == (is_black_pen( fg, bg, r, g, b ) ? 0 : 0xffffff),
1643  "wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
1644  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1645  ok( bits[0] == (is_black_pen( fg, bg, r, g, b ) ? 0x00 : 0xffff),
1646  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1647  DeleteObject( SelectObject( hdc, old_pen ));
1648 
1649  /* mono DDB pattern brush */
1650  bitmap = CreateBitmap( 16, 8, 1, 1, pattern_bits );
1651  old_brush = SelectObject( hdc, CreatePatternBrush( bitmap ));
1652  PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
1653  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1654  ok( bits[0] == 0x5555 || broken(bits[0] == 0xaada) /* XP SP1 & 2003 SP0 */,
1655  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1656  DeleteObject( SelectObject( hdc, old_brush ));
1657 
1658  /* mono DDB bitmap */
1659  memdc = CreateCompatibleDC( hdc );
1660  SelectObject( memdc, bitmap );
1661  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1662  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1663  ok( bits[0] == 0x5555,
1664  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1665  SetTextColor( memdc, RGB(255,255,255) );
1666  SetBkColor( memdc, RGB(0,0,0) );
1667  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1668  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1669  ok( bits[0] == 0x5555,
1670  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1671 
1672  /* mono DIB section */
1673  memset( buffer, 0, sizeof(buffer) );
1674  info->bmiHeader.biSize = sizeof(info->bmiHeader);
1675  info->bmiHeader.biHeight = -16;
1676  info->bmiHeader.biWidth = 16;
1677  info->bmiHeader.biBitCount = 1;
1678  info->bmiHeader.biPlanes = 1;
1679  info->bmiHeader.biCompression = BI_RGB;
1680  colors[0].rgbRed = 0xff;
1681  colors[0].rgbGreen = 0xff;
1682  colors[0].rgbBlue = 0xf0;
1683  colors[1].rgbRed = 0x20;
1684  colors[1].rgbGreen = 0x0;
1685  colors[1].rgbBlue = 0x0;
1686  bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, &bits_ptr, NULL, 0 );
1687  memset( bits_ptr, 0x55, 64 );
1688  DeleteObject( SelectObject( memdc, bitmap ));
1689  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1690  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1691  ok( bits[0] == 0x5555,
1692  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1693 
1694  colors[0].rgbRed = 0x0;
1695  colors[0].rgbGreen = 0x0;
1696  colors[0].rgbBlue = 0x10;
1697  colors[1].rgbRed = 0xff;
1698  colors[1].rgbGreen = 0xf0;
1699  colors[1].rgbBlue = 0xff;
1700  bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, &bits_ptr, NULL, 0 );
1701  memset( bits_ptr, 0x55, 64 );
1702  DeleteObject( SelectObject( memdc, bitmap ));
1703  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1704  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1705  ok( bits[0] == 0xaaaa,
1706  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1707 
1708  SetTextColor( memdc, RGB(0,20,0) );
1709  SetBkColor( memdc, RGB(240,240,240) );
1710  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1711  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1712  ok( bits[0] == 0x5555,
1713  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1714 
1715  SetTextColor( memdc, RGB(250,250,250) );
1716  SetBkColor( memdc, RGB(10,10,10) );
1717  BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
1718  GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
1719  ok( bits[0] == 0xaaaa,
1720  "wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
1721  DeleteDC( memdc );
1722  DeleteObject( bitmap );
1723 }
unsigned short WORD
Definition: ntddk_ex.h:93
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define HBITMAP
Definition: msvc.h:28
COLORREF WINAPI GetNearestColor(_In_ HDC, _In_ COLORREF)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLuint buffer
Definition: glext.h:5915
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
Definition: compobj.c:611
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
UCHAR rgbBlue
Definition: inbv.c:118
UCHAR rgbGreen
Definition: inbv.c:119
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
UCHAR rgbRed
Definition: inbv.c:120
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_SOLID
Definition: wingdi.h:584
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_black_pen(COLORREF fg, COLORREF bg, int r, int g, int b)
Definition: bitmap.c:1607
#define ok(value,...)
Definition: CComObject.cpp:34
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
struct tagRGBQUAD RGBQUAD
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2917
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
#define broken(x)
Definition: _sntprintf.h:21
#define PATCOPY
Definition: wingdi.h:333
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:778
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static HDC
Definition: bitmap.c:44
GLuint res
Definition: glext.h:9613
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:365
DWORD COLORREF
Definition: windef.h:290
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
static COLORREF get_nearest(int r, int g, int b)
Definition: bitmap.c:1602
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define SRCCOPY
Definition: wingdi.h:331
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
static void test_bitmap_info ( HBITMAP  hbm,
INT  expected_depth,
const BITMAPINFOHEADER bmih 
)
static

Definition at line 64 of file bitmap.c.

Referenced by test_createdibitmap().

65 {
66  BITMAP bm;
67  BITMAP bma[2];
68  INT ret, width_bytes, i;
69  BYTE buf[512], buf_cmp[512];
70  INT test_size[] = {0 /*first value will be changed */, 0, -1, -1000, ~0, sizeof(buf)};
71 
72  ret = GetObjectW(hbm, sizeof(bm), &bm);
73  ok(ret == sizeof(bm), "GetObject returned %d\n", ret);
74 
75  ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
76  ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth);
77  ok(bm.bmHeight == bmih->biHeight, "wrong bm.bmHeight %d\n", bm.bmHeight);
78  width_bytes = get_bitmap_stride(bm.bmWidth, bm.bmBitsPixel);
79  ok(bm.bmWidthBytes == width_bytes, "wrong bm.bmWidthBytes %d != %d\n", bm.bmWidthBytes, width_bytes);
80  ok(bm.bmPlanes == bmih->biPlanes, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
81  ok(bm.bmBitsPixel == expected_depth, "wrong bm.bmBitsPixel %d != %d\n", bm.bmBitsPixel, expected_depth);
82  ok(bm.bmBits == NULL, "wrong bm.bmBits %p\n", bm.bmBits);
83 
84  assert(sizeof(buf) >= bm.bmWidthBytes * bm.bmHeight);
85  assert(sizeof(buf) == sizeof(buf_cmp));
86 
87  SetLastError(0xdeadbeef);
88  test_size[0] = bm.bmWidthBytes * bm.bmHeight;
89  /* NULL output buffer with different count values */
90  for (i = 0; i < sizeof(test_size) / sizeof(test_size[0]); i++)
91  {
92  ret = GetBitmapBits(hbm, test_size[i], NULL);
93  ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
94  }
95 
96  memset(buf_cmp, 0xAA, sizeof(buf_cmp));
97  memset(buf_cmp, 0, bm.bmWidthBytes * bm.bmHeight);
98 
99  /* Correct output buffer with different count values */
100  for (i = 0; i < sizeof(test_size) / sizeof(test_size[0]); i++)
101  {
102  int expect = i == 1 ? 0 : bm.bmWidthBytes * bm.bmHeight;
103  memset(buf, 0xAA, sizeof(buf));
104  ret = GetBitmapBits(hbm, test_size[i], buf);
105  ok(ret == expect, "Test[%d]: %d != %d\n", i, ret, expect);
106  if (expect)
107  ok(!memcmp(buf, buf_cmp, sizeof(buf)),
108  "Test[%d]: buffers do not match, depth %d\n", i, bmih->biBitCount);
109  }
110 
111  /* test various buffer sizes for GetObject */
112  ret = GetObjectW(hbm, sizeof(*bma) * 2, bma);
113  ok(ret == sizeof(*bma), "wrong size %d\n", ret);
114 
115  ret = GetObjectW(hbm, sizeof(bm) / 2, &bm);
116  ok(ret == 0, "%d != 0\n", ret);
117 
118  ret = GetObjectW(hbm, 0, &bm);
119  ok(ret == 0, "%d != 0\n", ret);
120 
121  ret = GetObjectW(hbm, 1, &bm);
122  ok(ret == 0, "%d != 0\n", ret);
123 
124  ret = GetObjectW(hbm, 0, NULL);
125  ok(ret == sizeof(bm), "wrong size %d\n", ret);
126 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define assert(x)
Definition: debug.h:53
int32_t INT
Definition: typedefs.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
static int get_bitmap_stride(int width, int bpp)
Definition: bitmap.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
#define SetLastError(x)
Definition: compat.h:409
int ret
static UINT width_bytes(UINT width, UINT bpp)
Definition: tiffformat.c:734
unsigned char BYTE
Definition: ntddk_ex.h:96
static void test_size(void)
Definition: monthcal.c:1560
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331
#define expect(expected, got)
Definition: combo.c:36
#define memset(x, y, z)
Definition: compat.h:39
static void test_bitmapinfoheadersize ( void  )
static

Definition at line 2874 of file bitmap.c.

Referenced by START_TEST().

2875 {
2876  HBITMAP hdib;
2877  BITMAPINFO bmi;
2878  BITMAPCOREINFO bci;
2879  HDC hdc = GetDC(0);
2880 
2881  memset(&bmi, 0, sizeof(BITMAPINFO));
2882  bmi.bmiHeader.biHeight = 100;
2883  bmi.bmiHeader.biWidth = 512;
2884  bmi.bmiHeader.biBitCount = 24;
2885  bmi.bmiHeader.biPlanes = 1;
2886 
2887  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER) - 1;
2888 
2889  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2890  ok(hdib == NULL, "CreateDIBSection succeeded\n");
2891 
2892  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2893 
2894  SetLastError(0xdeadbeef);
2895  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2896  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
2897  DeleteObject(hdib);
2898 
2899  bmi.bmiHeader.biSize++;
2900 
2901  SetLastError(0xdeadbeef);
2902  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2903  ok(hdib != NULL ||
2904  broken(!hdib), /* Win98, WinMe */
2905  "CreateDIBSection error %d\n", GetLastError());
2906  DeleteObject(hdib);
2907 
2908  bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
2909 
2910  SetLastError(0xdeadbeef);
2911  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2912  ok(hdib != NULL ||
2913  broken(!hdib), /* Win98, WinMe */
2914  "CreateDIBSection error %d\n", GetLastError());
2915  DeleteObject(hdib);
2916 
2917  bmi.bmiHeader.biSize++;
2918 
2919  SetLastError(0xdeadbeef);
2920  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2921  ok(hdib != NULL ||
2922  broken(!hdib), /* Win98, WinMe */
2923  "CreateDIBSection error %d\n", GetLastError());
2924  DeleteObject(hdib);
2925 
2926  bmi.bmiHeader.biSize = sizeof(BITMAPV4HEADER);
2927 
2928  SetLastError(0xdeadbeef);
2929  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2930  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
2931  DeleteObject(hdib);
2932 
2933  bmi.bmiHeader.biSize = sizeof(BITMAPV5HEADER);
2934 
2935  SetLastError(0xdeadbeef);
2936  hdib = CreateDIBSection(hdc, &bmi, 0, NULL, NULL, 0);
2937  ok(hdib != NULL ||
2938  broken(!hdib), /* Win95 */
2939  "CreateDIBSection error %d\n", GetLastError());
2940  DeleteObject(hdib);
2941 
2942  memset(&bci, 0, sizeof(BITMAPCOREINFO));
2943  bci.bmciHeader.bcHeight = 100;
2944  bci.bmciHeader.bcWidth = 512;
2945  bci.bmciHeader.bcBitCount = 24;
2946  bci.bmciHeader.bcPlanes = 1;
2947 
2948  bci.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER) - 1;
2949 
2950  hdib = CreateDIBSection(hdc, (BITMAPINFO *)&bci, 0, NULL, NULL, 0);
2951  ok(hdib == NULL, "CreateDIBSection succeeded\n");
2952 
2953  bci.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER);
2954 
2955  SetLastError(0xdeadbeef);
2956  hdib = CreateDIBSection(hdc, (BITMAPINFO *)&bci, 0, NULL, NULL, 0);
2957  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
2958  DeleteObject(hdib);
2959 
2960  bci.bmciHeader.bcSize++;
2961 
2962  hdib = CreateDIBSection(hdc, (BITMAPINFO *)&bci, 0, NULL, NULL, 0);
2963  ok(hdib == NULL, "CreateDIBSection succeeded\n");
2964 
2965  bci.bmciHeader.bcSize = sizeof(BITMAPCOREINFO);
2966 
2967  hdib = CreateDIBSection(hdc, (BITMAPINFO *)&bci, 0, NULL, NULL, 0);
2968  ok(hdib == NULL, "CreateDIBSection succeeded\n");
2969 
2970  ReleaseDC(0, hdc);
2971 }
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
HDC WINAPI GetDC(_In_opt_ HWND)
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1430
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define SetLastError(x)
Definition: compat.h:409
struct _BITMAPCOREINFO BITMAPCOREINFO
#define broken(x)
Definition: _sntprintf.h:21
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static HDC
Definition: bitmap.c:44
#define memset(x, y, z)
Definition: compat.h:39
struct tagBITMAPINFO BITMAPINFO
static void test_bmBits ( void  )
static

Definition at line 1785 of file bitmap.c.

Referenced by START_TEST().

1786 {
1787  BYTE bits[4];
1788  HBITMAP hbmp;
1789  BITMAP bmp;
1790 
1791  memset(bits, 0, sizeof(bits));
1792  hbmp = CreateBitmap(2, 2, 1, 4, bits);
1793  ok(hbmp != NULL, "CreateBitmap failed\n");
1794 
1795  memset(&bmp, 0xFF, sizeof(bmp));
1796  ok(GetObjectW(hbmp, sizeof(bmp), &bmp) == sizeof(bmp),
1797  "GetObject failed or returned a wrong structure size\n");
1798  ok(!bmp.bmBits, "bmBits must be NULL for device-dependent bitmaps\n");
1799 
1800  DeleteObject(hbmp);
1801 }
#define HBITMAP
Definition: msvc.h:28
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
BITMAP bmp
Definition: alphablend.c:62
unsigned char BYTE
Definition: ntddk_ex.h:96
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
Definition: bl.h:1331
HBITMAP hbmp
Definition: msvc.h:60
#define memset(x, y, z)
Definition: compat.h:39
static void test_clipping ( void  )
static

Definition at line 3949 of file bitmap.c.

Referenced by START_TEST().

3950 {
3951  HBITMAP bmpDst;
3952  HBITMAP bmpSrc;
3953  HRGN hRgn;
3954  LPVOID bits;
3955  BOOL result;
3956 
3959 
3960  BITMAPINFO bmpinfo={{0}};
3961  bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3962  bmpinfo.bmiHeader.biWidth = 100;
3963  bmpinfo.bmiHeader.biHeight = 100;
3964  bmpinfo.bmiHeader.biPlanes = 1;
3965  bmpinfo.bmiHeader.biBitCount = GetDeviceCaps( hdcDst, BITSPIXEL );
3966  bmpinfo.bmiHeader.biCompression = BI_RGB;
3967 
3968  bmpDst = CreateDIBSection( hdcDst, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
3969  ok(bmpDst != NULL, "Couldn't create destination bitmap\n");
3970  SelectObject( hdcDst, bmpDst );
3971 
3972  bmpSrc = CreateDIBSection( hdcSrc, &bmpinfo, DIB_RGB_COLORS, &bits, NULL, 0 );
3973  ok(bmpSrc != NULL, "Couldn't create source bitmap\n");
3974  SelectObject( hdcSrc, bmpSrc );
3975 
3976  result = BitBlt( hdcDst, 0, 0, 100, 100, hdcSrc, 100, 100, SRCCOPY );
3977  ok(result, "BitBlt failed\n");
3978 
3979  hRgn = CreateRectRgn( 0,0,0,0 );
3980  SelectClipRgn( hdcDst, hRgn );
3981 
3982  result = BitBlt( hdcDst, 0, 0, 100, 100, hdcSrc, 0, 0, SRCCOPY );
3983  ok(result, "BitBlt failed\n");
3984 
3985  DeleteObject( bmpDst );
3986  DeleteObject( bmpSrc );
3987  DeleteObject( hRgn );
3988  DeleteDC( hdcDst );
3989  DeleteDC( hdcSrc );
3990 }
#define BITSPIXEL
Definition: wingdi.h:718
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define HRGN
Definition: msvc.h:39
static HRGN hRgn
Definition: mapping.c:33
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HDC hdcSrc
Definition: xlate.c:32
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static HDC hdcDst
Definition: xlate.c:32
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static HDC
Definition: bitmap.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:365
GLuint64EXT * result
Definition: glext.h:11304
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:331
static void test_CreateBitmap ( void  )
static

Definition at line 2771 of file bitmap.c.

Referenced by START_TEST().

2772 {
2773  BITMAP bmp;
2774  HDC screenDC = GetDC(0);
2775  HDC hdc = CreateCompatibleDC(screenDC);
2776  UINT i, expect = 0;
2777 
2778  /* all of these are the stock monochrome bitmap */
2779  HBITMAP bm = CreateCompatibleBitmap(hdc, 0, 0);
2780  HBITMAP bm1 = CreateCompatibleBitmap(screenDC, 0, 0);
2781  HBITMAP bm4 = CreateBitmap(0, 1, 0, 0, 0);
2782  HBITMAP bm5 = CreateDiscardableBitmap(hdc, 0, 0);
2783  HBITMAP curObj1 = GetCurrentObject(hdc, OBJ_BITMAP);
2784  HBITMAP curObj2 = GetCurrentObject(screenDC, OBJ_BITMAP);
2785 
2786  /* these 2 are not the stock monochrome bitmap */
2787  HBITMAP bm2 = CreateCompatibleBitmap(hdc, 1, 1);
2788  HBITMAP bm3 = CreateBitmap(1, 1, 1, 1, 0);
2789 
2790  HBITMAP old1 = SelectObject(hdc, bm2);
2791  HBITMAP old2 = SelectObject(screenDC, bm3);
2792  SelectObject(hdc, old1);
2793  SelectObject(screenDC, old2);
2794 
2795  ok(bm == bm1 && bm == bm4 && bm == bm5 && bm == curObj1 && bm == old1,
2796  "0: %p, 1: %p, 4: %p, 5: %p, curObj1 %p, old1 %p\n",
2797  bm, bm1, bm4, bm5, curObj1, old1);
2798  ok(bm != bm2 && bm != bm3, "0: %p, 2: %p, 3: %p\n", bm, bm2, bm3);
2799 todo_wine
2800  ok(bm != curObj2, "0: %p, curObj2 %p\n", bm, curObj2);
2801  ok(old2 == 0, "old2 %p\n", old2);
2802 
2803  test_mono_1x1_bmp(bm);
2804  test_mono_1x1_bmp(bm1);
2805  test_mono_1x1_bmp(bm2);
2806  test_mono_1x1_bmp(bm3);
2807  test_mono_1x1_bmp(bm4);
2808  test_mono_1x1_bmp(bm5);
2809  test_mono_1x1_bmp(old1);
2810  test_mono_1x1_bmp(curObj1);
2811 
2812  DeleteObject(bm);
2813  DeleteObject(bm1);
2814  DeleteObject(bm2);
2815  DeleteObject(bm3);
2816  DeleteObject(bm4);
2817  DeleteObject(bm5);
2818 
2819  DeleteDC(hdc);
2820  ReleaseDC(0, screenDC);
2821 
2822  /* show that Windows ignores the provided bm.bmWidthBytes */
2823  bmp.bmType = 0;
2824  bmp.bmWidth = 1;
2825  bmp.bmHeight = 1;
2826  bmp.bmWidthBytes = 28;
2827  bmp.bmPlanes = 1;
2828  bmp.bmBitsPixel = 1;
2829  bmp.bmBits = NULL;
2830  bm = CreateBitmapIndirect(&bmp);
2831  ok(bm != 0, "CreateBitmapIndirect error %u\n", GetLastError());
2832  test_mono_1x1_bmp(bm);
2833  DeleteObject(bm);
2834 
2835  /* Test how the bmBitsPixel field is treated */
2836  for(i = 1; i <= 33; i++) {
2837  bmp.bmType = 0;
2838  bmp.bmWidth = 1;
2839  bmp.bmHeight = 1;
2840  bmp.bmWidthBytes = 28;
2841  bmp.bmPlanes = 1;
2842  bmp.bmBitsPixel = i;
2843  bmp.bmBits = NULL;
2844  SetLastError(0xdeadbeef);
2845  bm = CreateBitmapIndirect(&bmp);
2846  if(i > 32) {
2847  DWORD error = GetLastError();
2848  ok(bm == 0, "CreateBitmapIndirect for %d bpp succeeded\n", i);
2849  ok(error == ERROR_INVALID_PARAMETER, "Got error %d, expected ERROR_INVALID_PARAMETER\n", error);
2850  DeleteObject(bm);
2851  continue;
2852  }
2853  ok(bm != 0, "CreateBitmapIndirect error %u\n", GetLastError());
2854  GetObjectW(bm, sizeof(bmp), &bmp);
2855  if(i == 1) {
2856  expect = 1;
2857  } else if(i <= 4) {
2858  expect = 4;
2859  } else if(i <= 8) {
2860  expect = 8;
2861  } else if(i <= 16) {
2862  expect = 16;
2863  } else if(i <= 24) {
2864  expect = 24;
2865  } else if(i <= 32) {
2866  expect = 32;
2867  }
2868  ok(bmp.bmBitsPixel == expect, "CreateBitmapIndirect for a %d bpp bitmap created a %d bpp bitmap, expected %d\n",
2869  i, bmp.bmBitsPixel, expect);
2870  DeleteObject(bm);
2871  }
2872 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
HBITMAP WINAPI CreateDiscardableBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:297
#define HBITMAP
Definition: msvc.h:28
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define test_mono_1x1_bmp(a)
Definition: bitmap.c:2769
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
DWORD DWORD
Definition: winlogon.h:75
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
HBITMAP WINAPI CreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:307
#define ok(value,...)
Definition: CComObject.cpp:34
#define SetLastError(x)
Definition: compat.h:409
HBITMAP WINAPI CreateBitmapIndirect(const BITMAP *pbm)
Definition: bitmap.c:275
BITMAP bmp
Definition: alphablend.c:62
#define todo_wine
Definition: test.h:154
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
static HDC
Definition: bitmap.c:44
#define expect(expected, got)
Definition: combo.c:36
unsigned int UINT
Definition: ndis.h:50
#define OBJ_BITMAP
Definition: objidl.idl:1415
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
static void test_createdibitmap ( void  )
static

Definition at line 128 of file bitmap.c.

Referenced by START_TEST().

129 {
130  HDC hdc, hdcmem;
131  BITMAPINFOHEADER bmih;
132  BITMAPINFO bm;
133  HBITMAP hbm, hbm_colour, hbm_old;
134  INT screen_depth;
135  DWORD pixel;
136 
137  hdc = GetDC(0);
138  screen_depth = GetDeviceCaps(hdc, BITSPIXEL);
139  memset(&bmih, 0, sizeof(bmih));
140  bmih.biSize = sizeof(bmih);
141  bmih.biWidth = 10;
142  bmih.biHeight = 10;
143  bmih.biPlanes = 1;
144  bmih.biBitCount = 32;
145  bmih.biCompression = BI_RGB;
146 
147  hbm = CreateDIBitmap(hdc, NULL, CBM_INIT, NULL, NULL, 0);
148  ok(hbm == NULL, "CreateDIBitmap should fail\n");
149  hbm = CreateDIBitmap(hdc, NULL, 0, NULL, NULL, 0);
150  ok(hbm == NULL, "CreateDIBitmap should fail\n");
151 
152  /* First create an un-initialised bitmap. The depth of the bitmap
153  should match that of the hdc and not that supplied in bmih.
154  */
155 
156  /* First try 32 bits */
157  hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
158  ok(hbm != NULL, "CreateDIBitmap failed\n");
159  test_bitmap_info(hbm, screen_depth, &bmih);
160  DeleteObject(hbm);
161 
162  /* Then 16 */
163  bmih.biBitCount = 16;
164  hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
165  ok(hbm != NULL, "CreateDIBitmap failed\n");
166  test_bitmap_info(hbm, screen_depth, &bmih);
167  DeleteObject(hbm);
168 
169  /* Then 1 */
170  bmih.biBitCount = 1;
171  hbm = CreateDIBitmap(hdc, &bmih, 0, NULL, NULL, 0);
172  ok(hbm != NULL, "CreateDIBitmap failed\n");
173  test_bitmap_info(hbm, screen_depth, &bmih);
174  DeleteObject(hbm);
175 
176  /* Now with a monochrome dc we expect a monochrome bitmap */
177  hdcmem = CreateCompatibleDC(hdc);
178 
179  /* First try 32 bits */
180  bmih.biBitCount = 32;
181  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
182  ok(hbm != NULL, "CreateDIBitmap failed\n");
183  test_bitmap_info(hbm, 1, &bmih);
184  DeleteObject(hbm);
185 
186  /* Then 16 */
187  bmih.biBitCount = 16;
188  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
189  ok(hbm != NULL, "CreateDIBitmap failed\n");
190  test_bitmap_info(hbm, 1, &bmih);
191  DeleteObject(hbm);
192 
193  /* Then 1 */
194  bmih.biBitCount = 1;
195  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
196  ok(hbm != NULL, "CreateDIBitmap failed\n");
197  test_bitmap_info(hbm, 1, &bmih);
198  DeleteObject(hbm);
199 
200  /* Now select a polychrome bitmap into the dc and we expect
201  screen_depth bitmaps again */
202  hbm_colour = CreateCompatibleBitmap(hdc, bmih.biWidth, bmih.biHeight);
203  test_bitmap_info(hbm_colour, screen_depth, &bmih);
204  hbm_old = SelectObject(hdcmem, hbm_colour);
205 
206  /* First try 32 bits */
207  bmih.biBitCount = 32;
208  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
209  ok(hbm != NULL, "CreateDIBitmap failed\n");
210  test_bitmap_info(hbm, screen_depth, &bmih);
211  DeleteObject(hbm);
212 
213  /* Then 16 */
214  bmih.biBitCount = 16;
215  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
216  ok(hbm != NULL, "CreateDIBitmap failed\n");
217  test_bitmap_info(hbm, screen_depth, &bmih);
218  DeleteObject(hbm);
219 
220  /* Then 1 */
221  bmih.biBitCount = 1;
222  hbm = CreateDIBitmap(hdcmem, &bmih, 0, NULL, NULL, 0);
223  ok(hbm != NULL, "CreateDIBitmap failed\n");
224  test_bitmap_info(hbm, screen_depth, &bmih);
225  DeleteObject(hbm);
226 
227  SelectObject(hdcmem, hbm_old);
228  DeleteObject(hbm_colour);
229  DeleteDC(hdcmem);
230 
231  bmih.biBitCount = 32;
232  hbm = CreateDIBitmap(0, &bmih, 0, NULL, NULL, 0);
233  ok(hbm != NULL, "CreateDIBitmap failed\n");
234  test_bitmap_info(hbm, 1, &bmih);
235  DeleteObject(hbm);
236 
237  /* Test how formats are converted */
238  pixel = 0xffffffff;
239  bmih.biBitCount = 1;
240  bmih.biWidth = 1;
241  bmih.biHeight = 1;
242 
243  memset(&bm, 0, sizeof(bm));
244  bm.bmiHeader.biSize = sizeof(bm.bmiHeader);
245  bm.bmiHeader.biWidth = 1;
246  bm.bmiHeader.biHeight = 1;
247  bm.bmiHeader.biPlanes = 1;
248  bm.bmiHeader.biBitCount= 24;
250  bm.bmiHeader.biSizeImage = 0;
251  hbm = CreateDIBitmap(hdc, &bmih, CBM_INIT, &pixel, &bm, DIB_RGB_COLORS);
252  ok(hbm != NULL, "CreateDIBitmap failed\n");
253 
254  pixel = 0xdeadbeef;
255  bm.bmiHeader.biBitCount= 32;
256  GetDIBits(hdc, hbm, 0, 1, &pixel, &bm, DIB_RGB_COLORS);
257  ok(pixel == 0x00ffffff, "Reading a 32 bit pixel from a DDB returned %08x\n", pixel);
258  DeleteObject(hbm);
259 
260  ReleaseDC(0, hdc);
261 }
#define BITSPIXEL
Definition: wingdi.h:718
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
HDC WINAPI GetDC(_In_opt_ HWND)
INT WINAPI GetDIBits(HDC hDC, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uUsage)
Definition: bitmap.c:354
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:75
#define CBM_INIT
Definition: wingdi.h:363
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD biCompression
Definition: amvideo.idl:35
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
HBITMAP WINAPI CreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:307
#define ok(value,...)
Definition: CComObject.cpp:34
static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHEADER *bmih)
Definition: bitmap.c:64
HBITMAP WINAPI CreateDIBitmap(HDC hDC, const BITMAPINFOHEADER *Header, DWORD Init, LPCVOID Bits, const BITMAPINFO *Data, UINT ColorUse)
Definition: bitmap.c:398
DWORD biSizeImage
Definition: amvideo.idl:36
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
static HDC
Definition: bitmap.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
static void test_D3DKMTCreateDCFromMemory ( void  )
static

Definition at line 5667 of file bitmap.c.

Referenced by START_TEST().

5668 {
5669  D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
5670  D3DKMT_CREATEDCFROMMEMORY create_desc;
5671  unsigned int width_bytes;
5672  unsigned int i, x, y, z;
5673  DWORD expected, colour;
5674  BYTE data[12][48];
5675  NTSTATUS status;
5676  HGDIOBJ *bitmap;
5677  DIBSECTION dib;
5678  BOOL fail, ret;
5679  DWORD type, pixel;
5680  int size;
5681  HDC bmp_dc;
5682  HBITMAP bmp;
5683 
5684  static const struct
5685  {
5686  const char *name;
5688  unsigned int bit_count;
5689  DWORD mask_r, mask_g, mask_b;
5690  NTSTATUS status;
5691  }
5692  test_data[] =
5693  {
5694  { "R8G8B8", D3DDDIFMT_R8G8B8, 24, 0x00000000, 0x00000000, 0x00000000, STATUS_SUCCESS },
5695  { "A8R8G8B8", D3DDDIFMT_A8R8G8B8, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_SUCCESS },
5696  { "X8R8G8B8", D3DDDIFMT_X8R8G8B8, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_SUCCESS },
5697  { "R5G6B5", D3DDDIFMT_R5G6B5, 16, 0x0000f800, 0x000007e0, 0x0000001f, STATUS_SUCCESS },
5698  { "X1R5G5B5", D3DDDIFMT_X1R5G5B5, 16, 0x00007c00, 0x000003e0, 0x0000001f, STATUS_SUCCESS },
5699  { "A1R5G5B5", D3DDDIFMT_A1R5G5B5, 16, 0x00007c00, 0x000003e0, 0x0000001f, STATUS_SUCCESS },
5700  { "R3G3B2", D3DDDIFMT_R3G3B2, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5701  { "A2B10G10R10", D3DDDIFMT_A2B10G10R10, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5702  { "A8B8G8R8", D3DDDIFMT_A8B8G8R8, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5703  { "X8B8G8R8", D3DDDIFMT_A8B8G8R8, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5704  { "A2R10G10B10", D3DDDIFMT_A2R10G10B10, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5705  { "P8", D3DDDIFMT_P8, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_SUCCESS },
5706  { "L8", D3DDDIFMT_L8, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5707  { "A8L8", D3DDDIFMT_A8L8, 16, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5708  { "V8U8", D3DDDIFMT_V8U8, 16, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5709  { "Q8W8V8U8", D3DDDIFMT_Q8W8V8U8, 32, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5710  { "DXT1", D3DDDIFMT_DXT1, 4, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5711  { "DXT2", D3DDDIFMT_DXT2, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5712  { "DXT3", D3DDDIFMT_DXT3, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5713  { "DXT4", D3DDDIFMT_DXT4, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5714  { "DXT5", D3DDDIFMT_DXT5, 8, 0x00000000, 0x00000000, 0x00000000, STATUS_INVALID_PARAMETER },
5715  };
5716 
5717  if (!pD3DKMTCreateDCFromMemory)
5718  {
5719  win_skip("D3DKMTCreateDCFromMemory() is not implemented.\n");
5720  return;
5721  }
5722 
5723  status = pD3DKMTCreateDCFromMemory( NULL );
5724  ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status);
5725 
5726  for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
5727  {
5728  memset( data, 0xaa, sizeof(data) );
5729 
5730  create_desc.pMemory = data;
5731  create_desc.Format = test_data[i].format;
5732  create_desc.Width = 9;
5733  create_desc.Height = 7;
5734  create_desc.Pitch = sizeof(*data);
5735  create_desc.hDeviceDc = NULL;
5736  create_desc.pColorTable = NULL;
5737  create_desc.hDc = (void *)0x010baade;
5738  create_desc.hBitmap = (void *)0x020baade;
5739 
5740  status = pD3DKMTCreateDCFromMemory( &create_desc );
5741  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n",
5742  test_data[i].name, status);
5743 
5744  create_desc.hDeviceDc = CreateCompatibleDC( NULL );
5745  create_desc.pMemory = NULL;
5746  status = pD3DKMTCreateDCFromMemory( &create_desc );
5747  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n",
5748  test_data[i].name, status);
5749 
5750  create_desc.pMemory = data;
5751  create_desc.Height = 0;
5752  status = pD3DKMTCreateDCFromMemory( &create_desc );
5753  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n",
5754  test_data[i].name, status);
5755  ok(create_desc.hDc == (void *)0x010baade, "%s: Got unexpected dc %p.\n",
5756  test_data[i].name, create_desc.hDc);
5757  ok(create_desc.hBitmap == (void *)0x020baade, "%s: Got unexpected bitmap %p.\n",
5758  test_data[i].name, create_desc.hBitmap);
5759 
5760  create_desc.Height = 7;
5761  create_desc.Width = 0;
5762  status = pD3DKMTCreateDCFromMemory( &create_desc );
5763  ok(status == test_data[i].status, "%s: Got unexpected status %#x, expected %#x.\n",
5764  test_data[i].name, status, test_data[i].status);
5765  if (status == STATUS_SUCCESS)
5766  {
5767  destroy_desc.hDc = create_desc.hDc;
5768  destroy_desc.hBitmap = create_desc.hBitmap;
5769  status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5770  ok(status == STATUS_SUCCESS, "%s: Got unexpected status %#x.\n", test_data[i].name, status);
5771  create_desc.hDc = (void *)0x010baade;
5772  create_desc.hBitmap = (void *)0x020baade;
5773  }
5774 
5775  create_desc.Pitch = 0;
5776  status = pD3DKMTCreateDCFromMemory( &create_desc );
5777  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n",
5778  test_data[i].name, status);
5779  ok(create_desc.hDc == (void *)0x010baade, "%s: Got unexpected dc %p.\n",
5780  test_data[i].name, create_desc.hDc);
5781  ok(create_desc.hBitmap == (void *)0x020baade, "%s: Got unexpected bitmap %p.\n",
5782  test_data[i].name, create_desc.hBitmap);
5783 
5784  create_desc.Width = 9;
5785  create_desc.Pitch = sizeof(*data);
5786  status = pD3DKMTCreateDCFromMemory( &create_desc );
5787  ok(status == test_data[i].status, "%s: Got unexpected status %#x, expected %#x.\n",
5788  test_data[i].name, status, test_data[i].status);
5789  if (status == STATUS_SUCCESS)
5790  {
5791  ok(!!create_desc.hDc, "%s: Got unexpected dc %p.\n",
5792  test_data[i].name, create_desc.hDc);
5793  ok(!!create_desc.hBitmap, "%s: Got unexpected bitmap %p.\n",
5794  test_data[i].name, create_desc.hBitmap);
5795  }
5796  else
5797  {
5798  ok(create_desc.hDc == (void *)0x010baade, "%s: Got unexpected dc %p.\n",
5799  test_data[i].name, create_desc.hDc);
5800  ok(create_desc.hBitmap == (void *)0x020baade, "%s: Got unexpected bitmap %p.\n",
5801  test_data[i].name, create_desc.hBitmap);
5802  continue;
5803  }
5804 
5805  type = GetObjectType( create_desc.hDc );
5806  ok(type == OBJ_MEMDC, "%s: Got unexpected object type %#x.\n", test_data[i].name, type);
5807  type = GetObjectType( create_desc.hBitmap );
5808  ok(type == OBJ_BITMAP, "%s: Got unexpected object type %#x.\n", test_data[i].name, type);
5809  bitmap = GetCurrentObject( create_desc.hDc, OBJ_BITMAP );
5810  ok(bitmap == create_desc.hBitmap, "%s: Got unexpected bitmap %p, expected %p.\n",
5811  test_data[i].name, bitmap, create_desc.hBitmap);
5812 
5813  size = GetObjectA( bitmap, sizeof(dib), &dib );
5814  ok(size == sizeof(dib), "%s: Got unexpected size %d.\n", test_data[i].name, size);
5815  ok(!dib.dsBm.bmType, "%s: Got unexpected type %#x.\n",
5816  test_data[i].name, dib.dsBm.bmType);
5817  ok(dib.dsBm.bmWidth == create_desc.Width, "%s: Got unexpected width %d.\n",
5818  test_data[i].name, dib.dsBm.bmWidth);
5819  ok(dib.dsBm.bmHeight == create_desc.Height, "%s: Got unexpected height %d.\n",
5820  test_data[i].name, dib.dsBm.bmHeight);
5821  width_bytes = get_dib_stride( create_desc.Width, test_data[i].bit_count );
5822  ok(dib.dsBm.bmWidthBytes == width_bytes, "%s: Got unexpected width bytes %d.\n",
5823  test_data[i].name, dib.dsBm.bmWidthBytes);
5824  ok(dib.dsBm.bmPlanes == 1, "%s: Got unexpected plane count %d.\n",
5825  test_data[i].name, dib.dsBm.bmPlanes);
5826  ok(dib.dsBm.bmBitsPixel == test_data[i].bit_count, "%s: Got unexpected bit count %d.\n",
5827  test_data[i].name, dib.dsBm.bmBitsPixel);
5828  ok(dib.dsBm.bmBits == create_desc.pMemory, "%s: Got unexpected bits %p, expected %p.\n",
5829  test_data[i].name, dib.dsBm.bmBits, create_desc.pMemory);
5830 
5831  ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "%s: Got unexpected size %u.\n",
5832  test_data[i].name, dib.dsBmih.biSize);
5833  ok(dib.dsBmih.biWidth == create_desc.Width, "%s: Got unexpected width %d.\n",
5834  test_data[i].name, dib.dsBmih.biHeight);
5835  ok(dib.dsBmih.biHeight == create_desc.Height, "%s: Got unexpected height %d.\n",
5836  test_data[i].name, dib.dsBmih.biHeight);
5837  ok(dib.dsBmih.biPlanes == 1, "%s: Got unexpected plane count %u.\n",
5838  test_data[i].name, dib.dsBmih.biPlanes);
5839  ok(dib.dsBmih.biBitCount == test_data[i].bit_count, "%s: Got unexpected bit count %u.\n",
5840  test_data[i].name, dib.dsBmih.biBitCount);
5841  ok(dib.dsBmih.biCompression == (test_data[i].bit_count == 16 ? BI_BITFIELDS : BI_RGB),
5842  "%s: Got unexpected compression %#x.\n",
5843  test_data[i].name, dib.dsBmih.biCompression);
5844  ok(!dib.dsBmih.biSizeImage, "%s: Got unexpected image size %u.\n",
5845  test_data[i].name, dib.dsBmih.biSizeImage);
5846  ok(!dib.dsBmih.biXPelsPerMeter, "%s: Got unexpected horizontal resolution %d.\n",
5847  test_data[i].name, dib.dsBmih.biXPelsPerMeter);
5848  ok(!dib.dsBmih.biYPelsPerMeter, "%s: Got unexpected vertical resolution %d.\n",
5849  test_data[i].name, dib.dsBmih.biYPelsPerMeter);
5850  if (test_data[i].format == D3DDDIFMT_P8)
5851  {
5852  ok(dib.dsBmih.biClrUsed == 256, "%s: Got unexpected used colour count %u.\n",
5853  test_data[i].name, dib.dsBmih.biClrUsed);
5854  ok(dib.dsBmih.biClrImportant == 256, "%s: Got unexpected important colour count %u.\n",
5855  test_data[i].name, dib.dsBmih.biClrImportant);
5856  }
5857  else
5858  {
5859  ok(!dib.dsBmih.biClrUsed, "%s: Got unexpected used colour count %u.\n",
5860  test_data[i].name, dib.dsBmih.biClrUsed);
5861  ok(!dib.dsBmih.biClrImportant, "%s: Got unexpected important colour count %u.\n",
5862  test_data[i].name, dib.dsBmih.biClrImportant);
5863  }
5864 
5865  ok(dib.dsBitfields[0] == test_data[i].mask_r && dib.dsBitfields[1] == test_data[i].mask_g
5866  && dib.dsBitfields[2] == test_data[i].mask_b,
5867  "%s: Got unexpected colour masks 0x%08x 0x%08x 0x%08x.\n",
5868  test_data[i].name, dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2]);
5869  ok(!dib.dshSection, "%s: Got unexpected section %p.\n", test_data[i].name, dib.dshSection);
5870  ok(!dib.dsOffset, "%s: Got unexpected offset %u.\n", test_data[i].name, dib.dsOffset);
5871 
5872  ret = BitBlt( create_desc.hDc, 0, 0, 4, 10, NULL, 0, 0, BLACKNESS );
5873  ok(ret, "Failed to blit.\n");
5874  ret = BitBlt( create_desc.hDc, 1, 1, 2, 2, NULL, 0, 0, WHITENESS );
5875  ok(ret, "Failed to blit.\n");
5876 
5877  /* Also test blitting to a regular bitmap */
5878  bmp_dc = CreateCompatibleDC( create_desc.hDeviceDc );
5879  ok(bmp_dc != NULL, "failed to create DC\n");
5880  bmp = CreateCompatibleBitmap( bmp_dc, create_desc.Width, create_desc.Height );
5881  ok(bmp != NULL, "failed to create bmp\n");
5882  bmp = SelectObject( bmp_dc, bmp );
5883  ret = BitBlt( bmp_dc, 0, 0, create_desc.Width, create_desc.Height, create_desc.hDc, 0, 0, SRCCOPY );
5884  ok(ret, "Failed to blit.\n");
5885 
5886  destroy_desc.hDc = create_desc.hDc;
5887  destroy_desc.hBitmap = create_desc.hBitmap;
5888 
5889  status = pD3DKMTDestroyDCFromMemory( NULL );
5890  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n", test_data[i].name, status);
5891  status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5892  ok(status == STATUS_SUCCESS, "%s: Got unexpected status %#x.\n", test_data[i].name, status);
5893  status = pD3DKMTDestroyDCFromMemory( &destroy_desc );
5894  ok(status == STATUS_INVALID_PARAMETER, "%s: Got unexpected status %#x.\n", test_data[i].name, status);
5895 
5896  ret = DeleteDC( create_desc.hDeviceDc );
5897  ok(ret, "Failed to delete dc.\n");
5898 
5899  for (y = 0, fail = FALSE; y < 12 && !fail; ++y)
5900  {
5901  for (x = 0; x < sizeof(*data) / (test_data[i].bit_count / 8) && !fail; ++x)
5902  {
5903  for (z = 0, colour = 0; z < test_data[i].bit_count / 8; ++z)
5904  {
5905  colour = colour << 8 | data[y][x * (test_data[i].bit_count / 8) + z];
5906  }
5907 
5908  if ((x == 1 || x == 2) && (y == 1 || y == 2))
5909  expected = 0xffffffff >> (32 - test_data[i].bit_count);
5910  else if (x < 4 && y < 7)
5911  expected = 0x00000000;
5912  else
5913  expected = 0xaaaaaaaa >> (32 - test_data[i].bit_count);
5914  ok(colour == expected, "%s: Got unexpected colour 0x%08x at %u, %u, expected 0x%08x.\n",
5915  test_data[i].name, colour, x, y, expected);
5916  if (colour != expected)
5917  fail = TRUE;
5918 
5919  /* 'Xn' or 'An' formats don't successfully blit to the regular bmp */
5921  {
5922  pixel = GetPixel( bmp_dc, x, y );
5923  if ((x == 1 || x == 2) && (y == 1 || y == 2))
5924  expected = 0x00ffffff;
5925  else if (x < create_desc.Width && y < create_desc.Height)
5926  expected = 0x00000000;
5927  else
5928  expected = CLR_INVALID;
5929  ok(pixel == expected, "%s: got 0x%08x at %u, %u, expect 0x%08x\n", test_data[i].name,
5930  pixel, x, y, expected);
5931  }
5932  }
5933  }
5934 
5935  DeleteObject( SelectObject( bmp_dc, bmp ) );
5936  DeleteDC( bmp_dc );
5937  }
5938 }
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1647
#define TRUE
Definition: types.h:120
static int get_dib_stride(int width, int bpp)
Definition: bitmap.c:53
#define HBITMAP
Definition: msvc.h:28
DWORD biClrImportant
Definition: amvideo.idl:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_SUCCESS
Definition: btrfs.c:2690
LONG biXPelsPerMeter
Definition: amvideo.idl:37
#define OBJ_MEMDC
Definition: objidl.idl:1418
#define CLR_INVALID
Definition: wingdi.h:881
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static struct _test_data test_data[]
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
LONG biYPelsPerMeter
Definition: amvideo.idl:38
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD DWORD
Definition: winlogon.h:75
GLuint const GLchar * name
Definition: glext.h:6031
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
PALETTEENTRY * pColorTable
Definition: d3dkmthk.h:32
DWORD biCompression
Definition: amvideo.idl:35
GLdouble GLdouble z
Definition: glext.h:5874
smooth NULL
Definition: ftsmooth.c:416
HBITMAP WINAPI CreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:307
enum _D3DDDIFORMAT D3DDDIFORMAT
DWORD dsBitfields[3]
Definition: wingdi.h:1648
#define ok(value,...)
Definition: CComObject.cpp:34
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
LONG NTSTATUS
Definition: precomp.h:26
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
DWORD dsOffset
Definition: wingdi.h:1650
DWORD biSizeImage
Definition: amvideo.idl:36
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BITMAP bmp
Definition: alphablend.c:62
int ret
static UINT width_bytes(UINT width, UINT bpp)
Definition: tiffformat.c:734
HANDLE dshSection
Definition: wingdi.h:1649
#define WHITENESS
Definition: wingdi.h:335
unsigned char BYTE
Definition: ntddk_ex.h:96
#define BLACKNESS
Definition: wingdi.h:321
BOOL WINAPI DeleteDC(_In_ HDC)
static HDC
Definition: bitmap.c:44
BITMAP dsBm
Definition: wingdi.h:1646
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
static const BYTE dib[]
Definition: ole2.c:207
Definition: name.c:36
static HBITMAP bitmap
Definition: clipboard.c:1344
INT INT y
Definition: msvc.h:62
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
#define win_skip
Definition: test.h:141
#define BI_RGB
Definition: precomp.h:35
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define SRCCOPY
Definition: wingdi.h:331
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
BOOL expected
Definition: store.c:2063
INT x
Definition: msvc.h:62
static void test_dib_bits_access ( HBITMAP  hdib,
void bits 
)
static

Definition at line 376 of file bitmap.c.

Referenced by test_dibsections().

377 {
379  char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
380  DWORD data[256];
381  BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
382  HDC hdc;
383  char filename[MAX_PATH];
384  HANDLE file;
385  DWORD written;
386  INT ret;
387 
388  ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
389  "VirtualQuery failed\n");
390  ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
391  ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
392  ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
393  ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
394  ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
395  ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
396 
397  memset( pbmi, 0, sizeof(bmibuf) );
398  memset( data, 0xcc, sizeof(data) );
399  pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
400  pbmi->bmiHeader.biHeight = 16;
401  pbmi->bmiHeader.biWidth = 16;
402  pbmi->bmiHeader.biBitCount = 32;
403  pbmi->bmiHeader.biPlanes = 1;
405 
406  hdc = GetDC(0);
407 
408  ret = SetDIBits( hdc, hdib, 0, 16, data, pbmi, DIB_RGB_COLORS );
409  ok(ret == 16, "SetDIBits failed: expected 16 got %d\n", ret);
410 
411  ReleaseDC(0, hdc);
412 
413  ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
414  "VirtualQuery failed\n");
415  ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
416  ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
417  ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
418  ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
419  ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
420  ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
421 
422  /* try writing protected bits to a file */
423 
424  GetTempFileNameA( ".", "dib", 0, filename );
426  CREATE_ALWAYS, 0, 0 );
427  ok( file != INVALID_HANDLE_VALUE, "failed to open %s error %u\n", filename, GetLastError() );
428  ret = WriteFile( file, bits, 8192, &written, NULL );
429  ok( ret, "WriteFile failed error %u\n", GetLastError() );
430  if (ret) ok( written == 8192, "only wrote %u bytes\n", written );
431  CloseHandle( file );
432  DeleteFileA( filename );
433 }
#define CloseHandle
Definition: compat.h:398
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
HDC WINAPI GetDC(_In_opt_ HWND)
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
INT WINAPI SetDIBits(HDC hDC, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines, CONST VOID *lpvBits, CONST BITMAPINFO *lpbmi, UINT fuColorUse)
Definition: bitmap.c:562
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
const char * filename
Definition: ioapi.h:135
#define MEM_COMMIT
Definition: nt_native.h:1313
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:75
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD biCompression
Definition: amvideo.idl:35
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ok(value,...)
Definition: CComObject.cpp:34
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define MEM_PRIVATE
Definition: nt_native.h:1318
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
SIZE_T NTAPI VirtualQuery(IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:220
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define CREATE_ALWAYS
Definition: disk.h:72
const XML_Char XML_Encoding * info
Definition: expat.h:530
DWORD *typedef HANDLE
Definition: winlogon.h:52
static HDC
Definition: bitmap.c:44
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
struct tagBITMAPINFO BITMAPINFO
#define PAGE_READWRITE
Definition: nt_native.h:1304
static void test_dib_formats ( void  )
static

Definition at line 916 of file bitmap.c.

Referenced by START_TEST().

917 {
918  BITMAPINFO *bi;
919  char data[256];
920  void *bits;
921  int planes, bpp, compr, format;
922  HBITMAP hdib, hbmp;
923  HDC hdc, memdc;
924  UINT ret;
925  BOOL format_ok, expect_ok;
926 
927  bi = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ) );
928  hdc = GetDC( 0 );
929  memdc = CreateCompatibleDC( 0 );
930  hbmp = CreateCompatibleBitmap( hdc, 10, 10 );
931 
932  memset( data, 0xaa, sizeof(data) );
933 
935  skip("ROSTESTS-152: Skipping loop in test_dib_formats because it's too big and causes too many failures\n");
936  else
937  for (bpp = 0; bpp <= 64; bpp++)
938  {
939  for (planes = 0; planes <= 64; planes++)
940  {
941  for (compr = 0; compr < 8; compr++)
942  {
943  for (format = DIB_RGB_COLORS; format <= DIB_PAL_COLORS; format++)
944  {
945  switch (bpp)
946  {
947  case 1:
948  case 4:
949  case 8:
950  case 24: expect_ok = (compr == BI_RGB); break;
951  case 16:
952  case 32: expect_ok = (compr == BI_RGB || compr == BI_BITFIELDS); break;
953  default: expect_ok = FALSE; break;
954  }
955 
956  memset( bi, 0, sizeof(bi->bmiHeader) );
957  bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
958  bi->bmiHeader.biWidth = 2;
959  bi->bmiHeader.biHeight = 2;
960  bi->bmiHeader.biPlanes = planes;
961  bi->bmiHeader.biBitCount = bpp;
963  bi->bmiHeader.biSizeImage = 0;
964  memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 );
965  ret = GetDIBits(hdc, hbmp, 0, 0, data, bi, format);
966  if (expect_ok || (!bpp && compr != BI_JPEG && compr != BI_PNG) ||
967  (bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8))
968  ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
969  else
970  ok( !ret || broken(!bpp && (compr == BI_JPEG || compr == BI_PNG)), /* nt4 */
971  "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
972 
973  /* all functions check planes except GetDIBits with 0 lines */
974  format_ok = expect_ok;
975  if (!planes) expect_ok = FALSE;
976  memset( bi, 0, sizeof(bi->bmiHeader) );
977  bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
978  bi->bmiHeader.biWidth = 2;
979  bi->bmiHeader.biHeight = 2;
980  bi->bmiHeader.biPlanes = planes;
981  bi->bmiHeader.biBitCount = bpp;
983  bi->bmiHeader.biSizeImage = 0;
984  memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 );
985 
986  hdib = CreateDIBSection(hdc, bi, format, &bits, NULL, 0);
987  if (expect_ok && (planes == 1 || planes * bpp <= 16) &&
988  (compr != BI_BITFIELDS || format != DIB_PAL_COLORS))
989  ok( hdib != NULL, "CreateDIBSection failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
990  else
991  ok( hdib == NULL, "CreateDIBSection succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
992  if (hdib) DeleteObject( hdib );
993 
994  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, data, bi, format );
995  /* no sanity checks in CreateDIBitmap except compression */
996  if (compr == BI_JPEG || compr == BI_PNG)
997  ok( hdib == NULL || broken(hdib != NULL), /* nt4 */
998  "CreateDIBitmap succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
999  else
1000  ok( hdib != NULL, "CreateDIBitmap failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1001  if (hdib) DeleteObject( hdib );
1002 
1003  /* RLE needs a size */
1004  bi->bmiHeader.biSizeImage = 0;
1005  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, format);
1006  if (expect_ok)
1007  ok( ret, "SetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1008  else
1009  ok( !ret ||
1010  broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */
1011  "SetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1012  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, format );
1013  if (expect_ok)
1014  ok( ret, "SetDIBitsToDevice failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1015  else
1016  ok( !ret ||
1017  broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */
1018  "SetDIBitsToDevice succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1019  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, format, SRCCOPY );
1020  if (expect_ok)
1021  ok( ret, "StretchDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1022  else
1023  ok( !ret ||
1024  broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */
1025  "StretchDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1026 
1027  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, format);
1028  if (expect_ok)
1029  ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1030  else
1031  ok( !ret, "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1032  ok( bi->bmiHeader.biBitCount == bpp, "GetDIBits modified bpp %u/%u\n",
1033  bpp, bi->bmiHeader.biBitCount );
1034 
1035  bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1036  bi->bmiHeader.biWidth = 2;
1037  bi->bmiHeader.biHeight = 2;
1038  bi->bmiHeader.biPlanes = planes;
1039  bi->bmiHeader.biBitCount = bpp;
1041  bi->bmiHeader.biSizeImage = 1;
1042  memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 );
1043  /* RLE allowed with valid biSizeImage */
1044  if ((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)) expect_ok = TRUE;
1045 
1046  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, format);
1047  if (expect_ok)
1048  ok( ret, "SetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1049  else
1050  ok( !ret, "SetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1051  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, format );
1052  if (expect_ok)
1053  ok( ret, "SetDIBitsToDevice failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1054  else
1055  ok( !ret, "SetDIBitsToDevice succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1056  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, format, SRCCOPY );
1057  if (expect_ok)
1058  ok( ret, "StretchDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1059  else
1060  ok( !ret, "StretchDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1061 
1062  bi->bmiHeader.biSizeImage = 0;
1063  ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, format);
1064  if (expect_ok || !bpp)
1065  ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format );
1066  else
1067  ok( !ret || broken(format_ok && !planes), /* nt4 */
1068  "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format );
1069  }
1070  }
1071  }
1072  }
1073 
1074  memset( bi, 0, sizeof(bi->bmiHeader) );
1075  bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1076  bi->bmiHeader.biWidth = 2;
1077  bi->bmiHeader.biHeight = 2;
1078  bi->bmiHeader.biPlanes = 1;
1079  bi->bmiHeader.biBitCount = 16;
1081  bi->bmiHeader.biSizeImage = 0;
1082  *(DWORD *)&bi->bmiColors[0] = 0;
1083  *(DWORD *)&bi->bmiColors[1] = 0;
1084  *(DWORD *)&bi->bmiColors[2] = 0;
1085 
1086  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1087  ok( hdib == NULL, "CreateDIBSection succeeded with null bitfields\n" );
1088  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1089  ok( !ret, "SetDIBits succeeded with null bitfields\n" );
1090  /* other functions don't check */
1091  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_RGB_COLORS );
1092  ok( hdib != NULL, "CreateDIBitmap failed with null bitfields\n" );
1093  DeleteObject( hdib );
1094  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS );
1095  ok( ret, "SetDIBitsToDevice failed with null bitfields\n" );
1096  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY );
1097  ok( ret, "StretchDIBits failed with null bitfields\n" );
1098  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS);
1099  ok( ret, "GetDIBits failed with null bitfields\n" );
1100  bi->bmiHeader.biPlanes = 1;
1101  bi->bmiHeader.biBitCount = 16;
1103  bi->bmiHeader.biSizeImage = 0;
1104  *(DWORD *)&bi->bmiColors[0] = 0;
1105  *(DWORD *)&bi->bmiColors[1] = 0;
1106  *(DWORD *)&bi->bmiColors[2] = 0;
1107  ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS);
1108  ok( ret, "GetDIBits failed with null bitfields\n" );
1109 
1110  /* all fields must be non-zero */
1111  *(DWORD *)&bi->bmiColors[0] = 3;
1112  *(DWORD *)&bi->bmiColors[1] = 0;
1113  *(DWORD *)&bi->bmiColors[2] = 7;
1114  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1115  ok( hdib == NULL, "CreateDIBSection succeeded with null bitfields\n" );
1116  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1117  ok( !ret, "SetDIBits succeeded with null bitfields\n" );
1118 
1119  /* garbage is ok though */
1120  *(DWORD *)&bi->bmiColors[0] = 0x55;
1121  *(DWORD *)&bi->bmiColors[1] = 0x44;
1122  *(DWORD *)&bi->bmiColors[2] = 0x33;
1123  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1124  ok( hdib != NULL, "CreateDIBSection failed with bad bitfields\n" );
1125  if (hdib) DeleteObject( hdib );
1126  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1127  ok( ret, "SetDIBits failed with bad bitfields\n" );
1128 
1129  bi->bmiHeader.biWidth = -2;
1130  bi->bmiHeader.biHeight = 2;
1131  bi->bmiHeader.biBitCount = 32;
1133  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1134  ok( hdib == NULL, "CreateDIBSection succeeded with negative width\n" );
1135  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_RGB_COLORS );
1136  ok( hdib == NULL, "CreateDIBitmap succeeded with negative width\n" );
1137  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1138  ok( !ret, "SetDIBits succeeded with negative width\n" );
1139  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS );
1140  ok( !ret, "SetDIBitsToDevice succeeded with negative width\n" );
1141  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY );
1142  ok( !ret, "StretchDIBits succeeded with negative width\n" );
1143  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS);
1144  ok( !ret, "GetDIBits succeeded with negative width\n" );
1145  bi->bmiHeader.biWidth = -2;
1146  bi->bmiHeader.biHeight = 2;
1147  bi->bmiHeader.biBitCount = 32;
1149  ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS);
1150  ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with negative width\n" );
1151 
1152  bi->bmiHeader.biWidth = 0;
1153  bi->bmiHeader.biHeight = 2;
1154  bi->bmiHeader.biBitCount = 32;
1156  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1157  ok( hdib == NULL, "CreateDIBSection succeeded with zero width\n" );
1158  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_RGB_COLORS );
1159  ok( hdib != NULL, "CreateDIBitmap failed with zero width\n" );
1160  DeleteObject( hdib );
1161  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1162  ok( !ret || broken(ret), /* nt4 */ "SetDIBits succeeded with zero width\n" );
1163  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS );
1164  ok( !ret || broken(ret), /* nt4 */ "SetDIBitsToDevice succeeded with zero width\n" );
1165  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY );
1166  ok( !ret || broken(ret), /* nt4 */ "StretchDIBits succeeded with zero width\n" );
1167  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS);
1168  ok( !ret, "GetDIBits succeeded with zero width\n" );
1169  bi->bmiHeader.biWidth = 0;
1170  bi->bmiHeader.biHeight = 2;
1171  bi->bmiHeader.biBitCount = 32;
1173  ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS);
1174  ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with zero width\n" );
1175 
1176  bi->bmiHeader.biWidth = 2;
1177  bi->bmiHeader.biHeight = 0;
1178  bi->bmiHeader.biBitCount = 32;
1180  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1181  ok( hdib == NULL, "CreateDIBSection succeeded with zero height\n" );
1182  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_RGB_COLORS );
1183  ok( hdib != NULL, "CreateDIBitmap failed with zero height\n" );
1184  DeleteObject( hdib );
1185  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS);
1186  ok( !ret, "SetDIBits succeeded with zero height\n" );
1187  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS );
1188  ok( !ret, "SetDIBitsToDevice succeeded with zero height\n" );
1189  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY );
1190  ok( !ret, "StretchDIBits succeeded with zero height\n" );
1191  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS);
1192  ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with zero height\n" );
1193  bi->bmiHeader.biWidth = 2;
1194  bi->bmiHeader.biHeight = 0;
1195  bi->bmiHeader.biBitCount = 32;
1197  ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS);
1198  ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with zero height\n" );
1199 
1200  /* some functions accept DIB_PAL_COLORS+1, but not beyond */
1201 
1202  bi->bmiHeader.biWidth = 2;
1203  bi->bmiHeader.biHeight = 2;
1204  bi->bmiHeader.biBitCount = 1;
1206  hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+1, &bits, NULL, 0);
1207  ok( hdib == NULL, "CreateDIBSection succeeded with DIB_PAL_COLORS+1\n" );
1208  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_PAL_COLORS+1 );
1209  ok( hdib != NULL, "CreateDIBitmap failed with DIB_PAL_COLORS+1\n" );
1210  DeleteObject( hdib );
1211  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_PAL_COLORS+1);
1212  ok( !ret, "SetDIBits succeeded with DIB_PAL_COLORS+1\n" );
1213  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_PAL_COLORS+1 );
1214  ok( ret, "SetDIBitsToDevice failed with DIB_PAL_COLORS+1\n" );
1215  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_PAL_COLORS+1, SRCCOPY );
1216  ok( ret, "StretchDIBits failed with DIB_PAL_COLORS+1\n" );
1217  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_PAL_COLORS+1);
1218  ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+1\n" );
1219  bi->bmiHeader.biWidth = 2;
1220  bi->bmiHeader.biHeight = 2;
1221  bi->bmiHeader.biBitCount = 1;
1223  ret = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS+1);
1224  ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+1\n" );
1225 
1226  bi->bmiHeader.biWidth = 2;
1227  bi->bmiHeader.biHeight = 2;
1228  bi->bmiHeader.biBitCount = 1;
1230  hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+2, &bits, NULL, 0);
1231  ok( hdib == NULL, "CreateDIBSection succeeded with DIB_PAL_COLORS+2\n" );
1232  hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_PAL_COLORS+2 );
1233  ok( hdib == NULL, "CreateDIBitmap succeeded with DIB_PAL_COLORS+2\n" );
1234  DeleteObject( hdib );
1235  ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_PAL_COLORS+2);
1236  ok( !ret, "SetDIBits succeeded with DIB_PAL_COLORS+2\n" );
1237  ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_PAL_COLORS+2 );
1238  ok( !ret, "SetDIBitsToDevice succeeded with DIB_PAL_COLORS+2\n" );
1239  ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_PAL_COLORS+2, SRCCOPY );
1240  ok( !ret, "StretchDIBits succeeded with DIB_PAL_COLORS+2\n" );
1241  ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_PAL_COLORS+2);
1242  ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+2\n" );
1243  bi->bmiHeader.biWidth = 2;
1244  bi->bmiHeader.biHeight = 2;
1245  bi->bmiHeader.biBitCount = 1;
1247  ret = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS+2);
1248  ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+2\n" );
1249 
1250  bi->bmiHeader.biWidth = 0x4000;
1251  bi->bmiHeader.biHeight = 0x4000;
1252  bi->bmiHeader.biBitCount = 1;
1254  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1255  ok( hdib != NULL, "CreateDIBSection failed with large size\n" );
1256  DeleteObject( hdib );
1257 
1258  bi->bmiHeader.biWidth = 0x8001;
1259  bi->bmiHeader.biHeight = 0x8001;
1260  bi->bmiHeader.biBitCount = 32;
1262  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1263  ok( hdib == NULL, "CreateDIBSection succeeded with size overflow\n" );
1264 
1265  bi->bmiHeader.biWidth = 1;
1266  bi->bmiHeader.biHeight = 0x40000001;
1267  bi->bmiHeader.biBitCount = 32;
1269  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1270  ok( hdib == NULL, "CreateDIBSection succeeded with size overflow\n" );
1271 
1272  bi->bmiHeader.biWidth = 2;
1273  bi->bmiHeader.biHeight = 0x40000001;
1274  bi->bmiHeader.biBitCount = 16;
1276  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1277  ok( hdib == NULL, "CreateDIBSection succeeded with size overflow\n" );
1278 
1279  bi->bmiHeader.biWidth = 0x40000001;
1280  bi->bmiHeader.biHeight = 1;
1281  bi->bmiHeader.biBitCount = 32;
1283  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1284  ok( hdib == NULL, "CreateDIBSection succeeded with size overflow\n" );
1285 
1286  bi->bmiHeader.biWidth = 0x40000001;
1287  bi->bmiHeader.biHeight = 4;
1288  bi->bmiHeader.biBitCount = 8;
1290  hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0);
1291  ok( hdib == NULL, "CreateDIBSection succeeded with size overflow\n" );
1292 
1293  DeleteDC( memdc );
1294  DeleteObject( hbmp );
1295  ReleaseDC( 0, hdc );
1296  HeapFree( GetProcessHeap(), 0, bi );
1297 }
#define TRUE
Definition: types.h:120
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define DIB_PAL_COLORS
Definition: wingdi.h:364
HDC WINAPI GetDC(_In_opt_ HWND)
INT WINAPI GetDIBits(HDC hDC, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uUsage)
Definition: bitmap.c:354
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
INT WINAPI SetDIBits(HDC hDC, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines, CONST VOID *lpvBits, CONST BITMAPINFO *lpbmi, UINT fuColorUse)
Definition: bitmap.c:562
#define BI_JPEG
Definition: wingdi.h:38
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int winetest_interactive
int WINAPI StretchDIBits(HDC hdc, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo, UINT iUsage, DWORD dwRop)
Definition: bitmap.c:758
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD DWORD
Definition: winlogon.h:75
#define FALSE
Definition: types.h:117
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD biCompression
Definition: amvideo.idl:35
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
HBITMAP WINAPI CreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:307
#define ok(value,...)
Definition: CComObject.cpp:34
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RGBQUAD bmiColors[1]
Definition: wingdi.h:1454
static int compr(const void *a, const void *b)
Definition: bidi.c:685
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HBITMAP WINAPI CreateDIBitmap(HDC hDC, const BITMAPINFOHEADER *Header, DWORD Init, LPCVOID Bits, const BITMAPINFO *Data, UINT ColorUse)
Definition: bitmap.c:398
DWORD biSizeImage
Definition: amvideo.idl:36
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI DeleteDC(_In_ HDC)
#define BI_PNG
Definition: wingdi.h:39
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define skip(...)
Definition: CString.cpp:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
static HDC
Definition: bitmap.c:44
unsigned int UINT
Definition: ndis.h:50
#define BI_RLE4
Definition: precomp.h:36
INT WINAPI SetDIBitsToDevice(HDC hdc, int XDest, int YDest, DWORD Width, DWORD Height, int XSrc, int YSrc, UINT StartScan, UINT ScanLines, CONST VOID *Bits, CONST BITMAPINFO *lpbmi, UINT ColorUse)
Definition: bitmap.c:646
DWORD bpp
Definition: surface.c:181
#define DIB_RGB_COLORS
Definition: wingdi.h:365
HBITMAP hbmp
Definition: msvc.h:60
#define BI_RLE8
Definition: wingdi.h:35
#define memset(x, y, z)
Definition: compat.h:39
#define BI_RGB
Definition: precomp.h:35
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SRCCOPY
Definition: wingdi.h:331
static void test_dib_info ( HBITMAP  hbm,
const void bits,
const BITMAPINFOHEADER bmih 
)
static

Definition at line 263 of file bitmap.c.

Referenced by test_dibsections().

264 {
265  BITMAP bm;
266  BITMAP bma[2];
267  DIBSECTION ds;
268  DIBSECTION dsa[2];
269  INT ret, bm_width_bytes, dib_width_bytes;
270  BYTE *buf;
271 
272  ret = GetObjectW(hbm, sizeof(bm), &bm);
273  ok(ret == sizeof(bm), "GetObject returned %d\n", ret);
274 
275  ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
276  ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth);
277  ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight);
278  dib_width_bytes = get_dib_stride(bm.bmWidth, bm.bmBitsPixel);
279  bm_width_bytes = get_bitmap_stride(bm.bmWidth, bm.bmBitsPixel);
280  if (bm.bmWidthBytes != dib_width_bytes) /* Win2k bug */
281  ok(bm.bmWidthBytes == bm_width_bytes, "wrong bm.bmWidthBytes %d != %d\n", bm.bmWidthBytes, bm_width_bytes);
282  else
283  ok(bm.bmWidthBytes == dib_width_bytes, "wrong bm.bmWidthBytes %d != %d\n", bm.bmWidthBytes, dib_width_bytes);
284  ok(bm.bmPlanes == bmih->biPlanes, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
285  ok(bm.bmBitsPixel == bmih->biBitCount, "bm.bmBitsPixel %d != %d\n", bm.bmBitsPixel, bmih->biBitCount);
286  ok(bm.bmBits == bits, "wrong bm.bmBits %p != %p\n", bm.bmBits, bits);
287 
288  buf = HeapAlloc(GetProcessHeap(), 0, bm.bmWidthBytes * bm.bmHeight + 4096);
289 
290  /* GetBitmapBits returns not 32-bit aligned data */
291  SetLastError(0xdeadbeef);
292  ret = GetBitmapBits(hbm, 0, NULL);
293  ok(ret == bm_width_bytes * bm.bmHeight,
294  "%d != %d\n", ret, bm_width_bytes * bm.bmHeight);
295 
296  memset(buf, 0xAA, bm.bmWidthBytes * bm.bmHeight + 4096);
297  ret = GetBitmapBits(hbm, bm.bmWidthBytes * bm.bmHeight + 4096, buf);
298  ok(ret == bm_width_bytes * bm.bmHeight, "%d != %d\n", ret, bm_width_bytes * bm.bmHeight);
299 
300  HeapFree(GetProcessHeap(), 0, buf);
301 
302  /* test various buffer sizes for GetObject */
303  memset(&ds, 0xAA, sizeof(ds));
304  ret = GetObjectW(hbm, sizeof(*bma) * 2, bma);
305  ok(ret == sizeof(*bma), "wrong size %d\n", ret);
306  ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth);
307  ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight);
308  ok(bm.bmBits == bits, "wrong bm.bmBits %p != %p\n", bm.bmBits, bits);
309 
310  ret = GetObjectW(hbm, sizeof(bm) / 2, &bm);
311  ok(ret == 0, "%d != 0\n", ret);
312 
313  ret = GetObjectW(hbm, 0, &bm);
314  ok(ret == 0, "%d != 0\n", ret);
315 
316  ret = GetObjectW(hbm, 1, &bm);
317  ok(ret == 0, "%d != 0\n", ret);
318 
319  /* test various buffer sizes for GetObject */
320  ret = GetObjectW(hbm, 0, NULL);
321  ok(ret == sizeof(bm), "wrong size %d\n", ret);
322 
323  ret = GetObjectW(hbm, sizeof(*dsa) * 2, dsa);
324  ok(ret == sizeof(*dsa), "wrong size %d\n", ret);
325 
326  memset(&ds, 0xAA, sizeof(ds));
327  ret = GetObjectW(hbm, sizeof(ds), &ds);
328  ok(ret == sizeof(ds), "wrong size %d\n", ret);
329 
330  ok(ds.dsBm.bmBits == bits, "wrong bm.bmBits %p != %p\n", ds.dsBm.bmBits, bits);
331  if (ds.dsBm.bmWidthBytes != bm_width_bytes) /* Win2k bug */
332  ok(ds.dsBmih.biSizeImage == ds.dsBm.bmWidthBytes * ds.dsBm.bmHeight, "%u != %u\n",
333  ds.dsBmih.biSizeImage, ds.dsBm.bmWidthBytes * ds.dsBm.bmHeight);
334  ok(bmih->biSizeImage == 0, "%u != 0\n", bmih->biSizeImage);
335  ds.dsBmih.biSizeImage = 0;
336 
337  ok(ds.dsBmih.biSize == bmih->biSize, "%u != %u\n", ds.dsBmih.biSize, bmih->biSize);
338  ok(ds.dsBmih.biWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth);
339  ok(ds.dsBmih.biHeight == abs(bmih->biHeight), "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight));
340  ok(ds.dsBmih.biPlanes == bmih->biPlanes, "%u != %u\n", ds.dsBmih.biPlanes, bmih->biPlanes);
341  ok(ds.dsBmih.biBitCount == bmih->biBitCount, "%u != %u\n", ds.dsBmih.biBitCount, bmih->biBitCount);
342  ok(ds.dsBmih.biCompression == bmih->biCompression ||
343  ((bmih->biBitCount == 32) && broken(ds.dsBmih.biCompression == BI_BITFIELDS)), /* nt4 sp1 and 2 */
344  "%u != %u\n", ds.dsBmih.biCompression, bmih->biCompression);
345  ok(ds.dsBmih.biSizeImage == bmih->biSizeImage, "%u != %u\n", ds.dsBmih.biSizeImage, bmih->biSizeImage);
346  ok(ds.dsBmih.biXPelsPerMeter == bmih->biXPelsPerMeter, "%d != %d\n", ds.dsBmih.biXPelsPerMeter, bmih->biXPelsPerMeter);
347  ok(ds.dsBmih.biYPelsPerMeter == bmih->biYPelsPerMeter, "%d != %d\n", ds.dsBmih.biYPelsPerMeter, bmih->biYPelsPerMeter);
348 
349  memset(&ds, 0xAA, sizeof(ds));
350  ret = GetObjectW(hbm, sizeof(ds) - 4, &ds);
351  ok(ret == sizeof(ds.dsBm), "wrong size %d\n", ret);
352  ok(ds.dsBm.bmWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth);
353  ok(ds.dsBm.bmHeight == abs(bmih->biHeight), "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight));
354  ok(ds.dsBm.bmBits == bits, "%p != %p\n", ds.dsBm.bmBits, bits);
355 
356  ret = GetObjectW(hbm, 0, &ds);
357  ok(ret == 0, "%d != 0\n", ret);
358 
359  ret = GetObjectW(hbm, 1, &ds);
360  ok(ret == 0, "%d != 0\n", ret);
361 }
#define abs(i)
Definition: fconv.c:206
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1647
static int get_dib_stride(int width, int bpp)
Definition: bitmap.c:53
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
LONG biXPelsPerMeter
Definition: amvideo.idl:37
#define ds
Definition: i386-dis.c:434
LONG biYPelsPerMeter
Definition: amvideo.idl:38
int32_t INT
Definition: typedefs.h:56
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
static int get_bitmap_stride(int width, int bpp)
Definition: bitmap.c:48
#define ok(value,...)
Definition: CComObject.cpp:34
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
DWORD biSizeImage
Definition: amvideo.idl:36
#define SetLastError(x)
Definition: compat.h:409
int ret
#define broken(x)
Definition: _sntprintf.h:21
unsigned char BYTE
Definition: ntddk_ex.h:96
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331
BITMAP dsBm
Definition: wingdi.h:1646
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394
static void test_dibsections ( void  )
static

Definition at line 435 of file bitmap.c.

Referenced by START_TEST().

436 {
437  HDC hdc, hdcmem, hdcmem2;
438  HBITMAP hdib, oldbm, hdib2, oldbm2;
439  char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
440  char bcibuf[sizeof(BITMAPCOREINFO) + 256 * sizeof(RGBTRIPLE)];
441  BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
442  BITMAPCOREINFO *pbci = (BITMAPCOREINFO *)bcibuf;
443  RGBQUAD *colors = pbmi->bmiColors;
444  RGBTRIPLE *ccolors = pbci->bmciColors;
445  HBITMAP hcoredib;
446  char coreBits[256];
447  BYTE *bits;
448  RGBQUAD rgb[256];
449  int ret;
450  char logpalbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
451  LOGPALETTE *plogpal = (LOGPALETTE*)logpalbuf;
452  PALETTEENTRY *palent = plogpal->palPalEntry;
453  WORD *index;
454  DWORD *bits32;
455  HPALETTE hpal, oldpal;
456  DIBSECTION dibsec;
457  COLORREF c0, c1;
458  int i;
460 
461  hdc = GetDC(0);
462 
463  memset(pbmi, 0, sizeof(bmibuf));
464  pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
465  pbmi->bmiHeader.biHeight = 100;
466  pbmi->bmiHeader.biWidth = 512;
467  pbmi->bmiHeader.biBitCount = 24;
468  pbmi->bmiHeader.biPlanes = 1;
470 
471  SetLastError(0xdeadbeef);
472 
473  /* invalid pointer for BITMAPINFO
474  (*bits should be NULL on error) */
475  bits = (BYTE*)0xdeadbeef;
476  hdib = CreateDIBSection(hdc, NULL, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
477  ok(hdib == NULL && bits == NULL, "CreateDIBSection failed for invalid parameter: bmi == 0x0\n");
478 
479  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
480  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
481  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIBSection\n");
482  ok(dibsec.dsBm.bmBits == bits, "dibsec.dsBits %p != bits %p\n", dibsec.dsBm.bmBits, bits);
483 
484  /* test the DIB memory */
485  ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
486  "VirtualQuery failed\n");
487  ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
488  ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
489  ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
490  ok(info.RegionSize == 0x26000, "0x%lx != 0x26000\n", info.RegionSize);
491  ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
492  ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
493  ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
494 
495  test_dib_bits_access( hdib, bits );
496 
497  test_dib_info(hdib, bits, &pbmi->bmiHeader);
498  DeleteObject(hdib);
499 
500  /* Test a top-down DIB. */
501  pbmi->bmiHeader.biHeight = -100;
502  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
503  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
504  test_dib_info(hdib, bits, &pbmi->bmiHeader);
505  DeleteObject(hdib);
506 
507  pbmi->bmiHeader.biHeight = 100;
508  pbmi->bmiHeader.biBitCount = 8;
510  SetLastError(0xdeadbeef);
511  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
512  ok(hdib == NULL, "CreateDIBSection should fail when asked to create a compressed DIB section\n");
513  ok(GetLastError() == 0xdeadbeef, "wrong error %d\n", GetLastError());
514 
515  pbmi->bmiHeader.biBitCount = 16;
517  ((PDWORD)pbmi->bmiColors)[0] = 0xf800;
518  ((PDWORD)pbmi->bmiColors)[1] = 0x07e0;
519  ((PDWORD)pbmi->bmiColors)[2] = 0x001f;
520  SetLastError(0xdeadbeef);
521  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
522  ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
523 
524  /* test the DIB memory */
525  ok(VirtualQuery(bits, &info, sizeof(info)) == sizeof(info),
526  "VirtualQuery failed\n");
527  ok(info.BaseAddress == bits, "%p != %p\n", info.BaseAddress, bits);
528  ok(info.AllocationBase == bits, "%p != %p\n", info.AllocationBase, bits);
529  ok(info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect);
530  ok(info.RegionSize == 0x19000, "0x%lx != 0x19000\n", info.RegionSize);
531  ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
532  ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
533  ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
534 
535  test_dib_info(hdib, bits, &pbmi->bmiHeader);
536  DeleteObject(hdib);
537 
538  memset(pbmi, 0, sizeof(bmibuf));
539  pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader);
540  pbmi->bmiHeader.biHeight = 16;
541  pbmi->bmiHeader.biWidth = 16;
542  pbmi->bmiHeader.biBitCount = 1;
543  pbmi->bmiHeader.biPlanes = 1;
545  colors[0].rgbRed = 0xff;
546  colors[0].rgbGreen = 0;
547  colors[0].rgbBlue = 0;
548  colors[1].rgbRed = 0;
549  colors[1].rgbGreen = 0;
550  colors[1].rgbBlue = 0xff;
551 
552  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
553  ok(hdib != NULL, "CreateDIBSection failed\n");
554  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIBSection\n");
555  ok(dibsec.dsBmih.biClrUsed == 2,
556  "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 2);
557 
558  /* Test if the old BITMAPCOREINFO structure is supported */
559 
560  pbci->bmciHeader.bcSize = sizeof(BITMAPCOREHEADER);
561  pbci->bmciHeader.bcBitCount = 0;
562 
563  ret = GetDIBits(hdc, hdib, 0, 16, NULL, (BITMAPINFO*) pbci, DIB_RGB_COLORS);
564  ok(ret, "GetDIBits doesn't work with a BITMAPCOREHEADER\n");
565  ok((pbci->bmciHeader.bcWidth == 16) && (pbci->bmciHeader.bcHeight == 16)
566  && (pbci->bmciHeader.bcBitCount == 1) && (pbci->bmciHeader.bcPlanes == 1),
567  "GetDIBits didn't fill in the BITMAPCOREHEADER structure properly\n");
568 
569  ret = GetDIBits(hdc, hdib, 0, 16, &coreBits, (BITMAPINFO*) pbci, DIB_RGB_COLORS);
570  ok(ret, "GetDIBits doesn't work with a BITMAPCOREHEADER\n");
571  ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) &&
572  (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) &&
573  (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff),
574  "The color table has not been translated to the old BITMAPCOREINFO format\n");
575 
576  hcoredib = CreateDIBSection(hdc, (BITMAPINFO*) pbci, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
577  ok(hcoredib != NULL, "CreateDIBSection failed with a BITMAPCOREINFO\n");
578 
579  ZeroMemory(ccolors, 256 * sizeof(RGBTRIPLE));
580  ret = GetDIBits(hdc, hcoredib, 0, 16, &coreBits, (BITMAPINFO*) pbci, DIB_RGB_COLORS);
581  ok(ret, "GetDIBits doesn't work with a BITMAPCOREHEADER\n");
582  ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) &&
583  (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) &&
584  (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff),
585  "The color table has not been translated to the old BITMAPCOREINFO format\n");
586 
587  DeleteObject(hcoredib);
588 
589  hdcmem = CreateCompatibleDC(hdc);
590  oldbm = SelectObject(hdcmem, hdib);
591 
592  ret = GetDIBColorTable(hdcmem, 0, 2, rgb);
593  ok(ret == 2, "GetDIBColorTable returned %d\n", ret);
594  ok(!memcmp(rgb, pbmi->bmiColors, 2 * sizeof(RGBQUAD)),
595  "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
596  rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved,
597  rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved);
598 
599  c0 = RGB(colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue);
600  c1 = RGB(colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue);
601 
602  test_color(hdcmem, DIBINDEX(0), c0);
603  test_color(hdcmem, DIBINDEX(1), c1);
604  test_color(hdcmem, DIBINDEX(2), c0);
605  test_color(hdcmem, PALETTEINDEX(0), c0);
606  test_color(hdcmem, PALETTEINDEX(1), c0);
607  test_color(hdcmem, PALETTEINDEX(2), c0);
608  test_color(hdcmem, PALETTERGB(colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue), c0);
609  test_color(hdcmem, PALETTERGB(colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue), c1);
610  test_color(hdcmem, PALETTERGB(0, 0, 0), c0);
611  test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0);
612  test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1);
613 
614  SelectObject(hdcmem, oldbm);
615  DeleteObject(hdib);
616 
617  colors[0].rgbRed = 0xff;
618  colors[0].rgbGreen = 0xff;
619  colors[0].rgbBlue = 0xff;
620  colors[1].rgbRed = 0;
621  colors[1].rgbGreen = 0;
622  colors[1].rgbBlue = 0;
623 
624  hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
625  ok(hdib != NULL, "CreateDIBSection failed\n");
626 
627  test_dib_info(hdib, bits, &pbmi->bmiHeader);
628 
629  oldbm = SelectObject(hdcmem, hdib);
630 
631  ret = GetDIBColorTable(hdcmem, 0, 2, rgb);
632  ok(ret == 2, "GetDIBColorTable returned %d\n", ret);
633  ok(!memcmp(rgb, colors, 2 * sizeof(RGBQUAD)),
634  "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
635  rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved,
636  rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved);
637 
638  SelectObject(hdcmem, oldbm);
639  test_dib_info(hdib, bits, &pbmi->bmiHeader);
640  DeleteObject(hdib);
641 
642  pbmi->bmiHeader.biBitCount = 4;
643  for (i = 0; i < 16; i++) {
644  colors[i].rgbRed = i;
645  colors[i].rgbGreen = 16-i;
646  colors[i].rgbBlue = 0;
647  }
648  hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
649  ok(hdib != NULL, "CreateDIBSection failed\n");
650  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
651  ok(dibsec.dsBmih.biClrUsed == 16,
652  "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 16);
653  test_dib_info(hdib, bits, &pbmi->bmiHeader);
654  DeleteObject(hdib);
655 
656  pbmi->bmiHeader.biBitCount = 8;
657 
658  for (i = 0; i < 128; i++) {
659  colors[i].rgbRed = 255 - i * 2;
660  colors[i].rgbGreen = i * 2;
661  colors[i].rgbBlue = 0;
662  colors[255 - i].rgbRed = 0;
663  colors[255 - i].rgbGreen = i * 2;
664  colors[255 - i].rgbBlue = 255 - i * 2;
665  }
666  hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
667  ok(hdib != NULL, "CreateDIBSection failed\n");
668  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
669  ok(dibsec.dsBmih.biClrUsed == 256,
670  "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
671 
672  oldbm = SelectObject(hdcmem, hdib);
673 
674  for (i = 0; i < 256; i++) {
675  test_color(hdcmem, DIBINDEX(i), RGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue));
676  test_color(hdcmem, PALETTERGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue),
677  RGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue));
678  }
679 
680  SelectObject(hdcmem, oldbm);
681  test_dib_info(hdib, bits, &pbmi->bmiHeader);
682  DeleteObject(hdib);
683 
684  pbmi->bmiHeader.biBitCount = 1;
685 
686  /* Now create a palette and a palette indexed dib section */
687  memset(plogpal, 0, sizeof(logpalbuf));
688  plogpal->palVersion = 0x300;
689  plogpal->palNumEntries = 2;
690  palent[0].peRed = 0xff;
691  palent[0].peBlue = 0xff;
692  palent[1].peGreen = 0xff;
693 
694  index = (WORD*)pbmi->bmiColors;
695  *index++ = 0;
696  *index = 1;
697  hpal = CreatePalette(plogpal);
698  ok(hpal != NULL, "CreatePalette failed\n");
699  oldpal = SelectPalette(hdc, hpal, TRUE);
700  hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
701  ok(hdib != NULL, "CreateDIBSection failed\n");
702  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
703  ok(dibsec.dsBmih.biClrUsed == 2, "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 2);
704 
705  /* The colour table has already been grabbed from the dc, so we select back the
706  old palette */
707 
708  SelectPalette(hdc, oldpal, TRUE);
709  oldbm = SelectObject(hdcmem, hdib);
710  oldpal = SelectPalette(hdcmem, hpal, TRUE);
711 
712  ret = GetDIBColorTable(hdcmem, 0, 2, rgb);
713  ok(ret == 2, "GetDIBColorTable returned %d\n", ret);
714  ok(rgb[0].rgbRed == 0xff && rgb[0].rgbBlue == 0xff && rgb[0].rgbGreen == 0 &&
715  rgb[1].rgbRed == 0 && rgb[1].rgbBlue == 0 && rgb[1].rgbGreen == 0xff,
716  "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n",
717  rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved,
718  rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved);
719 
720  c0 = RGB(palent[0].peRed, palent[0].peGreen, palent[0].peBlue);
721  c1 = RGB(palent[1].peRed, palent[1].peGreen, palent[1].peBlue);
722 
723  test_color(hdcmem, DIBINDEX(0), c0);
724  test_color(hdcmem, DIBINDEX(1), c1);
725  test_color(hdcmem, DIBINDEX(2), c0);
726  test_color(hdcmem, PALETTEINDEX(0), c0);
727  test_color(hdcmem, PALETTEINDEX(1), c1);
728  test_color(hdcmem, PALETTEINDEX(2), c0);
729  test_color(hdcmem, PALETTERGB(palent[0].peRed, palent[0].peGreen, palent[0].peBlue), c0);
730  test_color(hdcmem, PALETTERGB(palent[1].peRed, palent[1].peGreen, palent[1].peBlue), c1);
731  test_color(hdcmem, PALETTERGB(0, 0, 0), c1);
732  test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0);
733  test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0);
734  test_color(hdcmem, PALETTERGB(0, 1, 0), c1);
735  test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1);
736  test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0);
737 
738  /* Bottom and 2nd row from top green, everything else magenta */
739  bits[0] = bits[1] = 0xff;
740  bits[13 * 4] = bits[13*4 + 1] = 0xff;
741 
742  test_dib_info(hdib, bits, &pbmi->bmiHeader);
743 
744  pbmi->bmiHeader.biBitCount = 32;
745 
746  hdib2 = CreateDIBSection(NULL, pbmi, DIB_RGB_COLORS, (void **)&bits32, NULL, 0);
747  ok(hdib2 != NULL, "CreateDIBSection failed\n");
748  hdcmem2 = CreateCompatibleDC(hdc);
749  oldbm2 = SelectObject(hdcmem2, hdib2);
750 
751  BitBlt(hdcmem2, 0, 0, 16,16, hdcmem, 0, 0, SRCCOPY);
752 
753  ok(bits32[0] == 0xff00, "lower left pixel is %08x\n", bits32[0]);
754  ok(bits32[17] == 0xff00ff, "bottom but one, left pixel is %08x\n", bits32[17]);
755 
756  SelectObject(hdcmem2, oldbm2);
757  test_dib_info(hdib2, bits32, &pbmi->bmiHeader);
758  DeleteObject(hdib2);
759 
760  SelectObject(hdcmem, oldbm);
761  SelectPalette(hdcmem, oldpal, TRUE);
762  DeleteObject(hdib);
763  DeleteObject(hpal);
764 
765 
766  pbmi->bmiHeader.biBitCount = 8;
767 
768  memset(plogpal, 0, sizeof(logpalbuf));
769  plogpal->palVersion = 0x300;
770  plogpal->palNumEntries = 256;
771 
772  for (i = 0; i < 128; i++) {
773  palent[i].peRed = 255 - i * 2;
774  palent[i].peBlue = i * 2;
775  palent[i].peGreen = 0;
776  palent[255 - i].peRed = 0;
777  palent[255 - i].peGreen = i * 2;
778  palent[255 - i].peBlue = 255 - i * 2;
779  }
780 
781  index = (WORD*)pbmi->bmiColors;
782  for (i = 0; i < 256; i++) {
783  *index++ = i;
784  }
785 
786  hpal = CreatePalette(plogpal);
787  ok(hpal != NULL, "CreatePalette failed\n");
788  oldpal = SelectPalette(hdc, hpal, TRUE);
789  hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
790  ok(hdib != NULL, "CreateDIBSection failed\n");
791  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
792  ok(dibsec.dsBmih.biClrUsed == 256, "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
793 
794  test_dib_info(hdib, bits, &pbmi->bmiHeader);
795 
796  SelectPalette(hdc, oldpal, TRUE);
797  oldbm = SelectObject(hdcmem, hdib);
798  oldpal = SelectPalette(hdcmem, hpal, TRUE);
799 
800  ret = GetDIBColorTable(hdcmem, 0, 256, rgb);
801  ok(ret == 256, "GetDIBColorTable returned %d\n", ret);
802  for (i = 0; i < 256; i++) {
803  ok(rgb[i].rgbRed == palent[i].peRed &&
804  rgb[i].rgbBlue == palent[i].peBlue &&
805  rgb[i].rgbGreen == palent[i].peGreen,
806  "GetDIBColorTable returns table %d: r%02x g%02x b%02x res%02x\n",
807  i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved);
808  }
809 
810  for (i = 0; i < 256; i++) {
811  test_color(hdcmem, DIBINDEX(i), RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue));
812  test_color(hdcmem, PALETTEINDEX(i), RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue));
813  test_color(hdcmem, PALETTERGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue),
814  RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue));
815  }
816 
817  SelectPalette(hdcmem, oldpal, TRUE);
818  SelectObject(hdcmem, oldbm);
819  DeleteObject(hdib);
820  DeleteObject(hpal);
821 
822  plogpal->palNumEntries = 37;
823  hpal = CreatePalette(plogpal);
824  ok(hpal != NULL, "CreatePalette failed\n");
825  oldpal = SelectPalette(hdc, hpal, TRUE);
826  pbmi->bmiHeader.biClrUsed = 142;
827  hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
828  ok(hdib != NULL, "CreateDIBSection failed\n");
829  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
830  ok(dibsec.dsBmih.biClrUsed == 256, "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
831 
832  test_dib_info(hdib, bits, &pbmi->bmiHeader);
833 
834  SelectPalette(hdc, oldpal, TRUE);
835  oldbm = SelectObject(hdcmem, hdib);
836 
837  memset( rgb, 0xcc, sizeof(rgb) );
838  ret = GetDIBColorTable(hdcmem, 0, 256, rgb);
839  ok(ret == 256, "GetDIBColorTable returned %d\n", ret);
840  for (i = 0; i < 256; i++)
841  {
842  if (i < pbmi->bmiHeader.biClrUsed)
843  {
844  ok(rgb[i].rgbRed == palent[i % 37].peRed &&
845  rgb[i].rgbBlue == palent[i % 37].peBlue &&
846  rgb[i].rgbGreen == palent[i % 37].peGreen,
847  "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n",
848  i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved);
849  test_color(hdcmem, DIBINDEX(i),
850  RGB(palent[i % 37].peRed, palent[i % 37].peGreen, palent[i % 37].peBlue));
851  }
852  else
853  {
854  ok(rgb[i].rgbRed == 0 && rgb[i].rgbBlue == 0 && rgb[i].rgbGreen == 0,
855  "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n",
856  i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved);
857  test_color(hdcmem, DIBINDEX(i), 0 );
858  }
859  }
860  pbmi->bmiHeader.biClrUsed = 173;
861  memset( pbmi->bmiColors, 0xcc, 256 * sizeof(RGBQUAD) );
862  GetDIBits( hdc, hdib, 0, 1, NULL, pbmi, DIB_RGB_COLORS );
863  ok( pbmi->bmiHeader.biClrUsed == 0, "wrong colors %u\n", pbmi->bmiHeader.biClrUsed );
864  for (i = 0; i < 256; i++)
865  {
866  if (i < 142)
867  ok(colors[i].rgbRed == palent[i % 37].peRed &&
868  colors[i].rgbBlue == palent[i % 37].peBlue &&
869  colors[i].rgbGreen == palent[i % 37].peGreen,
870  "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n",
871  i, colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved);
872  else
873  ok(colors[i].rgbRed == 0 && colors[i].rgbBlue == 0 && colors[i].rgbGreen == 0,
874  "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n",
875  i, colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved);
876  }
877 
878  rgb[0].rgbRed = 1;
879  rgb[0].rgbGreen = 2;
880  rgb[0].rgbBlue = 3;
881  rgb[0].rgbReserved = 123;
882  ret = SetDIBColorTable( hdcmem, 0, 1, rgb );
883  ok( ret == 1, "SetDIBColorTable returned unexpected result %u\n", ret );
884  ok( rgb[0].rgbReserved == 123, "Expected rgbReserved = 123, got %u\n", rgb[0].rgbReserved );
885 
886  rgb[0].rgbRed = rgb[0].rgbGreen = rgb[0].rgbBlue = rgb[0].rgbReserved = -1;
887  ret = GetDIBColorTable( hdcmem, 0, 1, rgb );
888  ok( ret == 1, "GetDIBColorTable returned unexpected result %u\n", ret );
889  ok( rgb[0].rgbRed == 1, "Expected rgbRed = 1, got %u\n", rgb[0].rgbRed );
890  ok( rgb[0].rgbGreen == 2, "Expected rgbGreen = 2, got %u\n", rgb[0].rgbGreen );
891  ok( rgb[0].rgbBlue == 3, "Expected rgbBlue = 3, got %u\n", rgb[0].rgbBlue );
892  ok( rgb[0].rgbReserved == 0, "Expected rgbReserved = 0, got %u\n", rgb[0].rgbReserved );
893 
894  SelectObject(hdcmem, oldbm);
895  DeleteObject(hdib);
896  DeleteObject(hpal);
897 
898  /* ClrUsed ignored on > 8bpp */
899  pbmi->bmiHeader.biBitCount = 16;
900  pbmi->bmiHeader.biClrUsed = 37;
901  hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
902  ok(hdib != NULL, "CreateDIBSection failed\n");
903  ok(GetObjectW(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
904  ok(dibsec.dsBmih.biClrUsed == 0, "created DIBSection: wrong biClrUsed field: %u\n", dibsec.dsBmih.biClrUsed);
905  oldbm = SelectObject(hdcmem, hdib);
906  ret = GetDIBColorTable(hdcmem, 0, 256, rgb);
907  ok(ret == 0, "GetDIBColorTable returned %d\n", ret);
908  SelectObject(hdcmem, oldbm);
909  DeleteObject(hdib);
910 
911  DeleteDC(hdcmem);
912  DeleteDC(hdcmem2);
913  ReleaseDC(0, hdc);
914 }
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1647
unsigned short WORD
Definition: ntddk_ex.h:93
#define TRUE
Definition: types.h:120
#define HBITMAP
Definition: msvc.h:28
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER *bmih)
Definition: bitmap.c:263
#define DIB_PAL_COLORS
Definition: wingdi.h:364
HDC WINAPI GetDC(_In_opt_ HWND)
INT WINAPI GetDIBits(HDC hDC, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uUsage)
Definition: bitmap.c:354
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define test_color(hdc, color, exp)
Definition: bitmap.c:373
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define MEM_COMMIT
Definition: nt_native.h:1313
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD DWORD
Definition: winlogon.h:75
UCHAR rgbBlue
Definition: inbv.c:118
UCHAR rgbGreen
Definition: inbv.c:119
WORD palVersion
Definition: wingdi.h:1810
UCHAR rgbRed
Definition: inbv.c:120
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1430
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define DIBINDEX(n)
Definition: mmsystem.h:932
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD biCompression
Definition: amvideo.idl:35
HDC hdc
Definition: msvc.h:53
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
RGBTRIPLE bmciColors[1]
Definition: wingdi.h:1431
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
#define ok(value,...)
Definition: CComObject.cpp:34
#define MEM_PRIVATE
Definition: nt_native.h:1318
RGBQUAD bmiColors[1]
Definition: wingdi.h:1454
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
#define RGB(r, g, b)
Definition: wingdi.h:2917
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define for
Definition: utility.h:88
SIZE_T NTAPI VirtualQuery(IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:220
#define SetLastError(x)
Definition: compat.h:409
int ret
#define index(s, c)
Definition: various.h:29
struct _BITMAPCOREINFO BITMAPCOREINFO
unsigned char BYTE
Definition: ntddk_ex.h:96
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
const XML_Char XML_Encoding * info
Definition: expat.h:530
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3520
BOOL WINAPI DeleteDC(_In_ HDC)
#define PALETTERGB(r, g, b)
Definition: wingdi.h:2919
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
static HDC
Definition: bitmap.c:44
struct tagLOGPALETTE LOGPALETTE
BITMAP dsBm
Definition: wingdi.h:1646
DWORD * PDWORD
Definition: pedump.c:68
WORD palNumEntries
Definition: wingdi.h:1811
UCHAR rgbReserved
Definition: inbv.c:121
#define DIB_RGB_COLORS
Definition: wingdi.h:365
static void test_dib_bits_access(HBITMAP hdib, void *bits)
Definition: bitmap.c:376
DWORD COLORREF
Definition: windef.h:290