谁能给我一个拉框放大的算法
假设,正在显示一幅图片在缩放的过程中
已知当前图片的放大倍数,和图片左上角在实现区的坐标再拉框放大后,显示图片的左上角的坐标怎么算,我是越算越晕给点思路也好

解决方案 »

  1.   

    正在显示一幅图片在缩放的过程中
    这句话是什么意思?我没太看懂你的意思。但是如果只是2维,应该可以解决。ps ,你可以把原图另开一块内存备份。
    lpBackBits.
    在你需要复原的时候可以刷新就可以了。
      

  2.   

    可以按这个公式计算,那么你的背景对话框也可以这么算:
    图像X方向和Y方向的缩放比率分别为r1,r2,那么:
    [ x1 ]  [r1 0 0]   [ x0 ]
    | y1 | =|0 r2 0| * | y0 |
    [ 1  ]  [0  0 1]   [ 1  ]
      

  3.   

    在缩放前先将屏幕的中心点(P1)保存,
    然后进行缩放,
    最后再取得缩放后的屏幕中心点(P2),
    用P1-P2的偏移量移动屏幕原点坐标。
      

  4.   

    // 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_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);
    }