2026-01-02 20:00:18 +01:00
|
|
|
|
#pragma once
|
2025-11-23 10:57:52 +01:00
|
|
|
|
#include <Vfw.h>
|
|
|
|
|
|
#pragma comment(lib,"Vfw32.lib")
|
|
|
|
|
|
|
|
|
|
|
|
#define ERR_INVALID_PARAM 1
|
|
|
|
|
|
#define ERR_NO_ENCODER 2
|
|
|
|
|
|
#define ERR_INTERNAL 3
|
|
|
|
|
|
#define ERR_NOT_SUPPORT 4
|
|
|
|
|
|
|
|
|
|
|
|
enum FCCHandler {
|
2025-11-29 23:22:55 +01:00
|
|
|
|
ENCODER_BMP = BI_RGB,
|
|
|
|
|
|
ENCODER_MJPEG = mmioFOURCC('M', 'J', 'P', 'G'),
|
2026-01-02 20:00:18 +01:00
|
|
|
|
// 安装x264vfw编解码器: https://sourceforge.net/projects/x264vfw/
|
2025-11-29 23:22:55 +01:00
|
|
|
|
ENCODER_H264 = mmioFOURCC('X', '2', '6', '4'),
|
2025-11-23 10:57:52 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
|
* @class CBmpToAvi
|
2026-01-02 20:00:18 +01:00
|
|
|
|
* @brief 位图转AVI帧
|
2025-11-23 10:57:52 +01:00
|
|
|
|
************************************************************************/
|
|
|
|
|
|
class CBmpToAvi
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
2025-11-29 23:22:55 +01:00
|
|
|
|
CBmpToAvi();
|
|
|
|
|
|
virtual ~CBmpToAvi();
|
|
|
|
|
|
int Open(LPCTSTR szFile, LPBITMAPINFO lpbmi, int rate = 4, FCCHandler h = ENCODER_BMP);
|
|
|
|
|
|
bool Write(unsigned char* lpBuffer);
|
|
|
|
|
|
void Close();
|
|
|
|
|
|
static std::string GetErrMsg(int result)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (result) {
|
|
|
|
|
|
case ERR_INVALID_PARAM:
|
2026-01-02 20:00:18 +01:00
|
|
|
|
return ("无效参数");
|
2025-11-29 23:22:55 +01:00
|
|
|
|
case ERR_NOT_SUPPORT:
|
2026-01-02 20:00:18 +01:00
|
|
|
|
return ("不支持的位深度,需要24位或32位");
|
2025-11-29 23:22:55 +01:00
|
|
|
|
case ERR_NO_ENCODER:
|
2026-01-02 20:00:18 +01:00
|
|
|
|
return ("未安装x264编解码器 \n下载地址:https://sourceforge.net/projects/x264vfw");
|
2025-11-29 23:22:55 +01:00
|
|
|
|
case ERR_INTERNAL:
|
2026-01-02 20:00:18 +01:00
|
|
|
|
return("创建AVI文件失败");
|
2025-11-29 23:22:55 +01:00
|
|
|
|
default:
|
|
|
|
|
|
return "succeed";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-23 10:57:52 +01:00
|
|
|
|
private:
|
2025-11-29 23:22:55 +01:00
|
|
|
|
FCCHandler m_fccHandler;
|
|
|
|
|
|
PAVIFILE m_pfile;
|
|
|
|
|
|
PAVISTREAM m_pavi;
|
|
|
|
|
|
int m_nFrames;
|
2026-01-02 20:00:18 +01:00
|
|
|
|
static AVISTREAMINFO m_si; // 这个参数需要是静态的
|
2025-11-23 10:57:52 +01:00
|
|
|
|
|
2025-11-29 23:22:55 +01:00
|
|
|
|
int m_bitCount = 24;
|
|
|
|
|
|
int m_width = 1920;
|
|
|
|
|
|
int m_height = 1080;
|
|
|
|
|
|
int m_quality = 90;
|
|
|
|
|
|
HIC m_hic = NULL;
|
2025-11-23 10:57:52 +01:00
|
|
|
|
};
|