#pragma once typedef DWORD COLORREF; typedef uint8_t BYTE; typedef uint16_t WORD; typedef int32_t LONG; typedef unsigned short* PWORD; #define BITSPERPIXEL 32 // 目标格式每像素位数 #define BITMAPBITSPERPIXEL 24 // 假设输入是24位BMP #define RGB(r, g, b) ((COLORREF)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((DWORD)(unsigned char)(b))<<16))) #pragma pack(push, 1) typedef struct { WORD bfType; // 必须为'BM' DWORD bfSize; // 文件大小 WORD bfReserved1; // 保留 WORD bfReserved2; // 保留 DWORD bfOffBits; // 像素数据偏移量 } BITMAPFILEHEADER; // BMP信息头结构(Linux环境下模拟) typedef struct { DWORD biSize; // 本结构大小 LONG biWidth; // 宽度 LONG biHeight; // 高度 WORD biPlanes; // 色彩平面数,必须为1 WORD biBitCount; // 每像素位数 DWORD biCompression; // 压缩方式 DWORD biSizeImage; // 像素数据大小 LONG biXPelsPerMeter;// 水平分辨率 LONG biYPelsPerMeter;// 垂直分辨率 DWORD biClrUsed; // 使用的颜色数 DWORD biClrImportant; // 重要颜色数 } BITMAPINFOHEADER; #pragma pack(pop) class SeqImages { DWORD m_Count; vector m_pSmCircleBuff; int m_nWidth, m_nHeight; unsigned short * TransBmp2Raw(unsigned char* pBuff, DWORD width, DWORD height); unsigned char* LoadBmp(const char *szFilename, DWORD &width, DWORD &height); bool LoadBmpFromDirectory(const char *pszDirName); bool LoadRawFromDirectory(const char *pszDirName, DWORD dx, DWORD dy); bool CreateCircle(DWORD size, DWORD count); void CloseCircle(); public: SeqImages(); virtual ~SeqImages(); bool LoadPath(const char *pPath, DWORD dwImgX = 0, DWORD dwImgY = 0); void PushMemImage(unsigned short* pRaw, int nW, int nH, int nBits); DWORD GetCurrentFrameID(); unsigned short * GetImage(); int GetNext(); bool ResetImageID(); bool ClearImage(); int GetWidth() const { return m_nWidth; } int GetHeight() const { return m_nHeight; } int GetTotalFrameNumber(); };