Esempio n. 1
0
        private static bool LoadImage(string fileName)
        {
            int res = TNSOCR.Img_LoadFile(ImgObj, fileName);

            if (res > TNSOCR.ERROR_FIRST)
            {
                ShowError("Img_LoadFile", res);
                return(false);
            }

            int w0, h0, w, h;

            //native size
            TNSOCR.Img_GetSize(ImgObj, out w0, out h0);


            //now apply image scaling, binarize image, deskew etc,
            //everything except zoning and OCR
            res = TNSOCR.Img_OCR(ImgObj, TNSOCR.OCRSTEP_FIRST, TNSOCR.OCRSTEP_ZONING - 1, 0);
            if (res > TNSOCR.ERROR_FIRST)
            {
                ShowError("Img_OCR", res);
                return(false);
            }

            //final size after pre-processing
            TNSOCR.Img_GetSize(ImgObj, out w, out h);

            /*res = TNSOCR.Img_GetSkewAngle(ImgObj);
             * if (res > TNSOCR.ERROR_FIRST)
             * {
             *  ShowError("Img_GetSkewAngle", res);
             *  //lbSkew.Text = "";
             * }
             * else
             * {
             *  //lbSkew.Text = "Skew angle (degrees): " + (res / 1000.0);
             * }
             *
             * //pixel lines info
             * res = TNSOCR.Img_GetPixLineCnt(ImgObj);
             * if (res > TNSOCR.ERROR_FIRST)
             * {
             *  ShowError("Img_GetPixLineCnt", res);
             *  return false;
             * }
             * //lbLines.Text = "Lines: " + res.ToString();
             *
             * //edPage.Text = "1";
             * //lbPages.Text = "of " + TNSOCR.Img_GetPageCount(ImgObj).ToString();
             */

            Frame = new Rectangle(0, 0, w, h);

            return(true);
        }