mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Make loading a bit more robust (more error handling)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2097 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
bfadd35eb5
commit
83780218c2
@ -2385,6 +2385,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
if (format == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bdnXml = new BdnXml();
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
@ -2400,8 +2402,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (fileName.ToLower().EndsWith(".dost"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var dost = new Dost();
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
@ -2415,8 +2424,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == null || format.Name == new Scenarist().Name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var son = new Son();
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
@ -2430,6 +2446,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == null || format.Name == new SubRip().Name)
|
||||
{
|
||||
@ -2455,6 +2476,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
if (format == null || format.Name == new Scenarist().Name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var sst = new SonicScenaristBitmaps();
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
@ -2468,8 +2491,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var htmlSamiArray = new HtmlSamiArray();
|
||||
string[] arr = File.ReadAllLines(fileName, Utilities.GetEncodingFromFile(fileName));
|
||||
@ -2487,6 +2517,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
format = GetCurrentSubtitleFormat();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (format == null && fi.Length < 500000)
|
||||
|
350
src/Forms/VobSubOcr.Designer.cs
generated
350
src/Forms/VobSubOcr.Designer.cs
generated
@ -58,6 +58,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxOcrMethod = new System.Windows.Forms.GroupBox();
|
||||
this.comboBoxOcrMethod = new System.Windows.Forms.ComboBox();
|
||||
this.groupBoxImageCompareMethod = new System.Windows.Forms.GroupBox();
|
||||
this.labelMaxErrorPercent = new System.Windows.Forms.Label();
|
||||
this.numericUpDownMaxErrorPct = new System.Windows.Forms.NumericUpDown();
|
||||
this.checkBoxRightToLeft = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownPixelsIsSpace = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonEditCharacterDatabase = new System.Windows.Forms.Button();
|
||||
this.labelNoOfPixelsIsSpace = new System.Windows.Forms.Label();
|
||||
this.comboBoxCharacterDatabase = new System.Windows.Forms.ComboBox();
|
||||
this.labelImageDatabase = new System.Windows.Forms.Label();
|
||||
this.buttonNewCharacterDatabase = new System.Windows.Forms.Button();
|
||||
this.GroupBoxTesseractMethod = new System.Windows.Forms.GroupBox();
|
||||
this.buttonGetTesseractDictionaries = new System.Windows.Forms.Button();
|
||||
this.checkBoxTesseractMusicOn = new System.Windows.Forms.CheckBox();
|
||||
@ -65,7 +76,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.checkBoxUseModiInTesseractForUnknownWords = new System.Windows.Forms.CheckBox();
|
||||
this.labelTesseractLanguage = new System.Windows.Forms.Label();
|
||||
this.comboBoxTesseractLanguages = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxOcrMethod = new System.Windows.Forms.ComboBox();
|
||||
this.groupBoxModiMethod = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBoxModiLanguage = new System.Windows.Forms.ComboBox();
|
||||
@ -79,14 +89,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.checkBoxRightToLeftNOCR = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.Label();
|
||||
this.groupBoxImageCompareMethod = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxRightToLeft = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownPixelsIsSpace = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonEditCharacterDatabase = new System.Windows.Forms.Button();
|
||||
this.labelNoOfPixelsIsSpace = new System.Windows.Forms.Label();
|
||||
this.comboBoxCharacterDatabase = new System.Windows.Forms.ComboBox();
|
||||
this.labelImageDatabase = new System.Windows.Forms.Label();
|
||||
this.buttonNewCharacterDatabase = new System.Windows.Forms.Button();
|
||||
this.groupBoxOCRControls = new System.Windows.Forms.GroupBox();
|
||||
this.labelStartFrom = new System.Windows.Forms.Label();
|
||||
this.numericUpDownStartNumber = new System.Windows.Forms.NumericUpDown();
|
||||
@ -138,19 +140,18 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.splitContainerBottom = new System.Windows.Forms.SplitContainer();
|
||||
this.timerHideStatus = new System.Windows.Forms.Timer(this.components);
|
||||
this.labelMaxErrorPercent = new System.Windows.Forms.Label();
|
||||
this.numericUpDownMaxErrorPct = new System.Windows.Forms.NumericUpDown();
|
||||
this.textBoxCurrentText = new Nikse.SubtitleEdit.Controls.SETextBox();
|
||||
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
|
||||
this.timerHideStatus = new System.Windows.Forms.Timer(this.components);
|
||||
this.contextMenuStripListview.SuspendLayout();
|
||||
this.groupBoxOcrMethod.SuspendLayout();
|
||||
this.groupBoxImageCompareMethod.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).BeginInit();
|
||||
this.GroupBoxTesseractMethod.SuspendLayout();
|
||||
this.groupBoxModiMethod.SuspendLayout();
|
||||
this.groupBoxNOCR.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).BeginInit();
|
||||
this.groupBoxImageCompareMethod.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).BeginInit();
|
||||
this.groupBoxOCRControls.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).BeginInit();
|
||||
this.groupBoxOcrAutoFix.SuspendLayout();
|
||||
@ -171,7 +172,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.splitContainerBottom.Panel1.SuspendLayout();
|
||||
this.splitContainerBottom.Panel2.SuspendLayout();
|
||||
this.splitContainerBottom.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contextMenuStripListview
|
||||
@ -386,10 +386,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
// groupBoxOcrMethod
|
||||
//
|
||||
this.groupBoxOcrMethod.Controls.Add(this.comboBoxOcrMethod);
|
||||
this.groupBoxOcrMethod.Controls.Add(this.groupBoxImageCompareMethod);
|
||||
this.groupBoxOcrMethod.Controls.Add(this.GroupBoxTesseractMethod);
|
||||
this.groupBoxOcrMethod.Controls.Add(this.groupBoxModiMethod);
|
||||
this.groupBoxOcrMethod.Controls.Add(this.groupBoxNOCR);
|
||||
this.groupBoxOcrMethod.Controls.Add(this.groupBoxImageCompareMethod);
|
||||
this.groupBoxOcrMethod.Location = new System.Drawing.Point(13, 5);
|
||||
this.groupBoxOcrMethod.Name = "groupBoxOcrMethod";
|
||||
this.groupBoxOcrMethod.Size = new System.Drawing.Size(392, 192);
|
||||
@ -397,6 +397,156 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.groupBoxOcrMethod.TabStop = false;
|
||||
this.groupBoxOcrMethod.Text = "OCR method";
|
||||
//
|
||||
// comboBoxOcrMethod
|
||||
//
|
||||
this.comboBoxOcrMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxOcrMethod.FormattingEnabled = true;
|
||||
this.comboBoxOcrMethod.Items.AddRange(new object[] {
|
||||
"OCR via tesseract",
|
||||
"OCR via image compare",
|
||||
"OCR via Microsoftr MODI",
|
||||
"OCR via nOCR"});
|
||||
this.comboBoxOcrMethod.Location = new System.Drawing.Point(13, 20);
|
||||
this.comboBoxOcrMethod.Name = "comboBoxOcrMethod";
|
||||
this.comboBoxOcrMethod.Size = new System.Drawing.Size(366, 21);
|
||||
this.comboBoxOcrMethod.TabIndex = 0;
|
||||
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
|
||||
//
|
||||
// groupBoxImageCompareMethod
|
||||
//
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelMaxErrorPercent);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownMaxErrorPct);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.checkBoxRightToLeft);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelNoOfPixelsIsSpace);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.comboBoxCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelImageDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.buttonNewCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Location = new System.Drawing.Point(13, 38);
|
||||
this.groupBoxImageCompareMethod.Name = "groupBoxImageCompareMethod";
|
||||
this.groupBoxImageCompareMethod.Size = new System.Drawing.Size(366, 131);
|
||||
this.groupBoxImageCompareMethod.TabIndex = 2;
|
||||
this.groupBoxImageCompareMethod.TabStop = false;
|
||||
this.groupBoxImageCompareMethod.Text = "Image compare";
|
||||
//
|
||||
// labelMaxErrorPercent
|
||||
//
|
||||
this.labelMaxErrorPercent.AutoSize = true;
|
||||
this.labelMaxErrorPercent.Location = new System.Drawing.Point(7, 83);
|
||||
this.labelMaxErrorPercent.Name = "labelMaxErrorPercent";
|
||||
this.labelMaxErrorPercent.Size = new System.Drawing.Size(55, 13);
|
||||
this.labelMaxErrorPercent.TabIndex = 45;
|
||||
this.labelMaxErrorPercent.Text = "Max Err%";
|
||||
//
|
||||
// numericUpDownMaxErrorPct
|
||||
//
|
||||
this.numericUpDownMaxErrorPct.DecimalPlaces = 1;
|
||||
this.numericUpDownMaxErrorPct.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownMaxErrorPct.Location = new System.Drawing.Point(173, 81);
|
||||
this.numericUpDownMaxErrorPct.Maximum = new decimal(new int[] {
|
||||
20,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownMaxErrorPct.Minimum = new decimal(new int[] {
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownMaxErrorPct.Name = "numericUpDownMaxErrorPct";
|
||||
this.numericUpDownMaxErrorPct.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownMaxErrorPct.TabIndex = 44;
|
||||
this.numericUpDownMaxErrorPct.Value = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
//
|
||||
// checkBoxRightToLeft
|
||||
//
|
||||
this.checkBoxRightToLeft.AutoSize = true;
|
||||
this.checkBoxRightToLeft.Location = new System.Drawing.Point(9, 107);
|
||||
this.checkBoxRightToLeft.Name = "checkBoxRightToLeft";
|
||||
this.checkBoxRightToLeft.Size = new System.Drawing.Size(83, 17);
|
||||
this.checkBoxRightToLeft.TabIndex = 6;
|
||||
this.checkBoxRightToLeft.Text = "Right to left";
|
||||
this.checkBoxRightToLeft.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownPixelsIsSpace
|
||||
//
|
||||
this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 54);
|
||||
this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPixelsIsSpace.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPixelsIsSpace.Name = "numericUpDownPixelsIsSpace";
|
||||
this.numericUpDownPixelsIsSpace.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownPixelsIsSpace.TabIndex = 5;
|
||||
this.numericUpDownPixelsIsSpace.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// buttonEditCharacterDatabase
|
||||
//
|
||||
this.buttonEditCharacterDatabase.Location = new System.Drawing.Point(278, 46);
|
||||
this.buttonEditCharacterDatabase.Name = "buttonEditCharacterDatabase";
|
||||
this.buttonEditCharacterDatabase.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonEditCharacterDatabase.TabIndex = 3;
|
||||
this.buttonEditCharacterDatabase.Text = "Edit";
|
||||
this.buttonEditCharacterDatabase.UseVisualStyleBackColor = true;
|
||||
this.buttonEditCharacterDatabase.Click += new System.EventHandler(this.ButtonEditCharacterDatabaseClick);
|
||||
//
|
||||
// labelNoOfPixelsIsSpace
|
||||
//
|
||||
this.labelNoOfPixelsIsSpace.AutoSize = true;
|
||||
this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 56);
|
||||
this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace";
|
||||
this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13);
|
||||
this.labelNoOfPixelsIsSpace.TabIndex = 4;
|
||||
this.labelNoOfPixelsIsSpace.Text = "No of pixels is space";
|
||||
//
|
||||
// comboBoxCharacterDatabase
|
||||
//
|
||||
this.comboBoxCharacterDatabase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxCharacterDatabase.FormattingEnabled = true;
|
||||
this.comboBoxCharacterDatabase.Location = new System.Drawing.Point(130, 19);
|
||||
this.comboBoxCharacterDatabase.Name = "comboBoxCharacterDatabase";
|
||||
this.comboBoxCharacterDatabase.Size = new System.Drawing.Size(142, 21);
|
||||
this.comboBoxCharacterDatabase.TabIndex = 1;
|
||||
this.comboBoxCharacterDatabase.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCharacterDatabaseSelectedIndexChanged);
|
||||
//
|
||||
// labelImageDatabase
|
||||
//
|
||||
this.labelImageDatabase.AutoSize = true;
|
||||
this.labelImageDatabase.Location = new System.Drawing.Point(7, 22);
|
||||
this.labelImageDatabase.Name = "labelImageDatabase";
|
||||
this.labelImageDatabase.Size = new System.Drawing.Size(85, 13);
|
||||
this.labelImageDatabase.TabIndex = 0;
|
||||
this.labelImageDatabase.Text = "Image database";
|
||||
//
|
||||
// buttonNewCharacterDatabase
|
||||
//
|
||||
this.buttonNewCharacterDatabase.Location = new System.Drawing.Point(278, 19);
|
||||
this.buttonNewCharacterDatabase.Name = "buttonNewCharacterDatabase";
|
||||
this.buttonNewCharacterDatabase.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonNewCharacterDatabase.TabIndex = 2;
|
||||
this.buttonNewCharacterDatabase.Text = "New";
|
||||
this.buttonNewCharacterDatabase.UseVisualStyleBackColor = true;
|
||||
this.buttonNewCharacterDatabase.Click += new System.EventHandler(this.ButtonNewCharacterDatabaseClick);
|
||||
//
|
||||
// GroupBoxTesseractMethod
|
||||
//
|
||||
this.GroupBoxTesseractMethod.Controls.Add(this.buttonGetTesseractDictionaries);
|
||||
@ -478,21 +628,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.comboBoxTesseractLanguages.TabIndex = 1;
|
||||
this.comboBoxTesseractLanguages.SelectedIndexChanged += new System.EventHandler(this.ComboBoxTesseractLanguagesSelectedIndexChanged);
|
||||
//
|
||||
// comboBoxOcrMethod
|
||||
//
|
||||
this.comboBoxOcrMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxOcrMethod.FormattingEnabled = true;
|
||||
this.comboBoxOcrMethod.Items.AddRange(new object[] {
|
||||
"OCR via tesseract",
|
||||
"OCR via image compare",
|
||||
"OCR via Microsoftr MODI",
|
||||
"OCR via nOCR"});
|
||||
this.comboBoxOcrMethod.Location = new System.Drawing.Point(13, 20);
|
||||
this.comboBoxOcrMethod.Name = "comboBoxOcrMethod";
|
||||
this.comboBoxOcrMethod.Size = new System.Drawing.Size(366, 21);
|
||||
this.comboBoxOcrMethod.TabIndex = 0;
|
||||
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
|
||||
//
|
||||
// groupBoxModiMethod
|
||||
//
|
||||
this.groupBoxModiMethod.Controls.Add(this.label1);
|
||||
@ -641,104 +776,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.TabIndex = 4;
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Text = "No of pixels is space";
|
||||
//
|
||||
// groupBoxImageCompareMethod
|
||||
//
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelMaxErrorPercent);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownMaxErrorPct);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.checkBoxRightToLeft);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelNoOfPixelsIsSpace);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.comboBoxCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelImageDatabase);
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.buttonNewCharacterDatabase);
|
||||
this.groupBoxImageCompareMethod.Location = new System.Drawing.Point(13, 38);
|
||||
this.groupBoxImageCompareMethod.Name = "groupBoxImageCompareMethod";
|
||||
this.groupBoxImageCompareMethod.Size = new System.Drawing.Size(366, 131);
|
||||
this.groupBoxImageCompareMethod.TabIndex = 2;
|
||||
this.groupBoxImageCompareMethod.TabStop = false;
|
||||
this.groupBoxImageCompareMethod.Text = "Image compare";
|
||||
//
|
||||
// checkBoxRightToLeft
|
||||
//
|
||||
this.checkBoxRightToLeft.AutoSize = true;
|
||||
this.checkBoxRightToLeft.Location = new System.Drawing.Point(9, 107);
|
||||
this.checkBoxRightToLeft.Name = "checkBoxRightToLeft";
|
||||
this.checkBoxRightToLeft.Size = new System.Drawing.Size(83, 17);
|
||||
this.checkBoxRightToLeft.TabIndex = 6;
|
||||
this.checkBoxRightToLeft.Text = "Right to left";
|
||||
this.checkBoxRightToLeft.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownPixelsIsSpace
|
||||
//
|
||||
this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 54);
|
||||
this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPixelsIsSpace.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownPixelsIsSpace.Name = "numericUpDownPixelsIsSpace";
|
||||
this.numericUpDownPixelsIsSpace.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownPixelsIsSpace.TabIndex = 5;
|
||||
this.numericUpDownPixelsIsSpace.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// buttonEditCharacterDatabase
|
||||
//
|
||||
this.buttonEditCharacterDatabase.Location = new System.Drawing.Point(278, 46);
|
||||
this.buttonEditCharacterDatabase.Name = "buttonEditCharacterDatabase";
|
||||
this.buttonEditCharacterDatabase.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonEditCharacterDatabase.TabIndex = 3;
|
||||
this.buttonEditCharacterDatabase.Text = "Edit";
|
||||
this.buttonEditCharacterDatabase.UseVisualStyleBackColor = true;
|
||||
this.buttonEditCharacterDatabase.Click += new System.EventHandler(this.ButtonEditCharacterDatabaseClick);
|
||||
//
|
||||
// labelNoOfPixelsIsSpace
|
||||
//
|
||||
this.labelNoOfPixelsIsSpace.AutoSize = true;
|
||||
this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 56);
|
||||
this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace";
|
||||
this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13);
|
||||
this.labelNoOfPixelsIsSpace.TabIndex = 4;
|
||||
this.labelNoOfPixelsIsSpace.Text = "No of pixels is space";
|
||||
//
|
||||
// comboBoxCharacterDatabase
|
||||
//
|
||||
this.comboBoxCharacterDatabase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxCharacterDatabase.FormattingEnabled = true;
|
||||
this.comboBoxCharacterDatabase.Location = new System.Drawing.Point(130, 19);
|
||||
this.comboBoxCharacterDatabase.Name = "comboBoxCharacterDatabase";
|
||||
this.comboBoxCharacterDatabase.Size = new System.Drawing.Size(142, 21);
|
||||
this.comboBoxCharacterDatabase.TabIndex = 1;
|
||||
this.comboBoxCharacterDatabase.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCharacterDatabaseSelectedIndexChanged);
|
||||
//
|
||||
// labelImageDatabase
|
||||
//
|
||||
this.labelImageDatabase.AutoSize = true;
|
||||
this.labelImageDatabase.Location = new System.Drawing.Point(7, 22);
|
||||
this.labelImageDatabase.Name = "labelImageDatabase";
|
||||
this.labelImageDatabase.Size = new System.Drawing.Size(85, 13);
|
||||
this.labelImageDatabase.TabIndex = 0;
|
||||
this.labelImageDatabase.Text = "Image database";
|
||||
//
|
||||
// buttonNewCharacterDatabase
|
||||
//
|
||||
this.buttonNewCharacterDatabase.Location = new System.Drawing.Point(278, 19);
|
||||
this.buttonNewCharacterDatabase.Name = "buttonNewCharacterDatabase";
|
||||
this.buttonNewCharacterDatabase.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonNewCharacterDatabase.TabIndex = 2;
|
||||
this.buttonNewCharacterDatabase.Text = "New";
|
||||
this.buttonNewCharacterDatabase.UseVisualStyleBackColor = true;
|
||||
this.buttonNewCharacterDatabase.Click += new System.EventHandler(this.ButtonNewCharacterDatabaseClick);
|
||||
//
|
||||
// groupBoxOCRControls
|
||||
//
|
||||
this.groupBoxOCRControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@ -1309,48 +1346,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.splitContainerBottom.SplitterDistance = 658;
|
||||
this.splitContainerBottom.TabIndex = 39;
|
||||
//
|
||||
// timerHideStatus
|
||||
//
|
||||
this.timerHideStatus.Interval = 2000;
|
||||
this.timerHideStatus.Tick += new System.EventHandler(this.timerHideStatus_Tick);
|
||||
//
|
||||
// labelMaxErrorPercent
|
||||
//
|
||||
this.labelMaxErrorPercent.AutoSize = true;
|
||||
this.labelMaxErrorPercent.Location = new System.Drawing.Point(7, 83);
|
||||
this.labelMaxErrorPercent.Name = "labelMaxErrorPercent";
|
||||
this.labelMaxErrorPercent.Size = new System.Drawing.Size(55, 13);
|
||||
this.labelMaxErrorPercent.TabIndex = 45;
|
||||
this.labelMaxErrorPercent.Text = "Max Err%";
|
||||
//
|
||||
// numericUpDownMaxErrorPct
|
||||
//
|
||||
this.numericUpDownMaxErrorPct.DecimalPlaces = 1;
|
||||
this.numericUpDownMaxErrorPct.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownMaxErrorPct.Location = new System.Drawing.Point(173, 81);
|
||||
this.numericUpDownMaxErrorPct.Maximum = new decimal(new int[] {
|
||||
20,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownMaxErrorPct.Minimum = new decimal(new int[] {
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
this.numericUpDownMaxErrorPct.Name = "numericUpDownMaxErrorPct";
|
||||
this.numericUpDownMaxErrorPct.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownMaxErrorPct.TabIndex = 44;
|
||||
this.numericUpDownMaxErrorPct.Value = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
//
|
||||
// textBoxCurrentText
|
||||
//
|
||||
this.textBoxCurrentText.AllowDrop = true;
|
||||
@ -1388,6 +1383,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
|
||||
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
|
||||
//
|
||||
// timerHideStatus
|
||||
//
|
||||
this.timerHideStatus.Interval = 2000;
|
||||
this.timerHideStatus.Tick += new System.EventHandler(this.timerHideStatus_Tick);
|
||||
//
|
||||
// VobSubOcr
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -1415,6 +1415,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.Resize += new System.EventHandler(this.VobSubOcr_Resize);
|
||||
this.contextMenuStripListview.ResumeLayout(false);
|
||||
this.groupBoxOcrMethod.ResumeLayout(false);
|
||||
this.groupBoxImageCompareMethod.ResumeLayout(false);
|
||||
this.groupBoxImageCompareMethod.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).EndInit();
|
||||
this.GroupBoxTesseractMethod.ResumeLayout(false);
|
||||
this.GroupBoxTesseractMethod.PerformLayout();
|
||||
this.groupBoxModiMethod.ResumeLayout(false);
|
||||
@ -1422,9 +1426,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.groupBoxNOCR.ResumeLayout(false);
|
||||
this.groupBoxNOCR.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).EndInit();
|
||||
this.groupBoxImageCompareMethod.ResumeLayout(false);
|
||||
this.groupBoxImageCompareMethod.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).EndInit();
|
||||
this.groupBoxOCRControls.ResumeLayout(false);
|
||||
this.groupBoxOCRControls.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).EndInit();
|
||||
@ -1450,7 +1451,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.splitContainerBottom.Panel1.PerformLayout();
|
||||
this.splitContainerBottom.Panel2.ResumeLayout(false);
|
||||
this.splitContainerBottom.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -3077,6 +3077,55 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return nocrChars;
|
||||
}
|
||||
|
||||
public static List<NOcrChar> LoadNOcrForTesseract(string xmlRessourceName)
|
||||
{
|
||||
var nocrChars = new List<NOcrChar>();
|
||||
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
Stream strm = asm.GetManifestResourceStream(xmlRessourceName);
|
||||
if (strm != null)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
var rdr = new StreamReader(strm);
|
||||
using (var zip = new System.IO.Compression.GZipStream(rdr.BaseStream, System.IO.Compression.CompressionMode.Decompress))
|
||||
{
|
||||
byte[] data = new byte[175000];
|
||||
zip.Read(data, 0, 175000);
|
||||
doc.LoadXml(System.Text.Encoding.UTF8.GetString(data));
|
||||
}
|
||||
rdr.Close();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (XmlNode node in doc.DocumentElement.SelectNodes("Char"))
|
||||
{
|
||||
var oc = new NOcrChar(node.Attributes["Text"].Value);
|
||||
oc.Width = Convert.ToInt32(node.Attributes["Width"].Value, CultureInfo.InvariantCulture);
|
||||
oc.Height = Convert.ToInt32(node.Attributes["Height"].Value, CultureInfo.InvariantCulture);
|
||||
oc.MarginTop = Convert.ToInt32(node.Attributes["MarginTop"].Value, CultureInfo.InvariantCulture);
|
||||
if (node.Attributes["Italic"] != null)
|
||||
oc.Italic = Convert.ToBoolean(node.Attributes["Italic"].Value, CultureInfo.InvariantCulture);
|
||||
if (node.Attributes["ExpandCount"] != null)
|
||||
oc.ExpandCount = Convert.ToInt32(node.Attributes["ExpandCount"].Value, CultureInfo.InvariantCulture);
|
||||
foreach (XmlNode pointNode in node.SelectNodes("Point"))
|
||||
{
|
||||
var op = new NOcrPoint(DecodePoint(pointNode.Attributes["Start"].Value), DecodePoint(pointNode.Attributes["End"].Value));
|
||||
XmlAttribute a = pointNode.Attributes["On"];
|
||||
if (a != null && Convert.ToBoolean(a.Value))
|
||||
oc.LinesForeground.Add(op);
|
||||
else
|
||||
oc.LinesBackground.Add(op);
|
||||
}
|
||||
nocrChars.Add(oc);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
return nocrChars;
|
||||
}
|
||||
|
||||
private static Point DecodePoint(string text)
|
||||
{
|
||||
var arr = text.Split(',');
|
||||
@ -3995,6 +4044,125 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return "<i>" + Utilities.RemoveHtmlTags(GetStringWithItalicTags(matches)) + "</i>";
|
||||
}
|
||||
|
||||
public string NocrFastCheck(Bitmap bitmap)
|
||||
{
|
||||
var nbmpInput = new NikseBitmap(bitmap);
|
||||
nbmpInput.ReplaceNonWhiteWithTransparent();
|
||||
//bitmap = nbmp.GetBitmap();
|
||||
|
||||
var matches = new List<CompareMatch>();
|
||||
List<ImageSplitterItem> list = NikseBitmapImageSplitter.SplitBitmapToLetters(nbmpInput, (int)numericUpDownNumberOfPixelsIsSpaceNOCR.Value, checkBoxRightToLeft.Checked, Configuration.Settings.VobSubOcr.TopToBottom);
|
||||
|
||||
foreach (ImageSplitterItem item in list)
|
||||
{
|
||||
if (item.NikseBitmap != null)
|
||||
{
|
||||
item.NikseBitmap.ReplaceNonWhiteWithTransparent();
|
||||
item.Y += item.NikseBitmap.CropTopTransparent(0);
|
||||
item.NikseBitmap.CropTransparentSidesAndBottom(0, true);
|
||||
item.NikseBitmap.ReplaceTransparentWith(Color.Black);
|
||||
}
|
||||
}
|
||||
int index = 0;
|
||||
var expandSelectionList = new List<ImageSplitterItem>();
|
||||
while (index < list.Count)
|
||||
{
|
||||
ImageSplitterItem item = list[index];
|
||||
if (item.NikseBitmap == null)
|
||||
{
|
||||
matches.Add(new CompareMatch(item.SpecialCharacter, false, 0, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
CompareMatch match = null; // = GetNOcrCompareMatch(item, bitmap, _nocrChars, _unItalicFactor, checkBoxNOcrItalic.Checked, !checkBoxNOcrCorrect.Checked);
|
||||
|
||||
var nbmp = item.NikseBitmap;
|
||||
int index2 = 0;
|
||||
int topMargin = item.Y - item.ParentY;
|
||||
foreach (NOcrChar oc in _nocrChars)
|
||||
{
|
||||
if (Math.Abs(oc.Width - nbmp.Width) < 3 && Math.Abs(oc.Height - nbmp.Height) < 4 && Math.Abs(oc.MarginTop - topMargin) < 4)
|
||||
{ // only very accurate matches
|
||||
|
||||
bool ok = true;
|
||||
index2 = 0;
|
||||
while (index2 < oc.LinesForeground.Count && ok)
|
||||
{
|
||||
NOcrPoint op = oc.LinesForeground[index2];
|
||||
foreach (Point point in op.ScaledGetPoints(oc, nbmp.Width, nbmp.Height))
|
||||
{
|
||||
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
|
||||
{
|
||||
Color c = nbmp.GetPixel(point.X, point.Y);
|
||||
if (c.A > 150 && c.R + c.G + c.B > NocrMinColor)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
Point p = new Point(point.X - 1, point.Y);
|
||||
if (p.X < 0)
|
||||
p.X = 1;
|
||||
c = nbmp.GetPixel(p.X, p.Y);
|
||||
if (nbmp.Width > 20 && c.A > 150 && c.R + c.G + c.B > NocrMinColor)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index2++;
|
||||
}
|
||||
index2 = 0;
|
||||
while (index2 < oc.LinesBackground.Count && ok)
|
||||
{
|
||||
NOcrPoint op = oc.LinesBackground[index2];
|
||||
foreach (Point point in op.ScaledGetPoints(oc, nbmp.Width, nbmp.Height))
|
||||
{
|
||||
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
|
||||
{
|
||||
Color c = nbmp.GetPixel(point.X, point.Y);
|
||||
if (c.A > 150 && c.R + c.G + c.B > NocrMinColor)
|
||||
{
|
||||
Point p = new Point(point.X, point.Y);
|
||||
if (oc.Width > 19 && point.X > 0)
|
||||
p.X = p.X - 1;
|
||||
c = nbmp.GetPixel(p.X, p.Y);
|
||||
if (c.A > 150 && c.R + c.G + c.B > NocrMinColor)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index2++;
|
||||
}
|
||||
if (ok)
|
||||
match = new CompareMatch(oc.Text, oc.Italic, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (match == null)
|
||||
{
|
||||
matches.Add(new CompareMatch("*", false, 0, null));
|
||||
}
|
||||
else // found image match
|
||||
{
|
||||
matches.Add(new CompareMatch(match.Text, match.Italic, 0, null));
|
||||
if (match.ExpandCount > 0)
|
||||
index += match.ExpandCount - 1;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return GetStringWithItalicTags(matches);
|
||||
}
|
||||
|
||||
static void NOcrThreadDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
var p = (NOcrThreadParameter)e.Argument;
|
||||
@ -4107,6 +4275,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (comboBoxOcrMethod.SelectedIndex == 0 && _tesseractAsyncStrings == null)
|
||||
{
|
||||
_nocrChars = null;
|
||||
_tesseractAsyncStrings = new string[max];
|
||||
_tesseractAsyncIndex = (int)numericUpDownStartNumber.Value + 5;
|
||||
_tesseractThread = new BackgroundWorker();
|
||||
@ -4948,6 +5117,38 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string tmp = Utilities.RemoveHtmlTags(line).Trim();
|
||||
if (!tmp.Trim().EndsWith("..."))
|
||||
{
|
||||
tmp = tmp.TrimEnd('.').TrimEnd();
|
||||
if (tmp.Length > 2 && Utilities.LowercaseLetters.Contains(tmp.Substring(tmp.Length - 1, 1)))
|
||||
{
|
||||
if (_nocrChars == null)
|
||||
_nocrChars = LoadNOcrForTesseract("Nikse.SubtitleEdit.Resources.nOCR_TesseractHelper.xml.zip");
|
||||
string text = Utilities.RemoveHtmlTags(NocrFastCheck(bitmap).TrimEnd());
|
||||
string post = string.Empty;
|
||||
if (line.EndsWith("</i>"))
|
||||
{
|
||||
post = "</i>";
|
||||
line = line.Remove(line.Length - 4, 4).Trim();
|
||||
}
|
||||
if (text.EndsWith("."))
|
||||
{
|
||||
line = line.TrimEnd('.').Trim();
|
||||
while (text.EndsWith(".") || text.EndsWith(" "))
|
||||
{
|
||||
line += text.Substring(text.Length - 1).Trim();
|
||||
text = text.Remove(text.Length - 1, 1);
|
||||
}
|
||||
}
|
||||
else if (text.EndsWith("l") && text.EndsWith("!") && !text.EndsWith("l!"))
|
||||
{
|
||||
line = line.Remove(line.Length - 1, 1) + "!";
|
||||
}
|
||||
line += post;
|
||||
}
|
||||
}
|
||||
|
||||
// Log used word guesses (via word replace list)
|
||||
foreach (string guess in _ocrFixEngine.AutoGuessesUsed)
|
||||
listBoxLogSuggestions.Items.Add(guess);
|
||||
|
@ -119,9 +119,18 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
var lines = new List<string>();
|
||||
StreamReader sr;
|
||||
if (useThisEncoding != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
sr = new StreamReader(fileName, useThisEncoding);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(exception.Message);
|
||||
encoding = Encoding.UTF8;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
|
@ -121,6 +121,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length > 1150 && fi.Length < 1024000) // not too small or too big
|
||||
@ -138,6 +140,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -542,6 +542,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length > 1024 + 128 && fi.Length < 1024000) // not too small or too big
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buffer = File.ReadAllBytes(fileName);
|
||||
EbuGeneralSubtitleInformation header = ReadHeader(buffer);
|
||||
@ -554,6 +556,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
return Utilities.IsInteger(header.CodePageNumber) || fileName.ToLower().EndsWith("stl");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -857,6 +857,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big
|
||||
@ -891,6 +893,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fi = new FileInfo(fileName);
|
||||
if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big
|
||||
@ -91,6 +93,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,16 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
return;
|
||||
}
|
||||
byte[] array = File.ReadAllBytes(fileName);
|
||||
byte[] array;
|
||||
try
|
||||
{
|
||||
array = File.ReadAllBytes(fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
return;
|
||||
}
|
||||
if (array.Length < 100)
|
||||
{
|
||||
return;
|
||||
|
BIN
src/Resources/nOCR_TesseractHelper.xml.zip
Normal file
BIN
src/Resources/nOCR_TesseractHelper.xml.zip
Normal file
Binary file not shown.
@ -1438,6 +1438,7 @@
|
||||
<EmbeddedResource Include="Resources\OpenOfficeDictionaries.xml.zip" />
|
||||
<EmbeddedResource Include="Resources\HunspellDictionaries.xml.zip" />
|
||||
<EmbeddedResource Include="Resources\TesseractDictionaries.xml.zip" />
|
||||
<EmbeddedResource Include="Resources\nOCR_TesseractHelper.xml.zip" />
|
||||
<None Include="Web References\MicrosoftTranslationService\GetTranslationsResponse.datasource">
|
||||
<DependentUpon>Reference.map</DependentUpon>
|
||||
</None>
|
||||
|
Loading…
Reference in New Issue
Block a user