zoukankan      html  css  js  c++  java
  • GreenOpenPaint的实现(二)打开显示图片

    1、DOC中添加,核心图片文件保存在这里。之所以不用Mat,是因为CVVImage有更好的输入输出函数。

    我这里直接使用了public
    public:
        CvvImage m_image;
    2、重载打开
    //将文件的处理集中在DOC中是非常正确的方法
    BOOL CGreenOpenPaintDoc::OnOpenDocument(LPCTSTR lpszPathName)
    {
        if (!CDocument::OnOpenDocument(lpszPathName))
            return FALSE;
        m_image.Load(CT2CA(lpszPathName));
        //计算m_fScaleFactor
        m_fScaleFactor = ZOOM_NORMAL;
        return TRUE;
    }
    3、view中添加变量。主要添加头文件。
    private:
        CMainFramem_pParent;
        CGreenOpenPaintDocm_pDoc;
        CRect rectBackground;
    4、重构oninitupdate ,onupdate ,onDraw
    //初始化
    void CGreenOpenPaintView::OnInitialUpdate()
    {
        m_pParent = ((CMainFrame*)GetParentFrame());
        m_pDoc =((CGreenOpenPaintDoc*) GetDocument());
        OnUpdate(NULL, 0, NULL);
        CScrollView::OnInitialUpdate();
    }
     
    void CGreenOpenPaintView::OnUpdate(CViewpSenderLPARAM lHintCObjectpHint)
    {
        SetScrollSizes(MM_TEXT,
            CSize(int(m_pDoc->m_image.Width()*m_pDoc->m_fScaleFactor),
            int(m_pDoc->m_image.Height()*m_pDoc->m_fScaleFactor)));
     
        Invalidate();
    }
    现在已经可以打开图片,并且默认就是支持缩放的。而且支持滚动。
     





  • 相关阅读:
    springcloud-Netflix创建服务消费者
    Spring Cloud Zuul
    Spring Cloud 熔断器
    树莓派连接启动SSH
    win10红警黑屏和无法打开的处理
    创建索引和主键
    SQL语句增加字段、修改字段、修改类型、修改默认值
    SQL Server 事务隔离级别详解
    SQL Server数据库锁机制及类型
    SQL Server中的锁类型及用法
  • 原文地址:https://www.cnblogs.com/jsxyhelu/p/6353618.html
Copyright © 2011-2022 走看看