64,662
社区成员
发帖
与我相关
我的任务
分享
HWND hWnd = pDlg->m_hWnd;
HDC hdcTemp = pDlg->GetDC()->m_hDC;
HDC m_hdcMemory = CreateCompatibleDC(hdcTemp);
BYTE *pBits;
BITMAPINFOHEADER bmih;
ZeroMemory(&bmih,sizeof(BITMAPINFO));
//SecureZeroMemory(&bmih,sizeof(BITMAPINFO));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = nWidth;
bmih.biHeight = nHeight;
bmih.biPlanes = 1 ;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = 0 ;
bmih.biXPelsPerMeter = 0 ;
bmih.biYPelsPerMeter = 0 ;
bmih.biClrUsed = 0 ;
bmih.biClrImportant = 0 ;
HBITMAP hBitMap = CreateDIBSection(NULL,(BITMAPINFO*)&bmih,0,(VOID**)&pBits,NULL,0);
//============================================================================================
SelectObject(m_hdcMemory,hBitMap);
HWND hWnd = pDlg->m_hWnd;
HDC hdcTemp = pDlg->GetDC()->m_hDC;
HDC m_hdcMemory = CreateCompatibleDC(hdcTemp);
BYTE *pBits;
BITMAPINFOHEADER bmih;//初始化bmih是BITMAPINFOHEADER类型
ZeroMemory(&bmih,sizeof(BITMAPINFO));
//SecureZeroMemory(&bmih,sizeof(BITMAPINFO));//此处bmih是pvoid类型
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = nWidth;
bmih.biHeight = nHeight;
bmih.biPlanes = 1 ;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = 0 ;
bmih.biXPelsPerMeter = 0 ;
bmih.biYPelsPerMeter = 0 ;
bmih.biClrUsed = 0 ;
bmih.biClrImportant = 0 ;
HBITMAP hBitMap = CreateDIBSection(NULL,(BITMAPINFO*)&bmih,0,(VOID**)&pBits,NULL,0);//此处bmih是BITMAPINFO*类型
//============================================================================================
SelectObject(m_hdcMemory,hBitMap);
HWND hWnd = pDlg->m_hWnd;
HDC hdcTemp = pDlg->GetDC()->m_hDC;
HDC m_hdcMemory = CreateCompatibleDC(hdcTemp);
BYTE *pBits;
BITMAPINFOHEADER bmih;
ZeroMemory(&bmih,sizeof(BITMAPINFO));
//SecureZeroMemory(&bmih,sizeof(BITMAPINFO));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = nWidth;
bmih.biHeight = nHeight;
bmih.biPlanes = 1 ;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = 0 ;
bmih.biXPelsPerMeter = 0 ;
bmih.biYPelsPerMeter = 0 ;
bmih.biClrUsed = 0 ;
bmih.biClrImportant = 0 ;
HBITMAP hBitMap = CreateDIBSection(NULL,(BITMAPINFO*)&bmih,0,(VOID**)&pBits,NULL,0);
//============================================================================================
SelectObject(m_hdcMemory,hBitMap);
第八行中ZeroMemory调用的是*void类型,而定义的是BITMAPINFOHEADER 类型
ZeroMemory Macro
Fills a block of memory with zeros.
To avoid any undesired effects of optimizing compilers, use the SecureZeroMemory function.
void ZeroMemory(
[in] PVOID Destination,
[in] SIZE_T Length
);
第二十二行中的BITMAPINFOHEADER 的bmih被改成了BITMAPINFO*类型
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER