Win7下的MSPaint是Ribbon的典型运行。这种SDI程序对于图像处理来说是很适合的。利用春节时间,基于之前的积累,我实现GreenOpenPaint,主要就是模拟MSPaint的界面,实现出现处理的结果。
知识要点:
1、MFC下SDI程序设计;
2、Opencv和MFC SDI的融合;
3、标尺;
4、图像缩放。
一、界面设计、功能设计
下面两图是mspaint的界面
其中:
红框是图像和区域的选择和粘贴。这个对于图像处理可能有用。但是现在不实现;
绿框是画图的操作,对于图像处理来说没有用,不实现;
黄框是主要显示区域,有用,实现;
蓝框是缩放区域,有用实现。
为了扁平操作,所有选项都在一个界面中出现。


准备图标,并做成banner
二、RIBBON框架,主要地方截图





导入图标和banner,设置界面。注意工具条的高度是32,所以在设置图片的时候也要注意这一点。完成界面

三、将需要的文件和库引入
cvvimage用于显示图像,这里用的是我修改过的cvvimage
ruler用于显示标尺,这里引入的也是我修改过的。
引入Opencv;
stdafx.h添加全局常量
// 新添加
#include "CvvImage.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
//100DPI代表1英寸=100像素 ,已知 1英寸= 2.54厘米,得1像素=0.0254厘米
//TODO 自动获得DPI
#define DPICM 0.0254
#define DPIMM 0.254
#define ZOOM_MAX 4
#define ZOOM_MIN 0.125
#define ZOOM_NORMAL 1
修改编译器兼容问题

http://files.cnblogs.com/files/jsxyhelu/GreenOpenPaint01.rar