图像预处理第9步:存为.bmp文件
2016-04-19 17:08
465 查看
//图像预处理第9步:将最终标准化后的字符图像分为单个单个的HDIB保存,并存为.bmp文件 void CChildView::OnImgprcToDibAndSave() { unsigned char* lpSrc; int w,h; w=m_charRect.front ().Width() ; h=m_charRect.front ().Height() ; m_dibRect.clear (); m_dibRectCopy.clear (); int i_src,j_src; int i,j; int counts=0; CRect rect,rectnew; BYTE* lpDIB=(BYTE*)::GlobalLock ((HGLOBAL)m_hDIB); BYTE* lpDIBBits=(BYTE*)::FindDIBBits ((char*)lpDIB); BYTE* lpNewDIBBits; BYTE* lpDst; LONG lLineBytes=(digicount*w+3)/4*4; LONG lLineBytesnew =(w+3)/4*4; HDIB hDIB=NULL; while(!m_charRect.empty ()) { hDIB=::NewDIB (w,h,8); lpDIB=(BYTE*) ::GlobalLock((HGLOBAL)hDIB); lpNewDIBBits = (BYTE*)::FindDIBBits((char*)lpDIB); lpDst=(BYTE*)lpNewDIBBits; memset(lpDst,(BYTE)255,lLineBytesnew * h); rect=m_charRect.front (); m_charRect.pop_front (); for(i=0;i<h;i++) for(j=0;j<w;j++) { i_src=rect.top + i; j_src=j+counts*w; lpSrc=(BYTE *)lpDIBBits + lLineBytes * i_src + j_src; lpDst=(BYTE *)lpNewDIBBits + lLineBytesnew * i + j; *lpDst=*lpSrc; } ::GlobalUnlock (hDIB); m_dibRect.push_back (hDIB); counts++; } m_charRect=m_charRectCopy; m_dibRectCopy=m_dibRect; //输出为.bmp文件 CString str; counts=1; while(!m_dibRect.empty ()) { str.Format ("part%d.bmp",counts); //str=strPath+"\\"+str; CFile file(str, CFile::modeReadWrite|CFile::modeCreate); hDIB=m_dibRect.front (); ::SaveDIB (hDIB,file); m_dibRect.pop_front (); file.Close (); counts++; } m_dibRect=m_dibRectCopy; }
相关文章推荐
- 工程师离不开的那些电路设计工具 干货get√
- Eclipse 出现的问题总结
- java 对redis 的基本操作
- 用python进行科学统计及数据挖掘--便捷工具环境搭建
- php日记——获取当天产生的数据(比较日期)
- Android adb 命令
- NPOI使用手册
- warning C4819 解决方案 warning C4819: The file contains a character that cannot be represented in the cu
- Bundle研究
- 关于JAVA取本机ip的一些传说
- iOS根据日期、数值给model排序
- Java基础--反射、内省
- JAVA虚拟机之二:Java体系结构
- JAVA虚拟机之三:CMS垃圾收集器
- 考C1科目三历程
- Listener监听在线用户数量
- hdu2444The Accomodation of Students【判断二分图+最大匹配】
- MongoDB数据量较大时如何构建索引--减少业务最少影响
- grails框架数据查询
- Remove Duplicates from Sorted List