谁能给我一个拉框放大显示的算法 谁能给我一个拉框放大的算法假设,正在显示一幅图片在缩放的过程中已知当前图片的放大倍数,和图片左上角在实现区的坐标再拉框放大后,显示图片的左上角的坐标怎么算,我是越算越晕给点思路也好 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 正在显示一幅图片在缩放的过程中这句话是什么意思?我没太看懂你的意思。但是如果只是2维,应该可以解决。ps ,你可以把原图另开一块内存备份。lpBackBits.在你需要复原的时候可以刷新就可以了。 可以按这个公式计算,那么你的背景对话框也可以这么算:图像X方向和Y方向的缩放比率分别为r1,r2,那么:[ x1 ] [r1 0 0] [ x0 ]| y1 | =|0 r2 0| * | y0 |[ 1 ] [0 0 1] [ 1 ] 在缩放前先将屏幕的中心点(P1)保存,然后进行缩放,最后再取得缩放后的屏幕中心点(P2),用P1-P2的偏移量移动屏幕原点坐标。 // Zoom.h: interface for the CZoom class.////////////////////////////////////////////////////////////////////////#if !defined(AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_)#define AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000#include "Command.h"class CZoom : public CCommand {public: CZoom(bool bIsIn=true); int GetType(); void Cancel(); //取消命令 void OnRButtonDown(int nFlag, Point point); //按下鼠标右键 void OnLButtonDown(int nFlag, Point point); //按下鼠标左键 void OnLButtonDblClk(UINT nFlags, Point point); virtual ~CZoom();protected: bool m_bIsIn;};#endif // !defined(AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_)// Zoom.cpp: implementation of the CZoom class.////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "Drill.h"#include "Zoom.h"#ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE[]=__FILE__;#define new DEBUG_NEW#endif//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////CZoom::CZoom(bool bIsIn){ m_bIsIn = bIsIn; if (bIsIn) m_nCursorID = IDC_MAGNIFY; else m_nCursorID = IDC_SHRINK;}CZoom::~CZoom(){}void CZoom::OnLButtonDown(int nFlag, Point point){ CPoint ptSrc = g_pView->GetScreenPoint(point); //缩放之前的屏幕坐标 if (m_bIsIn) //改变倍率 g_pView->m_fScale /= 1.25; else g_pView->m_fScale *= 1.25; if (g_pView->m_fScale < 1/128 || g_pView->m_fScale > 64) g_pView->m_fScale = 1; CPoint ptDist = g_pView->GetScreenPoint(point); //缩放之后的屏幕坐标 CSize size = ptSrc - ptDist; //与原来位置的差距 g_pView->Offset(size); //移动屏幕}void CZoom::OnRButtonDown(int nFlag, Point point){ Cancel();}void CZoom::Cancel(){ m_bFinished = true; m_nStep = 0;}int CZoom::GetType(){ if (m_bIsIn) return CCommand::CT_MAGNIFY; else return CCommand::CT_SHRINK;}void CZoom::OnLButtonDblClk(UINT nFlags, Point point){ OnLButtonDown(nFlags, point);} 请问该如何进一步的学习 有关头文件调用顺序的问题 HOOK高手进来讨论一下Vista下的API HOOK DLL中的窗体加入一个Active X后,创建窗体失败 请问updatedata是什么具体意思啊 通过Invoke可以获得JavaScript定义的变量值吗? 求:代理服务器开发的例子或者参考资料 苍天啊、大地啊。。。。为什么别人的代码看起来毫不费力,自己写起来那么费劲? 请教多媒体软件高手 一个有关BITMAPINFO的问题 从数据库读出好友列表,如何一一填充到结构数组中,并发送给客户端? 读excel的文件的时候怎么会出现莫名其妙的空行???
这句话是什么意思?我没太看懂你的意思。但是如果只是2维,应该可以解决。ps ,你可以把原图另开一块内存备份。
lpBackBits.
在你需要复原的时候可以刷新就可以了。
图像X方向和Y方向的缩放比率分别为r1,r2,那么:
[ x1 ] [r1 0 0] [ x0 ]
| y1 | =|0 r2 0| * | y0 |
[ 1 ] [0 0 1] [ 1 ]
然后进行缩放,
最后再取得缩放后的屏幕中心点(P2),
用P1-P2的偏移量移动屏幕原点坐标。
//
//////////////////////////////////////////////////////////////////////#if !defined(AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_)
#define AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000#include "Command.h"class CZoom : public CCommand
{
public:
CZoom(bool bIsIn=true);
int GetType();
void Cancel(); //取消命令
void OnRButtonDown(int nFlag, Point point); //按下鼠标右键
void OnLButtonDown(int nFlag, Point point); //按下鼠标左键
void OnLButtonDblClk(UINT nFlags, Point point);
virtual ~CZoom();protected:
bool m_bIsIn;
};#endif // !defined(AFX_ZOOM_H__691B616A_261F_4215_AFAF_06B088AEEB30__INCLUDED_)// Zoom.cpp: implementation of the CZoom class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "Drill.h"
#include "Zoom.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CZoom::CZoom(bool bIsIn)
{
m_bIsIn = bIsIn;
if (bIsIn)
m_nCursorID = IDC_MAGNIFY;
else
m_nCursorID = IDC_SHRINK;
}CZoom::~CZoom()
{}void CZoom::OnLButtonDown(int nFlag, Point point)
{
CPoint ptSrc = g_pView->GetScreenPoint(point); //缩放之前的屏幕坐标 if (m_bIsIn) //改变倍率
g_pView->m_fScale /= 1.25;
else
g_pView->m_fScale *= 1.25;
if (g_pView->m_fScale < 1/128 || g_pView->m_fScale > 64)
g_pView->m_fScale = 1; CPoint ptDist = g_pView->GetScreenPoint(point); //缩放之后的屏幕坐标
CSize size = ptSrc - ptDist; //与原来位置的差距
g_pView->Offset(size); //移动屏幕
}void CZoom::OnRButtonDown(int nFlag, Point point)
{
Cancel();
}void CZoom::Cancel()
{
m_bFinished = true;
m_nStep = 0;
}int CZoom::GetType()
{
if (m_bIsIn)
return CCommand::CT_MAGNIFY;
else
return CCommand::CT_SHRINK;
}void CZoom::OnLButtonDblClk(UINT nFlags, Point point)
{
OnLButtonDown(nFlags, point);
}