我现在做了一个gis绘图软件,其中关于怎么实现拉框放大的问题不懂了。请各位高手指教!!!                        谢谢    基本实现思路是,我在绘制图形的区域中用鼠标拉个矩形框,然后把这个矩形框中的图形扩大到整个绘图区域,这样就可以实现放大效果了。

解决方案 »

  1.   

    BOOL StretchBlt(
      HDC hdcDest,      // handle to destination DC
      int nXOriginDest, // x-coord of destination upper-left corner
      int nYOriginDest, // y-coord of destination upper-left corner
      int nWidthDest,   // width of destination rectangle
      int nHeightDest,  // height of destination rectangle
      HDC hdcSrc,       // handle to source DC
      int nXOriginSrc,  // x-coord of source upper-left corner
      int nYOriginSrc,  // y-coord of source upper-left corner
      int nWidthSrc,    // width of source rectangle
      int nHeightSrc,   // height of source rectangle
      DWORD dwRop       // raster operation code
    );
      

  2.   

    float QZoomView::ZoomTo(float zoom)
    {
    #ifdef _DEBUG
    if (m_nMapMode == MM_NONE)
    {
    TRACE(_T("Error: must call SetScrollSizes() before calling ZoomTo.\n"));
    ASSERT(FALSE);
    return 1.0f;
    }
    #endif //_DEBUG if (zoom < ZOOM_MIN) zoom = ZOOM_MIN;
    else if (zoom > ZOOM_MAX) zoom = ZOOM_MAX; TRACE1(_T("Zoom factor = %f\n"), zoom); float prevZoom = m_Zoom; if (m_Zoom != zoom)
    {
    m_Zoom = zoom; CClientDC dc(this);
    OnPrepareDC(& dc); m_totalDev = m_totalLog;
    dc.LPtoDP(& m_totalDev); m_pageDev.cx = m_totalDev.cx / 10;
    m_pageDev.cy = m_totalDev.cy / 10;
    m_lineDev.cx = m_pageDev.cx / 10;
    m_lineDev.cy = m_pageDev.cy / 10; UpdateBars();
    OnZoom(zoom, prevZoom);
    Invalidate();
    }
    m_WheelDelta = 0;
    return prevZoom;
    }void QZoomView::ZoomToRectangle(CRect logRect)
    {
    CRect rcClient;
    GetClientRect(rcClient); // Compensate for scrollbars after zooming
    DWORD dwStyle = GetStyle(); CSize szSB;
    GetScrollBarSizes(szSB); if(!(dwStyle & WS_VSCROLL))
    rcClient.right -= szSB.cx;
    if(!(dwStyle & WS_HSCROLL))
    rcClient.bottom -= szSB.cy; CRect devRect(logRect); // Original mapmode gives 100% zoom
    CClientDC dc(this);
    dc.SetMapMode(m_nMapMode); // Rect for 100% zoom in device coordinates:
    dc.LPtoDP(devRect);
    devRect.NormalizeRect(); // We need to compare devRect.Width()/rcClient.right to devRect.Height()/rcClient.bottom.
    // Give them common denominators and compare just the numerators (assume all
    // numbers are positive):
    int nx = devRect.Width() * rcClient.bottom;
    int ny = devRect.Height() * rcClient.right; float zoom;
    if (nx < ny)
    {
    if (devRect.Width() < rcClient.right)
    rcClient.bottom += szSB.cy;
    // We probably don't need a horizontal scrollbar,
    // but we can't be sure. // -1 compensates for roundof errors
    zoom = (float)(rcClient.bottom - 1) /(float)devRect.Height();
    }
    else
    {
    if (devRect.Height() < rcClient.bottom)
    rcClient.right += szSB.cx;
    zoom = (float)(rcClient.right - 1) / (float)devRect.Width();
    }
    ZoomTo(zoom);
    m_PresetIndex = -1;
    }
      

  3.   

    如果放大缩小时不让线条变宽字体跟着就大可以直接用坐标变换来实现。
    若要字体相应变大,线相应变宽就用CDC的SetViewportExt(),SetViewportOrg()来实现。
      

  4.   

    在dc中用stretchblt,把圈选的内容放大到全屏............
      

  5.   


    我觉得做GIS应该采用这种方法比较好吧,不但容易实现,而且不用在内存中建立很大的位图来往屏幕上贴。