資源簡介
該文件可實現對手勢二值圖的輪廓跟蹤,并且提取手勢輪廓圖的傅立葉描述子提取,VC++6.0運行成功。

代碼片段和文件信息
//?cdib.cpp
//?new?version?for?WIN32
#include?“stdafx.h“
#include?“cdib.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
IMPLEMENT_SERIAL(CDib?Cobject?0);
CDib::CDib()
{
m_hFile?=?NULL;
m_hBitmap?=?NULL;
m_hPalette?=?NULL;
m_nBmihAlloc?=?m_nImageAlloc?=?noAlloc;
Empty();
}
CDib::CDib(CSize?size?int?nBitCount)
{
m_hFile?=?NULL;
m_hBitmap?=?NULL;
m_hPalette?=?NULL;
m_nBmihAlloc?=?m_nImageAlloc?=?noAlloc;
Empty();
ComputePaletteSize(nBitCount);
m_lpBMIH?=?(LPBITMAPINFOHEADER)?new?
char[sizeof(BITMAPINFOHEADER)?+?sizeof(RGBQUAD)?*?m_nColorTableEntries];
m_nBmihAlloc?=?crtAlloc;
m_lpBMIH->biSize?=?sizeof(BITMAPINFOHEADER);
m_lpBMIH->biWidth?=?size.cx;
m_lpBMIH->biHeight?=?size.cy;
m_lpBMIH->biPlanes?=?1;
m_lpBMIH->biBitCount?=?nBitCount;
m_lpBMIH->biCompression?=?BI_RGB;
m_lpBMIH->biSizeImage?=?0;
m_lpBMIH->biXPelsPerMeter?=?0;
m_lpBMIH->biYPelsPerMeter?=?0;
m_lpBMIH->biClrUsed?=?m_nColorTableEntries;
m_lpBMIH->biClrImportant?=?m_nColorTableEntries;
ComputeMetrics();
memset(m_lpvColorTable?0?sizeof(RGBQUAD)?*?m_nColorTableEntries);
m_lpImage?=?NULL;??//?no?data?yet
}
CDib::~CDib()
{
Empty();
}
CSize?CDib::GetDimensions()
{
if(m_lpBMIH?==?NULL)?return?CSize(0?0);
return?CSize((int)?m_lpBMIH->biWidth?(int)?m_lpBMIH->biHeight);
}
BOOL?CDib::AttachMapFile(const?char*?strPathname?BOOL?bShare)?//?for?reading
{
//?if?we?open?the?same?file?twice?Windows?treats?it?as?2?separate?files
//?doesn‘t?work?with?rare?BMP?files?where?#?palette?entries?>?biClrUsed
HANDLE?hFile?=?::CreateFile(strPathname?GENERIC_WRITE?|?GENERIC_READ
bShare???FILE_SHARE_READ?:?0
NULL?OPEN_EXISTING?FILE_ATTRIBUTE_NORMAL?NULL);
ASSERT(hFile?!=?INVALID_HANDLE_VALUE);
DWORD?dwFileSize?=?::GetFileSize(hFile?NULL);
HANDLE?hMap?=?::CreateFileMapping(hFile?NULL?PAGE_READWRITE?0?0?NULL);
DWORD?dwErr?=?::GetLastError();
if(hMap?==?NULL)?{
AfxMessageBox(“Empty?bitmap?file“);
return?FALSE;
}
LPVOID?lpvFile?=?::MapViewOfFile(hMap?FILE_MAP_WRITE?0?0?0);?//?map?whole?file
ASSERT(lpvFile?!=?NULL);
if(((LPBITMAPFILEHEADER)?lpvFile)->bfType?!=?0x4d42)?{
AfxMessageBox(“Invalid?bitmap?file“);
DetachMapFile();
return?FALSE;
}
AttachMemory((LPBYTE)?lpvFile?+?sizeof(BITMAPFILEHEADER));
m_lpvFile?=?lpvFile;
m_hFile?=?hFile;
m_hMap?=?hMap;
return?TRUE;
}
BOOL?CDib::CopyToMapFile(const?char*?strPathname)
{
//?copies?DIB?to?a?new?file?releases?prior?pointers
//?if?you?previously?used?CreateSection?the?HBITMAP?will?be?NULL?(and?unusable)
BITMAPFILEHEADER?bmfh;
bmfh.bfType?=?0x4d42;??//?‘BM‘
bmfh.bfSize?=?m_dwSizeImage?+?sizeof(BITMAPINFOHEADER)?+
sizeof(RGBQUAD)?*?m_nColorTableEntries?+?sizeof(BITMAPFILEHEADER);
//?meaning?of?bfSize?open?to?interpretation
bmfh.bfReserved1?=?bmfh.bfReserved2?=?0;
bmfh.bfOffBits?=?sizeof(BITMAPFILEHEADER)?+?sizeof(BITMAPINFOHEADE
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4804??2008-05-28?12:30??fuliye\fuliye.dsp
?????文件??????54784??2008-07-25?15:06??fuliye\fuliye.opt
?????文件???????2952??2008-07-25?15:06??fuliye\fuliye.clw
?????文件???????4766??2008-05-23?16:22??fuliye\ReadMe.txt
?????文件??????13432??2008-07-25?09:05??fuliye\fuliye.rc
?????文件???????1054??2008-05-23?16:22??fuliye\StdAfx.h
?????文件????????208??2008-05-23?16:22??fuliye\StdAfx.cpp
?????文件???????1542??2008-05-23?16:22??fuliye\MainFrm.h
?????文件???????2523??2008-05-23?16:22??fuliye\MainFrm.cpp
?????文件???????1397??2008-05-23?16:22??fuliye\ChildFrm.h
?????文件???????1533??2008-05-23?16:22??fuliye\ChildFrm.cpp
?????文件???????1968??2008-05-23?16:22??fuliye\fuliyeView.h
?????文件????????535??2008-05-23?16:22??fuliye\fuliye.dsw
?????文件?????181248??2008-07-25?15:06??fuliye\fuliye.ncb
?????文件???????2012??2008-01-09?10:28??fuliye\cdib.h
?????文件??????16576??2008-03-07?21:29??fuliye\cdib.cpp
?????文件????????246??2008-07-25?15:05??fuliye\fuliye.plg
?????文件???????3008??2008-05-23?16:26??fuliye\fuliyeView.cpp
?????文件??????45328??2008-07-25?09:05??fuliye\fuliye.aps
?????文件????????781??2008-07-24?16:32??fuliye\Resource.h
?????文件??????33902??2008-07-24?21:13??fuliye\fuliyeDoc.cpp
?????文件????????398??2008-05-23?16:22??fuliye\res\fuliye.rc2
?????文件???????1078??2008-05-23?16:22??fuliye\res\fuliyeDoc.ico
?????文件???????1078??2008-05-23?16:22??fuliye\res\fuliye.ico
?????文件???????1198??2008-07-24?09:06??fuliye\res\Toolbar.bmp
?????文件???????1382??2008-07-24?15:17??fuliye\fuliye.h
?????文件???????7109??2008-07-24?15:20??fuliye\fuliye.cpp
?????文件???????1600??2008-07-24?16:30??fuliye\fuliyeDoc.h
?????目錄??????????0??2008-06-02?10:29??fuliye\Debug
?????目錄??????????0??2008-06-02?10:29??fuliye\res
............此處省略5個文件信息
- 上一篇:C++中國象棋人機下棋 高智商版
- 下一篇:二叉樹c++源代碼實現查找,刪除,插入等
評論
共有 條評論