用vc 读取BMP图片并显示出来代码怎么写啊?
2个回答
展开全部
显示位图文件
HBITMAP hBitmap=(HBITMAP)LoadImage(NULL,_T(“xxx.bmp”),Image_Bitmap,0,0,
Lr_CreateDibSection|Lr_DefaultSize|Lr_LoadFromFile); //加岁猛姿载bmp文件
CBitmap bitmap;
bitmap.Attach(hBitmap); //关联位图对象
CDC dcimage;
dcimage.CreateCompatibleDC(pDC); //内存DC
BITMAP bmp;
bitmap.GetBitmap(&bmp); //获取位图信息
dcimage.SelectObject(&bitmap); //知枯选取位图对象
pDC->BitBlt(0,0,bmp.bmWidth,bmp.bmHeight,&dcimage,0,0,SRCCOPY); //显示乎绝
这是单文档显示位图文件的方法,你照着看吧。
HBITMAP hBitmap=(HBITMAP)LoadImage(NULL,_T(“xxx.bmp”),Image_Bitmap,0,0,
Lr_CreateDibSection|Lr_DefaultSize|Lr_LoadFromFile); //加岁猛姿载bmp文件
CBitmap bitmap;
bitmap.Attach(hBitmap); //关联位图对象
CDC dcimage;
dcimage.CreateCompatibleDC(pDC); //内存DC
BITMAP bmp;
bitmap.GetBitmap(&bmp); //获取位图信息
dcimage.SelectObject(&bitmap); //知枯选取位图对象
pDC->BitBlt(0,0,bmp.bmWidth,bmp.bmHeight,&dcimage,0,0,SRCCOPY); //显示乎绝
这是单文档显示位图文件的方法,你照着看吧。
展开全部
给你一个程序,你建立一个基于清哗尺对话框的程序,在主对话框上加载一个 PictureBox,然后加载一芦桐个Button,添加点击Button事件。具体代答高码如下:
CFileDialog dlg(TRUE,"bmp",".bmp",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"位图文件(*.BMP)|*.BMP||");
dlg.DoModal();
HBITMAP hBitmap;
HDC hSrcDC;
HDC hDesDC;
CBitmap bmp;
CWnd *hwnd;
RECT rect;
BITMAP bm;
hwnd = GetDlgItem(IDC_STATIC);
hDesDC = hwnd->GetDC()->m_hDC;
hSrcDC = CreateCompatibleDC(hDesDC);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
hwnd->GetClientRect(&rect);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
CFileDialog dlg(TRUE,"bmp",".bmp",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"位图文件(*.BMP)|*.BMP||");
dlg.DoModal();
HBITMAP hBitmap;
HDC hSrcDC;
HDC hDesDC;
CBitmap bmp;
CWnd *hwnd;
RECT rect;
BITMAP bm;
hwnd = GetDlgItem(IDC_STATIC);
hDesDC = hwnd->GetDC()->m_hDC;
hSrcDC = CreateCompatibleDC(hDesDC);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
hwnd->GetClientRect(&rect);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询