• 大小: 85KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签: 图像分割  

资源简介

图像分割 图像分割 图像分割 图像分割 图像分割 图像分割 图像分割 图像分割

资源截图

代码片段和文件信息

// 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 err?
m_lpImage=(LPBYTE) new char[((long int) size.cx)*size.cy];
m_nImageAlloc = crtAlloc;
}

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
BOOL CDib::AttachMapFile(const TCHAR* 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(_T(“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(_T(“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 TCHAR* 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_n

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2010-07-01 10:22  图像分割\
     文件       16645  2008-02-19 21:22  图像分割\cdib.cpp
     文件        1948  2008-02-19 21:22  图像分割\cdib.h
     文件       28868  2010-01-08 23:24  图像分割\DivideImage.aps
     文件        2388  2010-01-08 23:28  图像分割\DivideImage.clw
     文件        4299  2009-10-04 23:30  图像分割\DivideImage.cpp
     文件        4780  2009-10-04 23:39  图像分割\DivideImage.dsp
     文件         547  2009-10-04 23:30  图像分割\DivideImage.dsw
     文件        1411  2009-10-04 23:30  图像分割\DivideImage.h
     文件       91136  2010-01-08 23:30  图像分割\DivideImage.ncb
     文件       54784  2010-01-08 23:30  图像分割\DivideImage.opt
     文件        2087  2010-01-08 23:24  图像分割\DivideImage.plg
     文件       11754  2009-10-04 23:38  图像分割\DivideImage.rc
     文件        1996  2009-10-04 23:35  图像分割\DivideImageDoc.cpp
     文件        1561  2009-10-04 23:32  图像分割\DivideImageDoc.h
     文件        4118  2009-10-05 00:18  图像分割\DivideImageView.cpp
     文件        1899  2009-10-05 00:05  图像分割\DivideImageView.h
     文件        2512  2009-10-04 23:30  图像分割\MainFrm.cpp
     文件        1581  2009-10-04 23:30  图像分割\MainFrm.h
     文件        4431  2009-10-04 23:30  图像分割\ReadMe.txt
     目录           0  2010-06-30 09:39  图像分割\res\
     文件         645  2009-10-04 23:38  图像分割\resource.h
     文件        1078  2009-10-04 23:30  图像分割\res\DivideImage.ico
     文件         403  2009-10-04 23:30  图像分割\res\DivideImage.rc2
     文件        1078  2009-10-04 23:30  图像分割\res\DivideImageDoc.ico
     文件        1078  2009-10-04 23:30  图像分割\res\Toolbar.bmp
     文件         213  2009-10-04 23:30  图像分割\StdAfx.cpp
     文件        1054  2009-10-04 23:30  图像分割\StdAfx.h
     文件       44593  2010-06-30 10:02  图像分割\Visual C++.jpg

评论

共有 条评论