bitmap.cpp
来自「用vc编写的视频采集端口编成」· C++ 代码 · 共 46 行
CPP
46 行
// Bitmap.cpp: implementation of the CMyBitmap class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Bitmap.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMyBitmap::CMyBitmap()
{
}
bool CMyBitmap::Init(HINSTANCE hInstance, HDC hDc, WORD wBmpID)
{
BITMAP bm;
hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(wBmpID));
if( !hDc || !hBitmap)
return 0;
hMemDc = CreateCompatibleDC(hDc);
SelectObject(hMemDc, hBitmap);
SetMapMode(hMemDc, GetMapMode(hDc));
GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
pt.x = bm.bmWidth;
pt.y = bm.bmHeight;
return 1;
}
bool CMyBitmap::Show(HDC hDc, int x, int y)
{
int iResult;
iResult = BitBlt(hDc, x, y, pt.x, pt.y, hMemDc, 0, 0, SRCCOPY);
if (iResult == 0)
return 0;
else return 1;
}
CMyBitmap::~CMyBitmap()
{
DeleteDC(hMemDc);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?