19,468
社区成员
发帖
与我相关
我的任务
分享
void CtestDrawDlg::ZoomOutShow()
{
BOOL bRet = m_pxImage->Load(m_lpFilePath,CXIMAGE_FORMAT_JPG|CXIMAGE_FORMAT_BMP); //读取原图
if(!bRet)
{
return ;
}
GetDisplayRect();
Invalidate(FALSE);
}
void CtestDrawDlg::GetDisplayRect()
{
//RC_HEIGHT、RC_WIDTH分别为显示区域的高度和宽度
//PIC_HEIGHT、PIC_WIDTH分别为图片的实际的高度和宽度
if (RC_WIDTH < RC_HEIGHT)
{
long h = (long)(RC_HEIGHT - PIC_HEIGHT/(PIC_WIDTH/(RC_WIDTH*1.0)))>>1;
h = h>0?h:0;
m_rcThumbnail.left = 0;
m_rcThumbnail.right = m_rcShow.right - m_rcShow.left;
m_rcThumbnail.top = 0 + h;
m_rcThumbnail.bottom = m_rcShow.bottom - m_rcShow.top - h;
}
else
{
long w = (long)(RC_WIDTH - PIC_WIDTH/(PIC_HEIGHT/(RC_HEIGHT*1.0)))>>1;
w = w>0?w:0;
m_rcThumbnail.top = 0;
m_rcThumbnail.bottom = m_rcShow.bottom - m_rcShow.top;
m_rcThumbnail.left = 0 + w;
m_rcThumbnail.right = m_rcShow.right - m_rcShow.left - w;
}
}
if (bSmooth)
{
if (fx > 1 && fy > 1)
{
c = GetAreaColorInterpolated(dx - 0.5f, dy - 0.5f, fx, fy, CxImage::IM_BILINEAR, CxImage::OM_REPEAT);
}
else
{
c = GetPixelColorInterpolated(dx - 0.5f, dy - 0.5f, CxImage::IM_BILINEAR, CxImage::OM_REPEAT);
}
}