ReactOS 0.4.15-dev-8064-gdaf8068
bitblt.c
Go to the documentation of this file.
1
2/*
3 * Windows 2000 Graphics API Black Book
4 * (BitBlt Bitmap Rendering Demo)
5 *
6 * Created by Damon Chandler <dmc27@ee.cornell.edu>
7 * Updates can be downloaded at: <www.coriolis.com>
8 *
9 * Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
10 * if you have any questions about this code.
11 */
12
13
14#include <windows.h>
15#include <string.h>
16
18const char* WndClassName = "GMainWnd";
20 LPARAM LParam);
21
22
23int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
24 LPTSTR lpCmdLine, int nCmdShow)
25{
26 WNDCLASS wc;
27 MSG msg;
28
29 HInst = HInstance;
30
31 memset(&wc, 0, sizeof(WNDCLASS));
32
35 wc.hInstance = HInstance;
37 /* wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1); */
38 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
40
41 if (RegisterClass(&wc))
42 {
43 HWND HWnd =
45 WndClassName, TEXT("BitBlt Bitmap Rendering Demo"),
48 0, 0, 220, 230,
50 );
51
52 if (HWnd)
53 {
54 ShowWindow(HWnd, nCmdShow);
55 UpdateWindow(HWnd);
56
57 while (GetMessage(&msg, NULL, 0, 0))
58 {
61 }
62 }
63 }
64 return 0;
65}
66
67/* image related */
69LPCSTR filename = TEXT("lena.bmp");
72
74 LPARAM LParam)
75{
76 switch (Msg)
77 {
78 case WM_CREATE:
79 {
80 /* create a memory DC */
82 if (HMemDC)
83 {
84 /* load a bitmap from file */
86 /* static_cast<HBITMAP> */(
88 0, 0, 0)
89 );
90 if (HBmp)
91 {
92 /* extract dimensions of the bitmap */
93 GetObject(HBmp, sizeof(BITMAP), &bmp);
94
95 /* associate the bitmap with the memory DC */
96 /* HOldBmp = static_cast<HBITMAP> */
98 );
99 }
100 }
101 }
102 case WM_PAINT:
103 {
104 PAINTSTRUCT ps;
105 const HDC Hdc = BeginPaint(HWnd, &ps);
106#if 0
107 try
108#endif
109 {
110
111 /* TODO: add palette support (see Chapter 9)... */
112
113
114 BitBlt(Hdc, 20, 15,
115 bmp.bmWidth, bmp.bmHeight,
116 HMemDC, 0, 0,
117 SRCCOPY);
118 }
119#if 0
120 catch (...)
121#endif
122 {
123 EndPaint(HWnd, &ps);
124 }
125 EndPaint(HWnd, &ps);
126 break;
127 }
128 case WM_DESTROY:
129 {
130 /* clean up */
133
135 return 0;
136 }
137 }
138 return DefWindowProc(HWnd, Msg, WParam, LParam);
139}
#define msg(x)
Definition: auth_time.c:54
struct @1636 Msg[]
#define NULL
Definition: types.h:112
#define APIENTRY
Definition: api.h:79
#define CALLBACK
Definition: compat.h:35
static VOID 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:57
pKey DeleteObject()
const char * filename
Definition: ioapi.h:137
#define TEXT(s)
Definition: k32.h:26
const char * WndClassName
Definition: bitblt.c:18
BITMAP bmp
Definition: bitblt.c:68
HDC HMemDC
Definition: bitblt.c:70
int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
Definition: bitblt.c:23
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, LPARAM LParam)
Definition: bitblt.c:73
HINSTANCE HInst
Definition: bitblt.c:17
HBITMAP HOldBmp
Definition: bitblt.c:71
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define DefWindowProc
Definition: ros2win.h:31
#define memset(x, y, z)
Definition: compat.h:39
Definition: bl.h:1331
HBRUSH hbrBackground
Definition: winuser.h:3170
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3163
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
#define WM_PAINT
Definition: winuser.h:1620
#define CS_VREDRAW
Definition: winuser.h:658
#define IMAGE_BITMAP
Definition: winuser.h:211
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5812
#define LoadImage
Definition: winuser.h:5815
#define RegisterClass
Definition: winuser.h:5836
#define WM_DESTROY
Definition: winuser.h:1609
#define DispatchMessage
Definition: winuser.h:5765
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define COLOR_BTNFACE
Definition: winuser.h:928
HBITMAP HBmp
const char * LPCSTR
Definition: xmlstorage.h:183
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192