//image preprocessing The 9th step: The final standardized character image is divided into a single single Hdib saved, coexisting as a. bmp filevoidCchildview::onimgprctodibandsave () {unsignedChar*lpsrc; intw,h; W=M_charrect.front (). Width (); H=M_charrect.front (). Height (); M_dibrect.clear (); M_dibrectcopy.clear (); inti_src,j_src; inti,j; intcounts=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) 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; //output to a. bmp fileCString 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;}
Image preprocessing step 9th: Save as a. bmp file