资源简介
bp车牌识别源代码 基于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(BITMAPINFOHEADER) +
sizeof(RGBQUAD) * m_nColorTableEntries;
HANDLE hFile = ::CreateFile(strPathname
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 27252 2006-05-22 08:12 Photodeal\Bp.h
文件 15757 2001-11-22 02:37 Photodeal\cdib.cpp
文件 1851 2001-11-22 02:37 Photodeal\cdib.h
文件 64222 2001-11-22 02:37 Photodeal\ColorTable.h
文件 30237 2006-05-03 00:34 Photodeal\DIBAPI.CPP
文件 1819 2006-05-02 18:42 Photodeal\DIBAPI.H
文件 1122 2006-05-03 21:35 Photodeal\DlgBppara.cpp
文件 1267 2006-05-03 21:35 Photodeal\DlgBppara.h
文件 8764 2006-04-29 10:11 Photodeal\DlgEhance.cpp
文件 1661 2006-04-29 09:36 Photodeal\DlgEhance.h
文件 1032 2006-05-01 15:41 Photodeal\DlgInputinfo.cpp
文件 1251 2006-05-01 15:41 Photodeal\DlgInputinfo.h
文件 5048 2006-11-18 19:17 Photodeal\Dlgwhiteandblack.cpp
文件 1514 2006-04-29 11:22 Photodeal\Dlgwhiteandblack.h
文件 2510 2006-04-10 09:38 Photodeal\MainFrm.cpp
文件 1581 2006-04-10 09:38 Photodeal\MainFrm.h
文件 33540 2012-08-08 22:04 Photodeal\Photodeal.aps
文件 5190 2012-08-08 22:07 Photodeal\Photodeal.clw
文件 4263 2006-04-29 08:37 Photodeal\Photodeal.cpp
文件 4371 2006-05-09 10:59 Photodeal\Photodeal.dsp
文件 526 2006-04-29 08:37 Photodeal\Photodeal.dsw
文件 1389 2006-04-29 08:37 Photodeal\Photodeal.h
文件 246784 2012-08-08 22:07 Photodeal\Photodeal.ncb
文件 62976 2012-08-08 22:07 Photodeal\Photodeal.opt
文件 1357 2006-11-19 11:13 Photodeal\Photodeal.plg
文件 16314 2006-05-10 10:00 Photodeal\Photodeal.rc
文件 6309 2006-05-01 14:52 Photodeal\PhotodealDoc.cpp
文件 1756 2006-05-02 18:44 Photodeal\PhotodealDoc.h
文件 33929 2006-11-19 17:09 Photodeal\PhotodealView.cpp
文件 2632 2006-05-17 14:04 Photodeal\PhotodealView.h
............此处省略20个文件信息
- 上一篇:C++自动取款机ATM源代码
- 下一篇:计算图像的平均灰度值
评论
共有 条评论