请问怎么用VC++实现图形缩放?

xsh525 2005-04-13 09:11:12
我现在在用VC++编一个类似windows自带的画图程序,请问怎么实现放大和缩小的功能,要求线条粗细不变,而且可以用鼠标拖动选择要放大的区域。请大虾指点。
...全文
677 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
sherry1127 2005-04-25
  • 打赏
  • 举报
回复
mark
girlliujie 2005-04-23
  • 打赏
  • 举报
回复
我有这方面的代码,要不要咯?
给点分就行了
happyll 2005-04-20
  • 打赏
  • 举报
回复
这个是图像放大
看看 何斌的<数字图像编程>
gloomyfish 2005-04-19
  • 打赏
  • 举报
回复
插点算法
<<数字图象处理>> 冈萨雷斯
qiangv 2005-04-19
  • 打赏
  • 举报
回复
设置坐标的映射模式就可以了
不会改变线条粗细
vcPlayer 2005-04-19
  • 打赏
  • 举报
回复
晕,补补“计算机数学基础”吧!
icegirl914 2005-04-19
  • 打赏
  • 举报
回复
to: zy3481(远影孤帆)

什么叫插点算法
xsh525 2005-04-13
  • 打赏
  • 举报
回复
可是StretchBlt会使线条变粗啊?
fanqing 2005-04-13
  • 打赏
  • 举报
回复
StretchBlt可以缩放
xsh525 2005-04-13
  • 打赏
  • 举报
回复
那用坐标变换可以吗?
就是设置窗口,视口的范围可以吗?
inpriser 2005-04-13
  • 打赏
  • 举报
回复
自己写的函数,在OnDraw里调用
void PutViewPort(CDC* pDC)
{
if (m_NewCursorPoint!=m_OldCursorPoint)
{
m_CenterPointX += (long)((double)(m_OldCursorPoint.x-m_NewCursorPoint.x)/(double)m_ZoomScale);
m_CenterPointY += (long)((double)(m_OldCursorPoint.y-m_NewCursorPoint.y)/(double)m_ZoomScale);
m_NewCursorPoint=m_OldCursorPoint;
}

long tpWidth;
long tpHeight;
m_gpPicture->get_Width(&tpWidth);
m_gpPicture->get_Height(&tpHeight);
double pBL=((double)tpWidth)/((double)tpHeight);

RECT rc;
GetClientRect(&rc);

long vWidth=rc.right;
long vHeight=rc.bottom;
double vBL=((double)vWidth)/((double)vHeight);

long tvWidth;
long tvHeight;
if (pBL>vBL)
{
tvWidth=vWidth;
tvHeight=(long)((double)tvWidth/pBL);
}
else
{
tvHeight=vHeight;
tvWidth=(long)((double)tvHeight*pBL);
}

long trueWidth=(long)((double)tvWidth*m_ZoomScale);
long trueHeight=(long)((double)tvHeight*m_ZoomScale);

long trueX=(vWidth-trueWidth)/2-(long)((double)m_CenterPointX*m_ZoomScale);
long trueY=(vHeight-trueHeight)/2-(long)((double)m_CenterPointY*m_ZoomScale);

HDC hdc=pDC->GetSafeHdc();
m_gpPicture->Render(hdc,trueX,trueY,trueWidth,trueHeight,0,tpHeight,tpWidth,-tpHeight,&rc);

}
zy3481 2005-04-13
  • 打赏
  • 举报
回复
可以自己用插点算法写放大函数。
kidtty 2005-04-13
  • 打赏
  • 举报
回复
StretchBlt可以,放大就是使线条变粗.描述单个点的像素个数增加,所以会变粗.

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