基本如题。
如果要从外设中如SD卡中加载位图文件,应该用什么方法。我试了,::LoadBitmap 和::LoadImage()都没成功,后者在VC下
能成功,因为可以设置标志LR_LOADFROMFILE,可是在EVC下没有定义这个属性,应该怎么处理呢???
试试这个:
CBitmap hbmp;
HBITMAP hbitmap;
CStatic *pStaic;
pStaic=(CStatic*)GetDlgItem(IDC_showbmp);//控件ID
hbitmap = SHLoadDIBitmap(MapPath);//要加载的bmp路径
hbmp.Attach(hbitmap);
BITMAP bm;
hbmp.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(GetDC());
CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);
CRect lRect;
pStaic->GetClientRect(&lRect);
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),
&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,WHITENESS);
pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),
&dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dcMem.SelectObject(&poldBitmap);
hbitmap->unused;
DeleteObject(hbitmap);
hbmp.Detach();
hbmp.DeleteObject();