15,978
社区成员
发帖
与我相关
我的任务
分享
CImage m_BkImg;
m_BkImg.Load(_T("mypic.png"));
m_BkImg.Draw(m_hDC,0,0)
HBITMAP CreateBitmap32(Image* pImage)
{
SIZE sz = { pImage->GetWidth(), pImage->GetHeight() };
// Create a 32 bits depth bitmap and select it into the memory DC
BITMAPINFOHEADER stBmpInfoHeader = { 0 };
stBmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
stBmpInfoHeader.biWidth = sz.cx;
stBmpInfoHeader.biHeight = sz.cy;
stBmpInfoHeader.biPlanes = 1;
stBmpInfoHeader.biBitCount = 32;
stBmpInfoHeader.biCompression = BI_RGB;
stBmpInfoHeader.biClrUsed = 0;
stBmpInfoHeader.biSizeImage = (((sz.cx * 32 + 31) & (~31)) >> 3) * sz.cy;
HBITMAP hbm32 = CreateDIBSection(NULL, (PBITMAPINFO)&stBmpInfoHeader, DIB_RGB_COLORS, NULL, NULL, 0);
if (hbm32)
{
HDC hdcMem = CreateCompatibleDC(NULL);
SelectObject(hdcMem, hbm32);
Graphics graph(hdcMem);
graph.DrawImage(pImage, 0, 0, sz.cx, sz.cy);
//要做不规则窗口则hdcMem为UpdateLayeredWindow的第5个参数
DeleteDC(hdcMem);
}
return hbm32;
}