算法依赖的环境,动态库包括libtiff3.dll、jpeg62.dll、convert.dll、imgConv.dll。其中前两个从网上下载tiff、jpeg类后可以自动生成。后面两个类是Che同学给的,在此感谢他,我把这些类放到图片里面,如果能够上传就好了。CSDN做的真不够人性,不能添加附件。先试试。貌似没有成功。放到资源里面了大家可以免费下载。
我在MFC的CView类中实现函数的功能调用。
1)头文件
// ImgProcessView.h : CImgProcessView 类的接口
//
#pragma once
#include "ArdpsImg.h"
class CImgProcessDoc;
class CImgProcessView : public CScrollView
{
protected: // 仅从序列化创建
CImgProcessView();
DECLARE_DYNCREATE(CImgProcessView)
// 属性
public:
CImgProcessDoc* GetDocument() const;
// 操作
public:
CArdpsImg *pArdImg;
// 重写
public:
virtual void OnDraw(CDC* pDC); // 重写以绘制该视图
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // 构造后第一次调用
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
void OnRealizePal(WPARAM wParam, LPARAM lParam);
// 实现
public:
virtual ~CImgProcessView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnImgBinary();
public:
afx_msg void OnGrayMean();
public:
afx_msg void OnBinaryOtsu();
public:
afx_msg void OnBinaryMean();
public:
afx_msg void OnGrayMax();
public:
afx_msg void OnGrayStretch();
public:
afx_msg void OnGrayEqual();
public:
afx_msg void OnEliminateDirt();
public:
afx_msg void OnMakeWhite();
public:
afx_msg void OnBinaryGray();
public:
afx_msg void OnAutoBinary();
public:
afx_msg void OnRotateImg();
public:
afx_msg void OnAutoRotate();
public:
afx_msg void OnLightcontAdjust();
public:
afx_msg void OnZoom();
public:
afx_msg void OnOvlaodEqual();
public:
afx_msg void OnCutFrame();
public:
afx_msg void OnAdjustBinaryPos();
public:
afx_msg void OnColorAdjust();
public:
afx_msg void OnMergeImage();
};
#ifndef _DEBUG // ImgProcessView.cpp 中的调试版本
inline CImgProcessDoc* CImgProcessView::GetDocument() const
{ return reinterpret_cast<CImgProcessDoc*>(m_pDocument); }
#endif
2)源文件
// ImgProcessView.cpp : CImgProcessView 类的实现
//
#include "stdafx.h"
#include "ImgProcess.h"
#include "MainFrm.h"
#include "ImgProcessDoc.h"
#include "ImgProcessView.h"
#include "api/dibapi.h"
#include "ArdpsImg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CImgProcessView
IMPLEMENT_DYNCREATE(CImgProcessView, CScrollView)
BEGIN_MESSAGE_MAP(CImgProcessView, CScrollView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CScrollView::OnFilePrintPreview)