我做了单文档的显示一些线条的程序,怎么让文档局部缩放?
谢谢

解决方案 »

  1.   

    说个简单的方法吧:图片都是由一系列的点组成的,每个点由3个值组成(RGB),你把每个点和它周围的点(如右边的一个)取相同的RGB值,那你放大100个点的图片,现在就成了200个点了,图片也放大了2倍了。呵呵...
    至于缩小嘛,没做过,不敢乱说,也许去掉每个点右边的那个点可以。
      

  2.   

    StretchBlt() 函数是用于图像放大缩小的,具体怎么用 记不清了
    建议楼主 去查一下msdn
      

  3.   

    网上找的
    用CDC的StretchBlt实现图像放大镜,主要有以下功能:1.移动MOUSE放大显示图像的不
    同部位,2.左击增加放大倍率,3.右击减少放大倍率。 当放大倍率较大时产生抖动。 
    ---- 实现过程: ---- 1.使用AppWizard生成SDI应用IMAGE。 ---- 2.为CImageView增加以下成员数据: CSize m_sizeDest;
    CSize m_sizeSource;
    CBitmap * m_pBitmap;
    CDC * m_pdcMem;
    int oldx,oldy,s,d; file://s确定被放大区域,
    d确定放大显示区域,放大倍率=d/s
    bool recover;
    long mana;---- 3.在资源中加入自己喜欢的位图并设为IDB_BITMAP1。 ---- 4.对CImageView的以下消息编程: CImageView::CImageView()
    {
    // Initialize values
    m_pdcMem = new CDC;
    m_pBitmap = new CBitmap;
    recover = true;
    s = 30; d = 45; 
    mana = SRCCOPY;
    }CImageView::~CImageView()
    {
    delete m_pdcMem;
    delete m_pBitmap;
    }void CImageView::OnDraw(CDC* pDC)
    {
    static bool load;
    if (!load) {
    BITMAP bm;
    load = !load;
    m_pBitmap- >LoadBitmap(IDB_BITMAP1);
    m_pdcMem- >CreateCompatibleDC(pDC);
    m_pdcMem- >SelectObject(m_pBitmap);
    m_pBitmap- >GetObject(sizeof(bm),&bm);
    m_sizeSource.cx = bm.bmWidth;
    m_sizeSource.cy = bm.bmHeight;
    m_sizeDest = m_sizeSource;
    pDC- >StretchBlt(0,0,m_sizeSource.cx,m_sizeSource.cy,
    m_pdcMem,0,0,m_sizeSource.cx,m_sizeSource.cy,mana);
    }
    else {
    pDC- >StretchBlt(0,0,m_sizeSource.cx,m_sizeSource.cy,
    m_pdcMem,0,0,m_sizeSource.cx,m_sizeSource.cy,mana);
    }
    }
    void CImageView::OnMouseMove(UINT nFlags, CPoint point) 
    {
    CString cord;
    int dd;
    CRect srect,drect,mrect;
    CMainFrame * pFrame = (CMainFrame *)AfxGetApp()- >m_pMainWnd ;
    CStatusBar * pStatus = &pFrame- >m_wndStatusBar ;
    if (pStatus)
    {
    cord.Format("X = %d, Y = %d",point.x,point.y);
    pStatus- >SetPaneText (1,cord);
    srect.left = point.x - s;
    srect.top = point.y - s;
    srect.right = point.x + s;
    srect.bottom = point.y + s;drect.left = point.x - d;
    drect.top = point.y - d;
    drect.right = point.x + d;
    drect.bottom = point.y + d;mrect.left = oldx - d;
    mrect.top = oldy - d;
    mrect.right = oldx + d;
    mrect.bottom = oldy + d;
    dd = 2*d;
    CDC * pDC = GetDC();
    OnPrepareDC(pDC);
    if (recover)
    {
    pDC- >BitBlt(mrect.left,mrect.top,dd,dd,
    m_pdcMem,mrect.left,mrect.top,mana);
    }
    pDC- >StretchBlt(drect.left,drect.top,
    drect.Width(),drect.Height(),m_pdcMem,srect.left,
    srect.top,srect.Width(),srect.Height(),SRCCOPY);
    oldx = point.x; oldy = point.y;
    ReleaseDC(pDC);
    }
    recover = true;
    CView::OnMouseMove(nFlags, point);
    }void CImageView::OnRButtonDown(UINT nFlags, CPoint point) 
    {
    if (d > 5) 
    {
    CDC * pDC = GetDC();
    pDC- >StretchBlt(oldx - d,oldy - d,2*d,
    2*d,m_pdcMem,oldx - d,oldy - d,2*d,2*d,mana);
    d -= 10;
    ReleaseDC(pDC);
    CImageView::OnMouseMove(nFlags, point);

    CView::OnRButtonDown(nFlags, point);
    }void CImageView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    if (d < 150) 
    {
    d += 10; 
    CImageView::OnMouseMove(nFlags, point);
    }
    CView::OnLButtonDown(nFlags, point);
    }
      

  4.   

    根据放大的比例,算出点对应的坐标,
    你的应该是点线图,
    strech是对图象处理的,对你的程序好像不太适用,
    代码没有!