📄 tuxiang.cpp
字号:
#include "stdafx.h"
#include "comapi.h"
#include "imgprocDoc.h"
#include "imgprocView.h"
#include "dibapi.h"
#include "Resource.h"
#include "InDlg1.h"
#include "TemDlg.h"
void box0(CImgprocView* pView,void (*func)(unsigned char**,unsigned char**,unsigned ,unsigned))
{
unsigned short col,row;
unsigned char** uppimage;
unsigned char** outimage;
CImgprocDoc* pDoc =(CImgprocDoc*)(pView->GetDocument());
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
pView->BeginWaitCursor();
HDIB back=(HDIB)CopyHandle((HANDLE)hDIB);
uppimage=::DIBToArray(hDIB,col,row);
outimage=(unsigned char**)::fspace_2d(col,row,sizeof(unsigned char));
func(uppimage,outimage,row,col);
::ArrayToDIB(col,row,outimage,hDIB);
::ffree_2d((void**)outimage,col);
pView->myEditCopy();
pDoc->ReplaceHDIB(back);
// pDoc->SetModifiedFlag();
pView->SendMessage(WM_MYOWN);
pView->EndWaitCursor();
}
}
void box_0(CImgprocView* pView,void (*func)(unsigned char**,unsigned char**,int ,int))
{
unsigned short col,row;
unsigned char** uppimage;
unsigned char** outimage;
CImgprocDoc* pDoc =(CImgprocDoc*)(pView->GetDocument());
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
pView->BeginWaitCursor();
HDIB back=(HDIB)CopyHandle((HANDLE)hDIB);
uppimage=::DIBToArray(hDIB,col,row);
outimage=(unsigned char**)::fspace_2d(col,row,sizeof(unsigned char));
func(uppimage,outimage,row,col);
::ArrayToDIB(col,row,outimage,hDIB);
::ffree_2d((void**)outimage,col);
pView->myEditCopy();
pDoc->ReplaceHDIB(back);
// pDoc->SetModifiedFlag();
pView->SendMessage(WM_MYOWN);
pView->EndWaitCursor();
}
}
void box1(CImgprocView* pView,char* pstring,void (*func)(unsigned char**,unsigned char**,int ,int,int))
//template <class T>
//void box1(CImgprocView* pView,char* pstring,void (*func)(unsigned char**,unsigned char**,int ,int,T))
{
CInDlg1 dlg;
dlg.m_value=1;
dlg.m_text=pstring;
if(dlg.DoModal()==IDOK)
{
unsigned short col,row;
unsigned char** uppimage;
unsigned char** outimage;
CImgprocDoc* pDoc =(CImgprocDoc*)(pView->GetDocument());
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
pView->BeginWaitCursor();
HDIB back=(HDIB)CopyHandle((HANDLE)hDIB);
uppimage=::DIBToArray(hDIB,col,row);
outimage=(unsigned char**)::fspace_2d(col,row,sizeof(unsigned char));
func(uppimage,outimage,row,col,(int)dlg.m_value);
::ArrayToDIB(col,row,outimage,hDIB);
::ffree_2d((void**)outimage,col);
pView->myEditCopy();
pDoc->ReplaceHDIB(back);
// pDoc->SetModifiedFlag();
pView->SendMessage(WM_MYOWN);
pView->EndWaitCursor();
}
}
}
//////////////////该函数与其它函数不同,其中函数指针的最后两个参数含义不同
void box_1(CImgprocView* pView,void (*func)(unsigned char**,unsigned char**,unsigned char[7][7],int ,int))
{
CTemDlg dlg;
dlg.m_1_1=0; dlg.m_1_2=0; dlg.m_1_3=0; dlg.m_1_4=0;
dlg.m_1_5=0; dlg.m_1_6=0; dlg.m_1_7=0;
dlg.m_2_1=0; dlg.m_2_2=1; dlg.m_2_3=1; dlg.m_2_4=1;
dlg.m_2_5=1; dlg.m_2_6=1; dlg.m_2_7=0;
dlg.m_3_1=0; dlg.m_3_2=1; dlg.m_3_3=1; dlg.m_3_4=1;
dlg.m_3_5=1; dlg.m_3_6=1; dlg.m_3_7=0;
dlg.m_4_1=0; dlg.m_4_2=1; dlg.m_4_3=1; dlg.m_4_4=1;
dlg.m_4_5=1; dlg.m_4_6=1; dlg.m_4_7=0;
dlg.m_5_1=0; dlg.m_5_2=1; dlg.m_5_3=1; dlg.m_5_4=1;
dlg.m_5_5=1; dlg.m_5_6=1; dlg.m_5_7=0;
dlg.m_6_1=0; dlg.m_6_2=1; dlg.m_6_3=1; dlg.m_6_4=1;
dlg.m_6_5=1; dlg.m_6_6=1; dlg.m_6_7=0;
dlg.m_7_1=0; dlg.m_7_2=0; dlg.m_7_3=0; dlg.m_7_4=0;
dlg.m_7_5=0; dlg.m_7_6=0; dlg.m_7_7=0;
if(dlg.DoModal()==IDOK)
{
unsigned short col,row;
unsigned char** uppimage;
unsigned char** outimage;
unsigned char tmp[7][7];
tmp[0][0]=dlg.m_1_1; tmp[0][1]=dlg.m_1_2; tmp[0][2]=dlg.m_1_3; tmp[0][3]=dlg.m_1_4;
tmp[0][4]=dlg.m_1_5; tmp[0][5]=dlg.m_1_6; tmp[0][6]=dlg.m_1_7;
tmp[1][0]=dlg.m_2_1; tmp[1][1]=dlg.m_2_2; tmp[1][2]=dlg.m_2_3; tmp[1][3]=dlg.m_2_4;
tmp[1][4]=dlg.m_2_5; tmp[1][5]=dlg.m_2_6; tmp[1][6]=dlg.m_2_7;
tmp[2][0]=dlg.m_3_1; tmp[2][1]=dlg.m_3_2; tmp[2][2]=dlg.m_3_3; tmp[2][3]=dlg.m_3_4;
tmp[2][4]=dlg.m_3_5; tmp[2][5]=dlg.m_3_6; tmp[2][6]=dlg.m_3_7;
tmp[3][0]=dlg.m_4_1; tmp[3][1]=dlg.m_4_2; tmp[3][2]=dlg.m_4_3; tmp[3][3]=dlg.m_4_4;
tmp[3][4]=dlg.m_4_5; tmp[3][5]=dlg.m_4_6; tmp[3][6]=dlg.m_4_7;
tmp[4][0]=dlg.m_5_1; tmp[4][1]=dlg.m_5_2; tmp[4][2]=dlg.m_5_3; tmp[4][3]=dlg.m_5_4;
tmp[4][4]=dlg.m_5_5; tmp[4][5]=dlg.m_5_6; tmp[4][6]=dlg.m_5_7;
tmp[5][0]=dlg.m_6_1; tmp[5][1]=dlg.m_6_2; tmp[5][2]=dlg.m_6_3; tmp[5][3]=dlg.m_6_4;
tmp[5][4]=dlg.m_6_5; tmp[5][5]=dlg.m_6_6; tmp[5][6]=dlg.m_6_7;
tmp[6][0]=dlg.m_7_1; tmp[6][1]=dlg.m_7_2; tmp[6][2]=dlg.m_7_3; tmp[6][3]=dlg.m_7_4;
tmp[6][4]=dlg.m_7_5; tmp[6][5]=dlg.m_7_6; tmp[6][6]=dlg.m_7_7;
CImgprocDoc* pDoc =(CImgprocDoc*)(pView->GetDocument());
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
pView->BeginWaitCursor();
HDIB back=(HDIB)CopyHandle((HANDLE)hDIB);
uppimage=::DIBToArray(hDIB,col,row);
outimage=(unsigned char**)::fspace_2d(col,row,sizeof(unsigned char));
func(uppimage,outimage,tmp,/*row,col*/col,row);//此处不同
::ArrayToDIB(col,row,outimage,hDIB);
::ffree_2d((void**)outimage,col);
pView->myEditCopy();
pDoc->ReplaceHDIB(back);
// pDoc->SetModifiedFlag();
pView->SendMessage(WM_MYOWN);
pView->EndWaitCursor();
}
}
}
void box1(CImgprocView* pView,char* pstring,void (*func)(unsigned char**,unsigned char**,int ,int,float))
{
CInDlg1 dlg;
dlg.m_value=1;
dlg.m_text=pstring;
if(dlg.DoModal()==IDOK)
{
unsigned short col,row;
unsigned char** uppimage;
unsigned char** outimage;
CImgprocDoc* pDoc =(CImgprocDoc*)(pView->GetDocument());
HDIB hDIB = pDoc->GetHDIB();
if (hDIB != NULL)
{
pView->BeginWaitCursor();
HDIB back=(HDIB)CopyHandle((HANDLE)hDIB);
uppimage=::DIBToArray(hDIB,col,row);
outimage=(unsigned char**)::fspace_2d(col,row,sizeof(unsigned char));
func(uppimage,outimage,row,col,dlg.m_value);
::ArrayToDIB(col,row,outimage,hDIB);
::ffree_2d((void**)outimage,col);
pView->myEditCopy();
pDoc->ReplaceHDIB(back);
// pDoc->SetModifiedFlag();
pView->SendMessage(WM_MYOWN);
pView->EndWaitCursor();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -