⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dib_draw.h

📁 实时监控
💻 H
字号:
#ifndef _DIB_DRAW_H
#define _DIB_DRAW_H

#include "vfw.h"
#pragma comment(lib,"vfw32.lib")

/// DrawDibXXX函数族封装类.
class dib_draw
{
	HDRAWDIB handle;	// handle
	CWnd *o;			// owner
	BITMAPINFOHEADER bih;

public:
	dib_draw():handle(NULL), o(NULL){}
	~dib_draw(){destroy();}

	bool create(CWnd* owner, int w, int h, DWORD fourcc, int bitcount)
	{
		o = owner;
		ZeroMemory(&bih, sizeof(bih));
		bih.biSize = sizeof(bih);

		bih.biBitCount = bitcount;
		bih.biCompression = fourcc;
		bih.biWidth = w;
		bih.biHeight = h;
		bih.biPlanes = 1;

		handle = DrawDibOpen();

		return handle != NULL;
	}

	void destroy()
	{
		if( handle )
		{
			DrawDibClose(handle);
			handle = NULL;
		}
		o = NULL;
	}

	void draw(void* buf) 
	{
		if( !handle || !o ) return;

		CClientDC dc(o);
		CRect rc;
		o->GetClientRect(rc);

		draw(buf, &dc, rc);
	}
	void draw(void* buf, CDC* pdc, CRect rc)
	{
		DrawDibDraw(handle, pdc->m_hDC, rc.left, rc.top, rc.Width(), rc.Height(), 
			&bih, buf, 
			0, 0, bih.biWidth, bih.biHeight, 
			SRCCOPY);
	}
};

#endif	// _DIB_DRAW_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -