private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter      = "All Supported Files(*.jpg;*.jpe;*.jpeg;*.jfif;*.bmp;*.png;*.tif;*.tiff;*.pdf;*.gif)|*.jpg;*.jpe;*.jpeg;*.jfif;*.bmp;*.png;*.tif;*.tiff;*.pdf;*.gif|JPEG(*.jpg;*.jpeg;*.jpe;*.jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|BMP(*.bmp)|*.bmp|PNG(*.png)|*.png|TIFF(*.tif;*.tiff)|*.tif;*.tiff|PDF(*.pdf)|*.pdf|GIF(*.gif)|*.gif";
            dlg.Multiselect = true;
            if (dlg.ShowDialog().Value)
            {
                foreach (String strFileName in dlg.FileNames)
                {
                    int pos = strFileName.LastIndexOf(".");
                    if (pos != -1)
                    {
                        string strSuffix = strFileName.Substring(pos, strFileName.Length - pos).ToLower();
                        if (strSuffix.CompareTo(".pdf") == 0)
                        {
                            m_PDFRasterizer.ConvertMode = Dynamsoft.PDF.Enums.EnumConvertMode.enumCM_RENDERALL;
                            m_PDFRasterizer.ConvertToImage(strFileName, "", 200, this as IConvertCallback);
                            continue;
                        }
                    }
                    m_CoreForImageThum.IO.LoadImage(strFileName);
                }
                UpdateImageInfo();
            }
        }
예제 #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedlg = new OpenFileDialog();

            filedlg.Filter      = "All Support Files|*.JPG;*.JPEG;*.JPE;*.JFIF;*.BMP;*.PNG;*.TIF;*.TIFF;*.PDF;*.GIF|JPEG|*.JPG;*.JPEG;*.JPE;*.Jfif|BMP|*.BMP|PNG|*.PNG|TIFF|*.TIF;*.TIFF|PDF|*.PDF|GIF|*.GIF";
            filedlg.Multiselect = true;
            if (filedlg.ShowDialog() == DialogResult.OK)
            {
                foreach (string strfilename in filedlg.FileNames)
                {
                    int pos = strfilename.LastIndexOf(".");
                    if (pos != -1)
                    {
                        string strSuffix = strfilename.Substring(pos, strfilename.Length - pos).ToLower();
                        if (strSuffix.CompareTo(".pdf") == 0)
                        {
                            m_Rasterizer.ConvertMode = Dynamsoft.PDF.Enums.EnumConvertMode.enumCM_RENDERALL;
                            m_Rasterizer.ConvertToImage(strfilename, "", 200, this as IConvertCallback);
                            continue;
                        }
                    }
                    m_ImageCore.IO.LoadImage(strfilename);
                }
            }
        }
예제 #3
0
        private void btnLoadImage_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openfdlg = new OpenFileDialog();
                openfdlg.Filter      = "All Support Files|*.JPG;*.JPEG;*.JPE;*.JFIF;*.BMP;*.PNG;*.TIF;*.TIFF;*.PDF;*.GIF|JPEG|*.JPG;*.JPEG;*.JPE;*.Jfif|BMP|*.BMP|PNG|*.PNG|TIFF|*.TIF;*.TIFF|PDF|*.PDF|GIF|*.GIF";
                openfdlg.FilterIndex = 0;
                openfdlg.Multiselect = true;

                if (openfdlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string strfilename in openfdlg.FileNames)
                    {
                        int pos = strfilename.LastIndexOf(".");
                        if (pos != -1)
                        {
                            string strSuffix = strfilename.Substring(pos, strfilename.Length - pos).ToLower();
                            if (strSuffix.CompareTo(".pdf") == 0)
                            {
                                m_PDFRasterizer.ConvertToImage(strfilename, "", 200, this as IConvertCallback);
                            }
                        }
                        m_ImageCore.IO.LoadImage(strfilename);
                    }
                }
            }
            catch
            {
            }
        }
