資源簡介
C語言編寫的腐蝕膨脹開閉運算算法,比較簡單,適合入門

代碼片段和文件信息
//////////////////////////////////////////////////////////////
//Name:morph.c
//Purpose:?To?perform?morphological?operation
//Author:?phoenix?CS?TshingHua?Beijing?P.R.C.
//Email:?bjlufengjun@www.163.net?or?lufengjun@hotmail.com
//Date:April?3?1998
//header?file
#include?“bmp.h“
#include?“memory.h“
#include?“math.h“
#include?“stdio.h“
//owner?defined?stack
typedef?struct{
??HGLOBAL?hMem;
?? ??POINT?*lpMyStack;
??LONG??ElementsNum;
??LONG??ptr;
??}MYSTACK;
//macro?definition
#define?WIDTHBYTES(i)????((i+31)/32*4)
#define?PI?3.1415926535
#define?RADIAN(angle)?((angle)*PI/180.0)?//convert?angle?to?radian
//function?declaration
int?PASCAL?WinMain?(HANDLE?HANDLE?LPSTR?int);
LRESULT?CALLBACK?MainWndProc(HWND??UINTWPARAM?LPARAM);
BOOL?LoadBmpFile?(HWND?hWndchar?*BmpFileName);
BOOL?Dilation(HWND?hWndBOOL?Hori);
BOOL?Erosion(HWND?hWndBOOL?Hori);
BOOL?MorphOpen(HWND?hWndBOOL?Hori);
BOOL?MorphClose(HWND?hWndBOOL?Hori);
BOOL?Thinning(HWND?hWnd);
//global?variable?declaration
BITMAPFILEHEADER???bf;
BITMAPINFOHEADER???bi;
HPALETTE???????????hPalette=NULL;
HBITMAP????????????hBitmap=NULL;
HGLOBAL????????????hImgData=NULL;
DWORD??????????????NumColors;
DWORD??????????????LineBytes;
HINSTANCE??????????ghInst;
DWORD??????????????ImgWidth=0??ImgHeight=0;
///////////////////////////////////////////////////////////
int?PASCAL?WinMain?(HANDLE?hInstance?HANDLE?hPrevInstance
????LPSTR?lpszCmdLine?int?nCmdShow)
{
MSG???????msg;
WNDCLASS??wndclass;
HWND??????hWnd;
ghInst=hInstance;
if?(?!?hPrevInstance?){
wndclass.style?=?CS_HREDRAW?|?CS_VREDRAW;
wndclass.lpfnWndProc?=?MainWndProc;
wndclass.cbClsExtra?=?0;
wndclass.cbWndExtra?=?0;
wndclass.hInstance?=?hInstance;
wndclass.hIcon?=?LoadIcon?(NULL?IDI_APPLICATION);
wndclass.hCursor?=?LoadCursor?(NULL?IDC_ARROW);
wndclass.hbrBackground?=?GetStockobject?(WHITE_BRUSH);
wndclass.lpszMenuName?=??“BMPMENU“;
wndclass.lpszClassName?=?“phoenix?ip?system“;
????}
????if?(?!?RegisterClass?(&wndclass)?)
return?FALSE;
?
hWnd?=?CreateWindow?(“phoenix?ip?system““Morphological?operation“
?WS_OVERLAPPEDWINDOWCW_USEDEFAULTCW_USEDEFAULT
?CW_USEDEFAULT CW_USEDEFAULT?NULLNULL
?hInstance NULL);
if?(!hWnd)
return?FALSE;
ShowWindow?(hWnd?SW_SHOWMAXIMIZED);
UpdateWindow?(hWnd);
while?(?GetMessage?(&msg?NULL?0?0)?){
TranslateMessage?(&msg);
DispatchMessage?(&msg);
????}
return?msg.wParam;
}
////////////////////////////////////////////////////////////////
LRESULT?CALLBACK?MainWndProc(HWND?hWnd?UINT?messageWPARAM?wParam?LPARAM?lParam)
{
????static??HDC????hDChMemDC;
????PAINTSTRUCT????ps;
????switch?(message){
????case?WM_PAINT:
{?????????
hDC?=?BeginPaint(hWnd?&ps);
if?(hBitmap)
{?
hMemDC?=?CreateCompatibleDC(hDC);
if?(hPalette)
{???????????
SelectPalette?(hDC?hPalette?FALSE);?
SelectPalette?(hMemDC?hPalette?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????547??1998-04-17?20:10??Bmp.h
?????文件????????1169??1998-04-17?20:10??Bmp.rc
?????文件???????28596??1998-04-21?09:37??morph.c
?????文件???????29696??1998-04-21?14:34??morph.exe
?????文件?????????155??2000-06-11?09:44??readme.txt
- 上一篇:MFC多標簽仿Chorme瀏覽器Demo
- 下一篇:huichang.cpp
評論
共有 條評論