ReactOS  0.4.15-dev-5112-g22d8c0f
vbltest.c File Reference
#include <windows.h>
#include <tchar.h>
Include dependency graph for vbltest.c:

Go to the source code of this file.

Macros

#define CURRENT_BMPS   4
 
#define CURRENT_ICONS   1
 
#define SCALE   1.5
 
#define OFFSET   5
 

Functions

BOOL WINAPI GdiAlphaBlend (HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, BLENDFUNCTION blendFunction)
 
BOOL WINAPI GdiTransparentBlt (HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
 
static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static ATOM MyRegisterClass (HINSTANCE hInstance)
 
static BOOL InitInstance (HINSTANCE hInstance, int nCmdShow)
 
int WINAPI _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
 

Variables

HINSTANCE hInst
 
TCHAR szWindowClass [] = _T("testclass")
 

Macro Definition Documentation

◆ CURRENT_BMPS

#define CURRENT_BMPS   4

Definition at line 21 of file vbltest.c.

◆ CURRENT_ICONS

#define CURRENT_ICONS   1

Definition at line 22 of file vbltest.c.

◆ OFFSET

#define OFFSET   5

Definition at line 24 of file vbltest.c.

◆ SCALE

#define SCALE   1.5

Definition at line 23 of file vbltest.c.

Function Documentation

◆ _tWinMain()

int WINAPI _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPTSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 198 of file vbltest.c.

202 {
203  MSG msg;
204 
206 
207  if (!InitInstance(hInstance, nCmdShow))
208  {
209  return FALSE;
210  }
211 
212  while (GetMessage(&msg, NULL, 0, 0))
213  {
216  }
217 
218  return (int)msg.wParam;
219 }
#define DispatchMessage
Definition: winuser.h:5755
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: vbltest.c:166
static ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: vbltest.c:143
#define NULL
Definition: types.h:112
#define GetMessage
Definition: winuser.h:5780
#define msg(x)
Definition: auth_time.c:54

◆ GdiAlphaBlend()

BOOL WINAPI GdiAlphaBlend ( HDC  hdcDst,
int  xDst,
int  yDst,
int  wDst,
int  hDst,
HDC  hdcSrc,
int  xSrc,
int  ySrc,
int  wSrc,
int  hSrc,
BLENDFUNCTION  blendFunction 
)

Referenced by WndProc().

◆ GdiTransparentBlt()

BOOL WINAPI GdiTransparentBlt ( HDC  hdcDst,
int  xDst,
int  yDst,
int  wDst,
int  hDst,
HDC  hdcSrc,
int  xSrc,
int  ySrc,
int  wSrc,
int  hSrc,
UINT  crTransparent 
)

Referenced by DrawBackgroundPreview(), and WndProc().

◆ InitInstance()

static BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)
static

Definition at line 166 of file vbltest.c.

167 {
168  HWND hWnd;
169 
170  hInst = hInstance;
171 
172  hWnd = CreateWindowEx(0,
174  _T("Various blit and blend operations"),
178  640,
179  640,
180  NULL,
181  NULL,
182  hInstance,
183  NULL);
184 
185  if (!hWnd)
186  {
187  return FALSE;
188  }
189 
190  ShowWindow(hWnd, nCmdShow);
192 
193  return TRUE;
194 }
TCHAR szWindowClass[]
Definition: vbltest.c:27
#define TRUE
Definition: types.h:120
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
#define CreateWindowEx
Definition: winuser.h:5745
#define CW_USEDEFAULT
Definition: winuser.h:225
#define _T(x)
Definition: vfdio.h:22
HINSTANCE hInst
Definition: vbltest.c:26
#define NULL
Definition: types.h:112
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

Referenced by _tWinMain().

◆ MyRegisterClass()

static ATOM MyRegisterClass ( HINSTANCE  hInstance)
static

Definition at line 143 of file vbltest.c.

144 {
145  WNDCLASSEX wcex;
146 
147  wcex.cbSize = sizeof(WNDCLASSEX);
148 
149  wcex.style = CS_HREDRAW | CS_VREDRAW;
150  wcex.lpfnWndProc = WndProc;
151  wcex.cbClsExtra = 0;
152  wcex.cbWndExtra = 0;
153  wcex.hInstance = hInstance;
154  wcex.hIcon = NULL;
155  wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
156  wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
157  wcex.lpszMenuName = NULL;
159  wcex.hIconSm = NULL;
160 
161  return RegisterClassEx(&wcex);
162 }
TCHAR szWindowClass[]
Definition: vbltest.c:27
UINT style
Definition: winuser.h:3192
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: vbltest.c:30
LPCSTR lpszMenuName
Definition: winuser.h:3200
#define RegisterClassEx
Definition: winuser.h:5827
HCURSOR hCursor
Definition: winuser.h:3198
WNDPROC lpfnWndProc
Definition: winuser.h:3193
LPCSTR lpszClassName
Definition: winuser.h:3201
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3202
#define COLOR_WINDOW
Definition: winuser.h:912
HINSTANCE hInstance
Definition: charmap.c:20
HINSTANCE hInstance
Definition: winuser.h:3196
UINT cbSize
Definition: winuser.h:3191
HBRUSH hbrBackground
Definition: winuser.h:3199
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3195
HICON hIcon
Definition: winuser.h:3197
#define LoadCursor
Definition: winuser.h:5802
int cbClsExtra
Definition: winuser.h:3194
#define NULL
Definition: types.h:112
#define IDC_ARROW
Definition: winuser.h:682
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5709

Referenced by _tWinMain().

◆ WndProc()

static LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 30 of file vbltest.c.

