ReactOS 0.4.15-dev-8614-gbc76250
showimg.c File Reference
#include <windows.h>
#include <stdio.h>
Include dependency graph for showimg.c:

Go to the source code of this file.

Functions

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 wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
 

Variables

WCHAR szWindowClass [] = L"testclass"
 

Function Documentation

◆ InitInstance()

static BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)
static

Definition at line 104 of file showimg.c.

105{
106 HWND hWnd;
107
110 L"Bmp test",
114 300,
115 120,
116 NULL,
117 NULL,
118 hInstance,
119 NULL);
120
121 if (!hWnd)
122 return FALSE;
123
124 ShowWindow(hWnd, nCmdShow);
126
127 return TRUE;
128}
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
WCHAR szWindowClass[]
Definition: showimg.c:6
#define CreateWindowEx
Definition: winuser.h:5767
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225

Referenced by wWinMain().

◆ MyRegisterClass()

static ATOM MyRegisterClass ( HINSTANCE  hInstance)
static

Definition at line 81 of file showimg.c.

82{
83 WNDCLASSEX wcex;
84
85 wcex.cbSize = sizeof(WNDCLASSEX);
86
88 wcex.lpfnWndProc = WndProc;
89 wcex.cbClsExtra = 0;
90 wcex.cbWndExtra = 0;
91 wcex.hInstance = hInstance;
92 wcex.hIcon = NULL;
94 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
95 wcex.lpszMenuName = NULL;
97 wcex.hIconSm = NULL;
98
99 return RegisterClassEx(&wcex);
100}
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: showimg.c:9
int cbClsExtra
Definition: winuser.h:3207
HINSTANCE hInstance
Definition: winuser.h:3209
HCURSOR hCursor
Definition: winuser.h:3211
LPCSTR lpszMenuName
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3215
UINT style
Definition: winuser.h:3205
int cbWndExtra
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3204
WNDPROC lpfnWndProc
Definition: winuser.h:3206
LPCSTR lpszClassName
Definition: winuser.h:3214
HICON hIcon
Definition: winuser.h:3210
HBRUSH hbrBackground
Definition: winuser.h:3212
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:921
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define RegisterClassEx
Definition: winuser.h:5849
#define LoadCursor
Definition: winuser.h:5824
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5731

Referenced by wWinMain().

◆ WndProc()

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

Definition at line 9 of file showimg.c.

10{
11 static HBITMAP hBmp;
13 CHAR buffer[32];
14
15 switch (message)
16 {
17 case WM_CREATE:
18 {
20 sprintf(buffer, "%p", handle);
21 MessageBoxA(NULL, buffer, "handle", 0);
23 sprintf(buffer, "%p", hBmp);
24 MessageBoxA(NULL, buffer, "Bmp", 0);
25 sprintf(buffer, "%ld", GetLastError());
26 MessageBoxA(NULL, buffer, "LastError", 0);
27 break;
28 }
29
30 case WM_PAINT:
31 {
32 PAINTSTRUCT ps;
33 HDC hdc, hdcMem;
35 BITMAPINFO bmi;
36 hdc = BeginPaint(hWnd, &ps);
37 HGLOBAL hMem;
38 LPVOID lpBits;
39
41 SelectObject(hdcMem, hBmp);
42 GetObject(hBmp, sizeof(BITMAP), &bitmap);
43
44 memset(&bmi, 0, sizeof(bmi));
45 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
46 bmi.bmiHeader.biWidth = bitmap.bmWidth;
47 bmi.bmiHeader.biHeight = bitmap.bmHeight;
48 bmi.bmiHeader.biPlanes = bitmap.bmPlanes;
49 bmi.bmiHeader.biBitCount = bitmap.bmBitsPixel;
51 bmi.bmiHeader.biSizeImage = 0;
52
53 hMem = GlobalAlloc(GMEM_MOVEABLE, ((bitmap.bmWidth *
54 bmi.bmiHeader.biBitCount + 31) / 32) * 4 * bitmap.bmHeight);
55 lpBits = GlobalLock(hMem);
56 GetDIBits(hdc, hBmp, 0, bitmap.bmHeight, lpBits, &bmi, DIB_RGB_COLORS);
57
58 // increasing the multiplier makes the image larger
59 StretchDIBits(hdc, 0, 0, bitmap.bmWidth * 3, bitmap.bmHeight * 3, 0, 0,
60 bitmap.bmWidth, bitmap.bmHeight,lpBits, &bmi, DIB_RGB_COLORS, SRCCOPY);
61 GlobalUnlock(hMem);
62 GlobalFree(hMem);
63
65
66 EndPaint(hWnd, &ps);
67 break;
68 }
69
70 case WM_DESTROY:
72 break;
73 default:
75 }
76 return 0;
77}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
#define BI_RGB
Definition: precomp.h:56
GLuint buffer
Definition: glext.h:5915
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define DefWindowProc
Definition: ros2win.h:31
#define memset(x, y, z)
Definition: compat.h:39
Definition: bl.h:1331
Definition: uimain.c:89
Definition: tftpd.h:60
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HDC hdcMem
Definition: welcome.c:104
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define GMEM_MOVEABLE
Definition: winbase.h:294
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
#define GetObject
Definition: wingdi.h:4468
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
#define WM_PAINT
Definition: winuser.h:1623
#define IMAGE_BITMAP
Definition: winuser.h:211
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadImage
Definition: winuser.h:5827
#define LR_DEFAULTCOLOR
Definition: winuser.h:1090
#define WM_DESTROY
Definition: winuser.h:1612
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define MAKEINTRESOURCE
Definition: winuser.h:591
char CHAR
Definition: xmlstorage.h:175

Referenced by MyRegisterClass().

◆ wWinMain()

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

Definition at line 131 of file showimg.c.

135{
136 MSG msg;
137
139
140 if (!InitInstance(hInstance, nCmdShow))
141 return FALSE;
142
143 while (GetMessage(&msg, NULL, 0, 0))
144 {
147 }
148
149 return (int)msg.wParam;
150}
#define msg(x)
Definition: auth_time.c:54
static ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: showimg.c:81
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: showimg.c:104
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define GetMessage
Definition: winuser.h:5802
#define DispatchMessage
Definition: winuser.h:5777

Variable Documentation

◆ szWindowClass

WCHAR szWindowClass[] = L"testclass"

Definition at line 6 of file showimg.c.

Referenced by InitInstance(), and MyRegisterClass().