16,472
社区成员
发帖
与我相关
我的任务
分享
BOOL CLSDC::RemoteDisplay(HBITMAP hbitmap, RECT size)
{
BITMAP bmp;
GetObject(hbitmap, sizeof(BITMAP), &bmp);
const int dataSize = (bmp.bmWidthBytes * bmp.bmHeight );
m_pMsgData = MapViewOfFile(m_hMsgFile, FILE_MAP_READ | FILE_MAP_WRITE,
0, 0, 0);
if (m_pMsgData == NULL)
return FALSE;
HDC hdc = GetDC(NULL);
HBITMAP bitmap = CreateCompatibleBitmap(hdc, bmp.bmWidth, bmp.bmHeight);
BITMAPINFO bmpinfo;
bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpinfo.bmiHeader.biBitCount = 0;
int res;
res = ::GetDIBits(hdc, bitmap, 0, 1, NULL, &bmpinfo, DIB_RGB_COLORS);
if(res == 0)
return FALSE;
SelectObject(hdc, hbitmap);
GetDIBits(hdc, hbitmap, 0, bmp.bmHeight, m_pMsgData, &bmpinfo, DIB_RGB_COLORS);
UnmapViewOfFile(m_pMsgData);
return TRUE;
}