Use the Windows API to read and manipulate bitmap files.
//------------------------------------------------------------------------------ // Copyright (c) 2009 eryar All rights reserved. // // File : Main.cpp // Author : eryar@163.com // Date : 2009-9-18 23:04 // Version : 1.0v // // Description : // //============================================================================== #include <windows.h> #define IDM_FILE_OPEN 10000 #define IDM_FILE_EXIT 10001 CHAR* g_szAppName = "Read Bitmap"; CHAR* g_szClassName = "CReadBMP"; HINSTANCE g_hInst; void TrackMenu(HWND hWnd, POINT point); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { MSG Msg; HWND hWnd; WNDCLASSEX wndclass; wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_HREDRAW|CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = NULL; //(HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = g_szClassName; if (!RegisterClassEx(&wndclass)) { MessageBox(NULL, "register class failed! ", g_szAppName, MB_OK|MB_ICONERROR); return false; } hWnd = CreateWindowEx( NULL, g_szClassName, g_szAppName, WS_OVERLAPPEDWINDOW, 0,0, 300, 300, NULL, NULL, hInstance, NULL); if (!hWnd) { MessageBox(NULL, " create window failed! ", g_szAppName, MB_OK|MB_ICONERROR); return false; } g_hInst = hInstance; ShowWindow(hWnd, nShowCmd); UpdateWindow(hWnd); while(GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg,
WPARAM wParam,
LPARAM lParam)
{
PAINTSTRUCT ps;
static RECT rect;
static HDC hDC;
static HDC hDCBackBuffer;
static HBITMAP hBitmap;
static HBITMAP hOldBitmap;
