图像预处理第9步:存为.bmp文件

//图像预处理第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=;
CRect rect,rectnew;
BYTE* lpDIB=(BYTE*)::GlobalLock ((HGLOBAL)m_hDIB);
BYTE* lpDIBBits=(BYTE*)::FindDIBBits ((char*)lpDIB);
BYTE* lpNewDIBBits;
BYTE* lpDst;
LONG lLineBytes=(digicount*w+)/*;
LONG lLineBytesnew =(w+)/*;
HDIB hDIB=NULL;
while(!m_charRect.empty ())
{
hDIB=::NewDIB (w,h,);
lpDIB=(BYTE*) ::GlobalLock((HGLOBAL)hDIB);
lpNewDIBBits = (BYTE*)::FindDIBBits((char*)lpDIB);
lpDst=(BYTE*)lpNewDIBBits;
memset(lpDst,(BYTE),lLineBytesnew * h);
rect=m_charRect.front ();
m_charRect.pop_front ();
for(i=;i<h;i++)
for(j=;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=;
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;
}
上一篇:Python自动化运维


下一篇:BUAA软件工程_软件案例分析