日期:2014-05-18 浏览次数:21406 次
private void btnTest_Click(object sender , EventArgs e)
{
    MODI.Document md = new MODI.Document();
    // The Create method grabs the picture from disk snd prepares for OCR.Create
    string strFileName = Environment.CurrentDirectory + "\\temp484.tif";
    md.Create(strFileName);
    // Do the OCR
    [color=#FF0000][b]//断点跟踪到这里报错
    md.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_TRADITIONAL , false , false);[/b][/color]    //lx120715
    // This string will contain the text.
    string strText = String.Empty;
    // Get the first (and only image)
    MODI.Image image = (MODI.Image) md.Images[0];
    // Get the layout
    MODI.Layout layout = image.Layout;
    // Loop through the words.
    for (int j = 0 ; j < layout.Words.Count ; j++)
    {
        // Get this word.
        MODI.Word word = (MODI.Word) layout.Words[j];
        // Add a blank space to separate words.
        if (strText.Length > 0)
        {
            strText += " ";
        }
        // Add the word.
        strText += word.Text;
    }
    // Close the MODI.Document object.
    md.Close(false);
    // Create the dialog that displays
    // the OCRed text.
    ShowText st = new ShowText();
    // The the dialog's text.
    st.m_strOCRText = strText;
    // Show the dialog.
    st.ShowDialog();
}