16,473
社区成员
发帖
与我相关
我的任务
分享
//加载JPG
IPicture* pPic;
OleLoadPicturePath(_T("F:\\map.jpg"), NULL, NULL, NULL, IID_IPicture,(LPVOID*)&pPic);
if (pPic==NULL) return;
HBITMAP hPic = NULL;
pPic->get_Handle((UINT*)&hPic);
CBitmap cbitmap;
cbitmap.Attach(hPic);
BITMAP bmp;
cbitmap.GetBitmap(&bmp);
int width = bmp.bmWidth;
int height = bmp.bmHeight;
CDC *thedc=GetDC();
CDC dcMemory,dcMemory2;//兼容dc
dcMemory.CreateCompatibleDC(thedc);
dcMemory2.CreateCompatibleDC(&dcMemory);
CBitmap thebit;
thebit.CreateCompatibleBitmap(&dcMemory,width,height);
dcMemory.SelectObject(&thebit);
dcMemory2.SelectObject(&cbitmap);
dcMemory.BitBlt(0,0,width,height,&dcMemory2,0,0,SRCCOPY);
thedc->BitBlt(0,0,width,height,&dcMemory,0,0,SRCCOPY);