求MFC中打开BMP,并能进行二值化处理程序

2024-12-04 23:45:02
推荐回答(1个)
回答1:

3.16 icePub_imgToSingleBmp

l 函数原型:
int WINAPI icePub_imgToSingleBmp(char *strImgFilename,char *strBmpFilename,int thresholdValue)
输入:strImgFilename 待处理图像文件名
strBmpFilename bmp图像名
thresholdValue 256级灰度值的阈值(函数会先将图像转换成灰度再根据thresholdValue做黑白2值化)
输出:

l VC连接Lib方式声明
__declspec(dllexport)
int WINAPI icePub_imgToSingleBmp(char *strImgFilename,char *strBmpFilename,int thresholdValue);

l 动态调用例程
VC sample代码:

typedef int (WINAPI ICEPUB_IMGTOSINGLEBMP)(char *strImgFilename,char *strBmpFilename,int thresholdValue);
ICEPUB_IMGTOSINGLEBMP *icePub_imgToSingleBmp = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
{
icePub_imgToSingleBmp=(ICEPUB_IMGTOSINGLEBMP *)GetProcAddress(hDLLDrv,"icePub_imgToSingleBmp");
}
if(icePub_imgToSingleBmp)
{
icePub_imgToSingleBmp("my24.bmp","single1.bmp",150);
icePub_imgToSingleBmp("my.jpg","single2.bmp",150);
icePub_imgToSingleBmp("my.png","single3.bmp",150);
}

if(hDLLDrv)
FreeLibrary(hDLLDrv);

http://dl.icese.net/dev.php?f=icePubDll.rar 下载