MFC picture control 显示不同格式图片
来源:互联网 发布:程序员示爱网页源代码 编辑:程序博客网 时间:2024/05/20 17:25
先上代码:
添加一个picture control,将ID改为IDC_STATIC_IMAGE,方便查看调用。
BOOL CVQMTDlg::ShowImage(){(CStatic*)GetDlgItem(IDC_STATIC_IMAGE)->ModifyStyle(0xF, SS_BITMAP | SS_CENTERIMAGE);CDC *pDc = NULL;pDc = GetDlgItem(IDC_STATIC_IMAGE)->GetDC();IPicture *pPic = NULL;OleLoadPicturePath(CComBSTR(m_sfiles[m_curImagePos].c_str()), (LPUNKNOWN)NULL, 0, 0, IID_IPicture, (LPVOID*)&pPic);if (NULL == pPic){return FALSE;}// 获取图像宽和高,注意这里的宽和高不是图像的分辨率 OLE_XSIZE_HIMETRIC hmWidth;OLE_YSIZE_HIMETRIC hmHeight;pPic->get_Width(&hmWidth);pPic->get_Height(&hmHeight);// 获取显示图片窗口的宽度和高度 RECT rtWnd;pDc->GetWindow()->GetWindowRect(&rtWnd);int iWndWidth = rtWnd.right - rtWnd.left;int iWndHeight = rtWnd.bottom - rtWnd.top;if (FAILED(pPic->Render(*pDc, 0, 0, iWndWidth, iWndHeight, 0, hmHeight, hmWidth, -hmHeight, NULL))){pPic->Release();return false;}//记得释放资源,不然会导致内存泄露 pPic->Release();return true;}
效果图:
这样就完美的切合了
参考一:http://blog.csdn.net/dafenqie/article/details/53337282
参考二:http://www.cnblogs.com/Forever-Road/p/6800838.html?utm_source=itdadao&utm_medium=referral
阅读全文
0 0
- MFC picture control 显示不同格式图片
- mfc- Picture control显示图片
- MFC Picture Control显示图片
- MFC在picture control中JPG/BMP/ICO等格式图片显示,并支持清除图片显示
- MFC实现的 picture control 类,对话框上显示图片
- mfc Picture control显示图片,利用资源ID
- MFC中 利用OpenCv显示图片到Picture Control控件
- MFC picture control控件不失真自适应图片显示
- MFC用Picture control显示jpg等各种图片
- MFC picture control控件不失真自适应图片显示
- MFC 对话框中的picture control 控件显示图片
- MFC picture control控件不失真自适应图片显示
- MFC界面Picture Control自适应不失真显示图片
- MFC——选择图片显示到Picture Control
- MFC--图片控件Picture Control
- MFC图片控件Picture Control
- mfc图片自适应picture control
- WTL Picture Control显示图片
- 【51nod 1085】背包问题(0-1背包模板)
- 如何同步本地代码到SVN服务器
- 1、java容易忘记的基础语法知识
- stm32:error: #268: declaration may not appear after executable statement in block
- GNU GPL介绍
- MFC picture control 显示不同格式图片
- css样式--将大小不固定的图片或文字段 垂直居中
- php md5()漏洞
- SQL批量修改某一个字段的值
- Android模拟信科教务登录
- HTML之JavaScript自学笔记(1)
- 欢迎使用CSDN-markdown编辑器
- [笔记分享] [Camera] msm8926的ZSL功能小结
- android动画