31 {
32  static HBITMAP hbmList[CURRENT_BMPS];
33  static HICON hicList[CURRENT_ICONS];
34 
35  switch (message)
36  {
37  case WM_CREATE:
38  {
42  hbmList[3] = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(2400), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
43  hicList[0] = (HICON)LoadIcon(hInst, MAKEINTRESOURCE(3200));
44  break;
45  }
46 
47  case WM_PAINT:
48  {
49  PAINTSTRUCT ps;
50  HDC hdc, hdcMem;
51  BITMAP bitmap;
52  BLENDFUNCTION bfunc;
53  int x = 0, y = 0, i;
54  hdc = BeginPaint(hWnd, &ps);
56 
57  bfunc.AlphaFormat = AC_SRC_ALPHA;
58  bfunc.BlendFlags = 0;
59  bfunc.BlendOp = AC_SRC_OVER;
60  bfunc.SourceConstantAlpha = 128;
61 
62  /* bitmaps */
63  for(i = 0; i < CURRENT_BMPS; i++)
64  {
65  y = 0;
66  SelectObject(hdcMem, hbmList[i]);
67  GetObject(hbmList[i], sizeof(BITMAP), &bitmap);
68 
69  /* bit blt */
70  BitBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
71  y += bitmap.bmHeight + OFFSET;
72 
73  /* stretch blt, org size */
74  StretchBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
75  y += bitmap.bmHeight + OFFSET;
76 
77  /* stretch blt, scaled */
78  StretchBlt(hdc, x, y, bitmap.bmWidth*SCALE, bitmap.bmHeight*SCALE, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
79  y += bitmap.bmHeight*SCALE + OFFSET;
80 
81  /* transparent blt, transparency: grey */
82  GdiTransparentBlt(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, 128*256*256+128*256+128);
83  y += bitmap.bmHeight + OFFSET;
84 
85  /* transparent blt, transparency: grey, scaled */
86  GdiTransparentBlt(hdc, x, y, bitmap.bmWidth*SCALE, bitmap.bmHeight*SCALE, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, 128*256*256+128*256+128);
87  y += bitmap.bmHeight*SCALE + OFFSET;
88 
89  /* alpha blend, org size */
90  GdiAlphaBlend(hdc, x, y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, bfunc);
91  y += bitmap.bmHeight + OFFSET;
92 
93  /* alpha blend, scaled */
94  GdiAlphaBlend(hdc, x, y, bitmap.bmWidth*SCALE, bitmap.bmHeight*SCALE, hdcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, bfunc);
95  y += bitmap.bmHeight*SCALE + OFFSET;
96 
97  x += bitmap.bmWidth*SCALE + OFFSET;
98  }
99 
100  /* icons */
101  for(i = 0; i < CURRENT_ICONS; i++)
102  {
103  y = 0;
104  /* pure icon */
105  DrawIcon(hdc, x, y, hicList[i]);
106  y += bitmap.bmHeight + OFFSET;
107 
108  /* normal icon using Ex */
109  DrawIconEx(hdc, x, y, hicList[i], 0, 0, 0, NULL, DI_NORMAL);
110  y += bitmap.bmHeight + OFFSET;
111 
112  /* normal icon using Ex with bigger size */
113  DrawIconEx(hdc, x, y, hicList[i], bitmap.bmWidth, bitmap.bmHeight, 0, NULL, DI_NORMAL);
114  y += bitmap.bmHeight + OFFSET;
115 
116  /* only icon using Ex */
117  DrawIconEx(hdc, x, y, hicList[i], 0, 0, 0, NULL, DI_IMAGE);
118  y += bitmap.bmHeight + OFFSET;
119 
120  /* mask using Ex */
121  DrawIconEx(hdc, x, y, hicList[i], 0, 0, 0, NULL, DI_MASK);
122  y += bitmap.bmHeight + OFFSET;
123 
124  x += bitmap.bmWidth*SCALE + OFFSET;
125  }
126 
127  DeleteDC(hdcMem);
128  EndPaint(hWnd, &ps);
129  break;
130  }
131 
132  case WM_DESTROY:
133  PostQuitMessage(0);
134  break;
135  default:
137  }
138  return 0;
139 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
#define DI_MASK
Definition: wingdi.h:71
#define OFFSET
Definition: vbltest.c:24
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, BLENDFUNCTION blendFunction)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define AC_SRC_ALPHA
Definition: alphablend.c:9
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)
WPARAM wParam
Definition: combotst.c:138
BYTE BlendOp
Definition: wingdi.h:2759
#define SCALE
Definition: vbltest.c:23
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1599
Definition: uimain.c:88
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
BYTE SourceConstantAlpha
Definition: wingdi.h:2761
#define GetObject
Definition: wingdi.h:4468
#define WM_PAINT
Definition: winuser.h:1610
HDC hdc
Definition: main.c:9
#define CURRENT_ICONS
Definition: vbltest.c:22
BYTE BlendFlags
Definition: wingdi.h:2760
#define AC_SRC_OVER
Definition: wingdi.h:1369
#define DI_NORMAL
Definition: wingdi.h:72
HINSTANCE hInst
Definition: vbltest.c:26
BOOL WINAPI DrawIcon(_In_ HDC, _In_ int, _In_ int, _In_ HICON)
Definition: cursoricon.c:1987
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1330
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WM_CREATE
Definition: winuser.h:1598
#define LoadImage
Definition: winuser.h:5805
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
#define LoadIcon
Definition: winuser.h:5803
#define LR_DEFAULTCOLOR
Definition: winuser.h:1081
BYTE AlphaFormat
Definition: wingdi.h:2762
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SRCCOPY
Definition: wingdi.h:333
HDC hdcMem
Definition: welcome.c:104
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
#define DI_IMAGE
Definition: wingdi.h:70
BOOL WINAPI GdiTransparentBlt(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
#define CURRENT_BMPS
Definition: vbltest.c:21

Referenced by MyRegisterClass().

Variable Documentation

◆ hInst

HINSTANCE hInst

Definition at line 26 of file vbltest.c.

Referenced by InitInstance(), and WndProc().

◆ szWindowClass

TCHAR szWindowClass[] = _T("testclass")

Definition at line 27 of file vbltest.c.

Referenced by InitInstance(), and MyRegisterClass().