private void openToolStripMenuItem_Click(object sender, EventArgs e) { try { ImageFileLoader loader = new ImageFileLoader(); loader.ShowLoadPagesDialog = true; loader.MultiSelect = false; loader.ShowPdfOptions = true; loader.ShowLoadPagesDialog = false; if (loader.Load(this, rasterCodecs, true) > 0) { OpenImage(loader.Image); } } catch (Exception exp) { EnableControls(true); Messager.ShowError(this, exp); } }
private void _miFileOpen_Click(object sender, System.EventArgs e) { ImageFileLoader loader = new ImageFileLoader(); loader.OpenDialogInitialPath = _openInitialPath; try { loader.LoadOnlyOnePage = true; if (loader.Load(this, _codecs, true) > 0) { _openInitialPath = Path.GetDirectoryName(loader.FileName); CreateChildForm(loader.Image, loader.FileName); } } catch (Exception ex) { Messager.ShowFileOpenError(this, loader.FileName, ex); } }
private void OpenImageFile() { // Open an image file from disk and put it in the viewer ImageFileLoader loader = new ImageFileLoader(); loader.OpenDialogInitialPath = _openInitialPath; try { loader.ShowLoadPagesDialog = true; if (loader.Load(this, _codecs, true) > 0) { _openInitialPath = Path.GetDirectoryName(loader.FileName); SetViewerImage(loader.FileName, loader.Image, Path.GetFileName(loader.FileName)); } } catch (Exception ex) { Messager.ShowFileOpenError(this, loader.FileName, ex); } }
private ImageInformation LoadImage() { ImageFileLoader loader = new ImageFileLoader(); loader.OpenDialogInitialPath = _openInitialPath; try { loader.LoadOnlyOnePage = true; loader.ShowLoadPagesDialog = false; if (loader.Load(this, _codecs, true) > 0) { _openInitialPath = Path.GetDirectoryName(loader.FileName); return(new ImageInformation(loader.Image, loader.FileName)); } } catch (Exception ex) { Messager.ShowFileOpenError(this, loader.FileName, ex); } return(null); }
/// <summary> /// Underlay an Image /// </summary> private void _miBasicFeaturesUnderlay_Click(object sender, EventArgs e) { try { ImageFileLoader loader = new ImageFileLoader(); if (loader.Load(this, _codecs, true) <= 0) { return; } using (UnderlayDialog dlg = new UnderlayDialog()) { if (dlg.ShowDialog(this) != DialogResult.OK) { return; } using (WaitCursor wait = new WaitCursor()) _viewer.Image.Underlay(loader.Image, dlg.Flags); } } catch (Exception ex) { Messager.ShowError(this, ex); } }
private void LoadImage(bool loadDefaultImage) { ImageFileLoader loader = new ImageFileLoader(); bool bLoaded; loader.OpenDialogInitialPath = _openInitialPath; try { loader.LoadOnlyOnePage = true; if (loadDefaultImage) { if (_ocrEngineType == OcrEngineType.Arabic) bLoaded = loader.Load(this, DemosGlobal.ImagesFolder + @"\ArabicSample.tif", _codecs, 1, -1); else bLoaded = loader.Load(this, DemosGlobal.ImagesFolder + @"\ocr1.tif", _codecs, 1, -1); } else bLoaded = loader.Load(this, _codecs, true) > 0; if (bLoaded) { _openInitialPath = Path.GetDirectoryName(loader.FileName); RasterImage image = loader.Image; if (image.XResolution < 150) image.XResolution = 150; if (image.YResolution < 150) image.YResolution = 150; if (_ocrPage != null) { _ocrPage.Dispose(); _ocrPage = null; } _viewer.Image = image; if (_ocrEngine.IsStarted) _ocrPage = _ocrEngine.CreatePage(image, OcrImageSharingMode.None); _currentHighlightRect = LeadRect.Empty; _recognitionResults.Text = ""; _tsMainZoomComboBox_SelectedIndexChanged(_tsMainZoomComboBox, new EventArgs()); } } catch (Exception ex) { Messager.ShowFileOpenError(this, loader.FileName, ex); } finally { _viewer.Invalidate(); } }
private void LoadImage(bool loadDefaultImage) { ImageFileLoader loader = new ImageFileLoader(); ViewerForm activeViewer = ActiveViewerForm; try { ImageInformation info = null; if (loadDefaultImage) { if (loader.Load(this, DemosGlobal.ImagesFolder + @"\clean.tif", _codecs, 1, 1)) { info = new ImageInformation(loader.Image, loader.FileName); } } else { int filesCount = loader.Load(this, _codecs, true); if (filesCount > 0 && loader.Images[0] != null) { info = loader.Images[0]; } } if (info != null) { if (info.Image.HasRegion) { info.Image.MakeRegionEmpty(); } _fileName = info.Name; info.Name += " (Original)"; if (!_viewerOpened) { NewImage(info, true); _viewerOpened = true; } else { activeViewer.Image = info.Image; activeViewer.Text = info.Name; if (!((ViewerForm)MdiChildren[0]).OriginalViewer) { MdiChildren[0].Close(); } if (MdiChildren.Length > 1) { if (!((ViewerForm)MdiChildren[1]).OriginalViewer) { MdiChildren[1].Close(); } } ShowSave = false; if (PreviousCheckQuality != null) { PreviousCheckQuality.Checked = false; } } } } catch (Exception ex) { Messager.ShowError(this, ex); } finally { UpdateControls(); } }
private void LoadImage(bool loadDefaultImage) { ImageFileLoader loader = new ImageFileLoader(); bool bLoaded; loader.OpenDialogInitialPath = _openInitialPath; try { loader.LoadOnlyOnePage = true; if (loadDefaultImage) { if (_ocrEngineType == OcrEngineType.OmniPageArabic) { bLoaded = loader.Load(this, DemosGlobal.ImagesFolder + @"\ArabicSample.tif", _codecs, 1, -1); } else { bLoaded = loader.Load(this, DemosGlobal.ImagesFolder + @"\ocr1.tif", _codecs, 1, -1); } } else { bLoaded = loader.Load(this, _codecs, true) > 0; } if (bLoaded) { _openInitialPath = Path.GetDirectoryName(loader.FileName); RasterImage image = loader.Image; if (image.XResolution < 150) { image.XResolution = 150; } if (image.YResolution < 150) { image.YResolution = 150; } if (_ocrPage != null) { _ocrPage.Dispose(); _ocrPage = null; } _viewer.Image = image; if (_ocrEngine.IsStarted) { _ocrPage = _ocrEngine.CreatePage(image, OcrImageSharingMode.None); } _currentHighlightRect = LeadRect.Empty; _recognitionResults.Text = ""; _tsMainZoomComboBox_SelectedIndexChanged(_tsMainZoomComboBox, new EventArgs()); } } catch (Exception ex) { Messager.ShowFileOpenError(this, loader.FileName, ex); } finally { _viewer.Invalidate(); } }