예제 #1
0
        // Wait for the engine to complete
        private static bool OCRWait(int JobNo, TOCRJOBINFO JobInfo)
        {
            int Status;
            int JobStatus = 0;
            int ErrorMode = 0;

            Status = TOCRDoJob(JobNo, ref JobInfo);
            if (Status == TOCR_OK)
            {
                Status = TOCRWaitForJob(JobNo, ref JobStatus);
            }

            if (Status == TOCR_OK && JobStatus == TOCRJOBSTATUS_DONE)
            {
                return(true);
            }
            else
            {
                // If something's gone wrong display a message
                // (Check that the OCR engine hasn't already displayed a message)
                TOCRGetErrorMode(JobNo, ref ErrorMode);
                if (ErrorMode == TOCRERRORMODE_NONE)
                {
                    StringBuilder Msg = new StringBuilder(TOCRJOBMSGLENGTH);
                    TOCRGetJobStatusMsg(JobNo, Msg);
                    MessageBox.Show(Msg.ToString(), "OCRWait", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                return(false);
            }
        }
예제 #2
0
        private string GetOCRfromBMP(Bitmap bmp)
        {
            int         Status;
            int         JobNo  = 0;
            string      Answer = "";
            Bitmap      BMP;
            TOCRRESULTS Results = new TOCRRESULTS();
            TOCRJOBINFO JobInfo = new TOCRJOBINFO();

            JobInfo.ProcessOptions.DisableCharacter = new short[256];

            IntPtr MMFhandle = IntPtr.Zero;

            //BMP = new Bitmap(mSample_BMP_file);
            BMP = bmp;

            //MMFhandle = ConvertBitmapToMMF(BMP);
            MMFhandle = ConvertBitmapToMMF2(BMP);

            if (!(MMFhandle.Equals(IntPtr.Zero)))
            {
                TOCRSetErrorMode(TOCRDEFERRORMODE, TOCRERRORMODE_MSGBOX);
                JobInfo.InputFile = "";
                JobInfo.JobType   = TOCRJOBTYPE_MMFILEHANDLE;
                Status            = TOCRInitialise(ref JobNo);
                if (Status == TOCR_OK)
                {
                    JobInfo.PageNo = MMFhandle.ToInt32();
                    if (OCRWait(JobNo, JobInfo))
                    {
                        if (GetResults(JobNo, ref Results))
                        {
                            if (FormatResults(Results, ref Answer))
                            {
                                //MessageBox.Show(Answer, "Example 3", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    TOCRShutdown(TOCRSHUTDOWNALL);
                }
                CloseHandle(MMFhandle);
            }
            return(Answer);
        }
예제 #3
0
 public static extern int TOCRDoJob(int JobNo, ref TOCRJOBINFO JobInfo);