MFC picture control控件不失真自适应图片显示
来源:互联网 发布:网络教育统考网站 编辑:程序博客网 时间:2024/06/07 02:53
bool CFlapContrlDlg::Show_picture(CString imgPath)
{
int height, width;
CRect rect;//定义矩形类
CRect rect1;
CImage image; //创建图片类
image.Load(imgPath);
height = image.GetHeight();
width = image.GetWidth();
m_PictureControl.GetClientRect(&rect); //获得pictrue控件所在的矩形区域
CDC *pDc = m_PictureControl.GetDC();//获得pictrue控件的Dc
SetStretchBltMode(pDc->m_hDC,STRETCH_HALFTONE);
if(width<=rect.Width() && height<=rect.Width()) //小图片,不缩放
{
rect1 = CRect(rect.TopLeft(), CSize(width,height));
image.StretchBlt(pDc->m_hDC,rect1,SRCCOPY); //将图片画到Picture控件表示的矩形区域
return TRUE;
}
else
{
float xScale=(float)rect.Width()/(float)width;
float yScale=(float)rect.Height()/(float)height;
float ScaleIndex=(xScale>=yScale:xScale,yScale);
rect1 = CRect(rect.TopLeft(), CSize((int)width*ScaleIndex,(int)height*ScaleIndex));
image.StretchBlt(pDc->m_hDC,rect1,SRCCOPY); //将图片画到Picture控件表示的矩形区域
}
ReleaseDC(pDc);//释放picture控件的Dc
return TRUE;
{
int height, width;
CRect rect;//定义矩形类
CRect rect1;
CImage image; //创建图片类
image.Load(imgPath);
height = image.GetHeight();
width = image.GetWidth();
m_PictureControl.GetClientRect(&rect); //获得pictrue控件所在的矩形区域
CDC *pDc = m_PictureControl.GetDC();//获得pictrue控件的Dc
SetStretchBltMode(pDc->m_hDC,STRETCH_HALFTONE);
if(width<=rect.Width() && height<=rect.Width()) //小图片,不缩放
{
rect1 = CRect(rect.TopLeft(), CSize(width,height));
image.StretchBlt(pDc->m_hDC,rect1,SRCCOPY); //将图片画到Picture控件表示的矩形区域
return TRUE;
}
else
{
float xScale=(float)rect.Width()/(float)width;
float yScale=(float)rect.Height()/(float)height;
float ScaleIndex=(xScale>=yScale:xScale,yScale);
rect1 = CRect(rect.TopLeft(), CSize((int)width*ScaleIndex,(int)height*ScaleIndex));
image.StretchBlt(pDc->m_hDC,rect1,SRCCOPY); //将图片画到Picture控件表示的矩形区域
}
ReleaseDC(pDc);//释放picture控件的Dc
return TRUE;
0 0
- MFC picture control控件不失真自适应图片显示
- MFC picture control控件不失真自适应图片显示
- MFC picture control控件不失真自适应图片显示
- MFC Picture Control 自适应控件大小显示图片,失真和不失真
- MFC界面Picture Control自适应不失真显示图片
- C++ 图片自适应 picture control 控件大小 不失真显示
- VS2010-MFC:MFC PictureControl控件上自适应显示图片,分图片失真或者图片不失真两种
- mfc图片自适应picture control
- 自适应MFC中的picture control 控件来显示文件路径中的图片
- MFC--图片控件Picture Control
- MFC图片控件Picture Control
- mfc- Picture control显示图片
- MFC Picture Control显示图片
- MFC Picture Control 控件不随图片伸缩的方法
- MFC位图自适应Picture Control控件大小
- MFC中 利用OpenCv显示图片到Picture Control控件
- MFC 对话框中的picture control 控件显示图片
- MFC常用控件:图片控件Picture Control
- phy0 -> rt2x00lib_request_firmware: Error - Failed to request Firmware.
- Pro JPA2读书笔记系列(三)-第三章(企业应用程序)
- 负载均衡集群解决方案 Nginx
- poj 3045 Cow Acrobats (贪心)
- BAT及各大互联网公司2014前端笔试面试题--Html,Css篇
- MFC picture control控件不失真自适应图片显示
- 序列化
- HDOJ-----1969二分
- Http协议详解
- 图片要启用gzip压缩吗?绝对不要!
- 理清Activity、View及Window之间关系
- go语言反射reflect
- Windows的字体LOGFONT
- Linux夜间模式(f.lux)