资源简介
数字图像二值化的源代码,比较简单,基于VC++实现
代码片段和文件信息
// dibapi.cpp
// Download by http://www.codefans.net
// Source file for Device-Independent Bitmap (DIB) API. Provides
// the following functions:
//
// PaintDIB() - Painting routine for a DIB
// CreateDIBPalette() - Creates a palette from a DIB
// FindDIBBits() - Returns a pointer to the DIB bits
// DIBWidth() - Gets the width of the DIB
// DIBHeight() - Gets the height of the DIB
// PaletteSize() - Gets the size required to store the DIB‘s palette
// DIBNumColors() - Calculates the number of colors
// in the DIB‘s color table
// CopyHandle() - Makes a copy of the given global memory block
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include “stdafx.h“
#include “dibapi.h“
#include
#include
#include
#include
/*
* Dib Header Marker - used in writing DIBs to files
*/
#define DIB_HEADER_MARKER ((WORD) (‘M‘ << 8) | ‘B‘)
/*************************************************************************
Function: ReadDIBFile (CFile&)
Purpose: Reads in the specified DIB file into a global chunk of
memory.
Returns: A handle to a dib (hDIB) if successful.
NULL if an error occurs.
Comments: BITMAPFILEHEADER is stripped off of the DIB. Everything
from the end of the BITMAPFILEHEADER structure on is
returned in the global memory handle.
*************************************************************************/
HDIB WINAPI ReadDIBFile(LPCTSTR pszFileName )
{
BITMAPFILEHEADER bmfHeader;
DWORD dwBitsSize;
HDIB hDIB;
LPSTR pDIB;
HANDLE hFile;
DWORD nBytesRead;
/*
* get length of DIB in bytes for use when reading
*/
hFile = CreateFile(
pszFileName // pointer to name of the file
GENERIC_READ // access (read-write) mode
FILE_SHARE_READ // share mode
NULL // pointer to security descriptor
OPEN_EXISTING // how to create
FILE_ATTRIBUTE_NORMAL // file attributes
NULL // handle to file with attributes to copy
);
dwBitsSize = GetFileSize(hFileNULL);
/*
* Go read the DIB file header and check if it‘s valid.
*/
// attempt an asynchronous read operation
if(! ReadFile(hFile (LPSTR)&bmfHeader sizeof(bmfHeader) &nBytesRead
NULL))
return NULL;
if (bmfHeader.bfType != DIB_HEADER_MARKER)
return NULL;
/*
* Allocate memory for DIB
*/
hDIB = (HDIB) ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT dwBitsSize);
if (hDIB == 0)
{
return NULL;
}
pDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
----------- --------- ---------- ----- ----
151969 33
- 上一篇:大数的加减乘除开方
- 下一篇:离散 合式公式 析取 合取转换
相关资源
- 用C语言进行数字图像处理
- Visual+C++数字图像处理-谢凤英-源代码
- VC++数字图像处理典型算法及实现
- Visual C++数字图像实用工程案例精选源
- 数字图像处理扑克牌识别程序
- 数字图像处理与机器视觉——Visual
- 中值滤波_均值滤波c语言实现_工程文
- 直方图均衡化_c语言实现_源代码+实验
- (VC++ 数字图像处理典型算法及实现源
- c语言实用数字图像处理
- 数字图像处理软件源代码三个资源集
- 数字图像处理实验源代码中值滤波,
- 数字图像处理的课程设计,图像处理
- 数字图像处理-基于内容的图像分类
- Visual C++数字图像识别技术典型案例
- VC6基于对话框的BMP灰度图片显示和轮
- 数字图像处理 MFC bmp格式图片打开与保
- Visual C++数字图像处理中文教程
- jpeg图片解码灰度二值化c语言实现
- C++数字图像处理典型算法及实现--图像
- C语言实用数字图像处理(日本的,看
- jbig二值图像压缩算法编码实现
- Visual C++数字图像获取、处理及实践应
- [毕业分享] MFC实现数字图像处理软件
- 书中-part2-1
- vc++ 数字图像处理典型算法及实现 源
- Visual C++数字图像处理谢凤英版源代码
- VC C++数字图像处理实验程序
- C语言实用数字图像处理_源代码code
- 数字图像处理MFC编程之灰度图像线性
川公网安备 51152502000135号
评论
共有 条评论