예제 #4
0
        public void GenerateOCR(OcrAttchmentModel ocrAttModel, string sourcePath, string fileName)  //, string targetPath
        {
            byte[] sbytes         = null;
            string languageFolder = ConfigurationManager.AppSettings["Tessdata"];

            LogUtility.WriteToFile("OCR Utility Process Path:" + languageFolder);
            //m_strCurrentDirectory + ConfigurationManager.AppSettings["Tessdata"];     // "\\OCR\\tessdata";
            m_Tesseract              = new Tesseract(m_StrProductKey);
            m_ImageCore              = new ImageCore();
            m_PDFRasterizer          = new PDFRasterizer(m_StrProductKey);
            tempListSelectedBitmap   = new List <System.Drawing.Bitmap>();
            m_Tesseract.TessDataPath = languageFolder;
            m_Tesseract.Language     = languages["English"];
            m_Tesseract.ResultFormat = ResultFormat.Text;

            string imageFolder = sourcePath;
            string testPath    = string.Empty;

            if (sourcePath.Contains(".pdf"))
            {
                m_PDFRasterizer.ConvertMode = Dynamsoft.PDF.Enums.EnumConvertMode.enumCM_AUTO;
                m_PDFRasterizer.ConvertToImage(imageFolder, "", 200, this as IConvertCallback);
            }
            else
            {
                m_ImageCore.IO.LoadImage(imageFolder);
            }
            int          imgCount  = m_ImageCore.ImageBuffer.HowManyImagesInBuffer;
            List <short> lstindexs = new List <short>();

            for (short index = 0; index < imgCount; index++)
            {
                if (index >= 0 && index < m_ImageCore.ImageBuffer.HowManyImagesInBuffer)
                {
                    if (tempListSelectedBitmap == null)
                    {
                        tempListSelectedBitmap = new List <Bitmap>();
                    }
                    Bitmap temp = m_ImageCore.ImageBuffer.GetBitmap(index);
                    tempListSelectedBitmap.Add(temp);
                    lstindexs.Add(index);
                }
            }

            if (tempListSelectedBitmap != null)
            {
                sbytes = m_Tesseract.Recognize(tempListSelectedBitmap);
            }

            if (sbytes != null && sbytes.Length > 0)
            {
                LogUtility.WriteToFile("OCR Processing File Name:" + fileName);
                SaveOCRBlob(ocrAttModel, fileName, sbytes);
            }
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedlg = new OpenFileDialog();

            filedlg.Filter      = "All Support Files|*.JPG;*.JPEG;*.JPE;*.JFIF;*.BMP;*.PNG;*.TIF;*.TIFF;*.PDF;*.GIF|JPEG|*.JPG;*.JPEG;*.JPE;*.Jfif|BMP|*.BMP|PNG|*.PNG|TIFF|*.TIF;*.TIFF|PDF|*.PDF|GIF|*.GIF";
            filedlg.FilterIndex = 0;
            filedlg.Multiselect = true;
            // try to locate images folder
            string imagesFolder = Application.ExecutablePath;

            // we assume we are running under the DotImage install folder
            imagesFolder = imagesFolder.Replace("/", "\\");
            string strPDFDllFolder = imagesFolder;
            int    pos             = imagesFolder.LastIndexOf("\\Samples\\");

            if (pos != -1)
            {
                imagesFolder = imagesFolder.Substring(0, imagesFolder.IndexOf(@"\", pos)) + @"\Samples\Bin\Images\BarcodeImages\";
            }


            //use this folder as starting point
            filedlg.InitialDirectory = imagesFolder;

            if (filedlg.ShowDialog() == DialogResult.OK)
            {
                foreach (string strfilename in filedlg.FileNames)
                {
                    pos = strfilename.LastIndexOf(".");
                    if (pos != -1)
                    {
                        string strSuffix = strfilename.Substring(pos, strfilename.Length - pos).ToLower();
                        if (strSuffix.CompareTo(".pdf") == 0)
                        {
                            m_PDFRasterizer.ConvertMode = Dynamsoft.PDF.Enums.EnumConvertMode.enumCM_RENDERALL;
                            m_PDFRasterizer.ConvertToImage(strfilename, "", 200, this as IConvertCallback);
                            continue;
                        }
                    }
                    this.m_ImageCore.IO.LoadImage(strfilename);
                }
                viewer1_OnImageAreaDeselected(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer);
            }
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedlg = new OpenFileDialog();

            filedlg.Filter      = "All Support Files|*.JPG;*.JPEG;*.JPE;*.JFIF;*.BMP;*.PNG;*.TIF;*.TIFF;*.PDF;*.GIF|JPEG|*.JPG;*.JPEG;*.JPE;*.Jfif|BMP|*.BMP|PNG|*.PNG|TIFF|*.TIF;*.TIFF|PDF|*.PDF|GIF|*.GIF";
            filedlg.Multiselect = true;
            string imageFolder     = m_strCurrentDirectory;
            string strPDFDllFolder = imageFolder;

            if (m_bSamplesExist)
            {
                imageFolder = m_strCurrentDirectory + @"Samples\Bin\Images\OCRImages\";
            }

            filedlg.InitialDirectory = imageFolder;


            if (filedlg.ShowDialog() == DialogResult.OK)
            {
                foreach (string strfilename in filedlg.FileNames)
                {
                    int pos = strfilename.LastIndexOf(".");
                    if (pos != -1)
                    {
                        string strSuffix = strfilename.Substring(pos, strfilename.Length - pos).ToLower();
                        if (strSuffix.CompareTo(".pdf") == 0)
                        {
                            m_PDFRasterizer.ConvertMode = Dynamsoft.PDF.Enums.EnumConvertMode.enumCM_RENDERALL;
                            m_PDFRasterizer.ConvertToImage(strfilename, "", 200, this as IConvertCallback);
                            continue;
                        }
                    }
                    m_ImageCore.IO.LoadImage(strfilename);
                }
                dynamicDotNetTwain1_OnImageAreaDeselected(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer);
            }
        }