mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Working on ocr
This commit is contained in:
parent
71c534c215
commit
7171bd0973
@ -6792,6 +6792,20 @@
|
||||
<Word from="fllr" to="für" />
|
||||
<Word from="fllrchterlich" to="fürchterlich" />
|
||||
<Word from="flndet" to="findet" />
|
||||
<Word from="AIle" to="Alle" />
|
||||
<Word from="AIter" to="Alter" />
|
||||
<Word from="GIück" to="Glück" />
|
||||
<Word from="PIaystation" to="Playstation" />
|
||||
<Word from="AIIes" to="Alles" />
|
||||
<Word from="AIso" to="Also" />
|
||||
<Word from="Ouatsch" to="Quatsch" />
|
||||
<Word from="AIles" to="Alles" />
|
||||
<Word from="BIeib" to="Bleib" />
|
||||
<Word from="KIaut" to="Klaut" />
|
||||
<Word from="AIlah" to="Allah" />
|
||||
<Word from="PIan" to="Plan" />
|
||||
<Word from="oderjemand" to="oder jemand" />
|
||||
<Word from="liestjetzt" to="liest jetzt" />
|
||||
</WholeWords>
|
||||
<PartialWordsAlways>
|
||||
<!-- Will be replaced always -->
|
||||
|
235
src/Forms/VobSubCharactersImport.Designer.cs
generated
Normal file
235
src/Forms/VobSubCharactersImport.Designer.cs
generated
Normal file
@ -0,0 +1,235 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
sealed partial class VobSubCharactersImport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
this.ColumnImport = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.ColumnText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.buttonImport = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.buttonFixesSelectAll = new System.Windows.Forms.Button();
|
||||
this.buttonFixesInverse = new System.Windows.Forms.Button();
|
||||
this.labelInfo = new System.Windows.Forms.Label();
|
||||
this.groupBoxCurrentImage = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.labelCurrentImage = new System.Windows.Forms.Label();
|
||||
this.buttonDone = new System.Windows.Forms.Button();
|
||||
this.groupBoxCurrentImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.listView1.CheckBoxes = true;
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.ColumnImport,
|
||||
this.ColumnText});
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.GridLines = true;
|
||||
this.listView1.HideSelection = false;
|
||||
this.listView1.Location = new System.Drawing.Point(12, 56);
|
||||
this.listView1.MultiSelect = false;
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.Size = new System.Drawing.Size(450, 426);
|
||||
this.listView1.TabIndex = 0;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
|
||||
//
|
||||
// ColumnImport
|
||||
//
|
||||
this.ColumnImport.Text = "Import";
|
||||
this.ColumnImport.Width = 80;
|
||||
//
|
||||
// ColumnText
|
||||
//
|
||||
this.ColumnText.Text = "Text";
|
||||
this.ColumnText.Width = 340;
|
||||
//
|
||||
// buttonImport
|
||||
//
|
||||
this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonImport.Location = new System.Drawing.Point(337, 493);
|
||||
this.buttonImport.Name = "buttonImport";
|
||||
this.buttonImport.Size = new System.Drawing.Size(125, 21);
|
||||
this.buttonImport.TabIndex = 4;
|
||||
this.buttonImport.Text = "I&mport";
|
||||
this.buttonImport.UseVisualStyleBackColor = true;
|
||||
this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(759, 493);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
|
||||
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
//
|
||||
// buttonFixesSelectAll
|
||||
//
|
||||
this.buttonFixesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonFixesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonFixesSelectAll.Location = new System.Drawing.Point(12, 493);
|
||||
this.buttonFixesSelectAll.Name = "buttonFixesSelectAll";
|
||||
this.buttonFixesSelectAll.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonFixesSelectAll.TabIndex = 105;
|
||||
this.buttonFixesSelectAll.Text = "Select &all";
|
||||
this.buttonFixesSelectAll.UseVisualStyleBackColor = true;
|
||||
this.buttonFixesSelectAll.Click += new System.EventHandler(this.buttonFixesSelectAll_Click);
|
||||
//
|
||||
// buttonFixesInverse
|
||||
//
|
||||
this.buttonFixesInverse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonFixesInverse.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonFixesInverse.Location = new System.Drawing.Point(93, 493);
|
||||
this.buttonFixesInverse.Name = "buttonFixesInverse";
|
||||
this.buttonFixesInverse.Size = new System.Drawing.Size(100, 21);
|
||||
this.buttonFixesInverse.TabIndex = 106;
|
||||
this.buttonFixesInverse.Text = "&Inverse selection";
|
||||
this.buttonFixesInverse.UseVisualStyleBackColor = true;
|
||||
this.buttonFixesInverse.Click += new System.EventHandler(this.buttonFixesInverse_Click);
|
||||
//
|
||||
// labelInfo
|
||||
//
|
||||
this.labelInfo.AutoSize = true;
|
||||
this.labelInfo.Location = new System.Drawing.Point(12, 22);
|
||||
this.labelInfo.Name = "labelInfo";
|
||||
this.labelInfo.Size = new System.Drawing.Size(47, 13);
|
||||
this.labelInfo.TabIndex = 107;
|
||||
this.labelInfo.Text = "labelInfo";
|
||||
//
|
||||
// groupBoxCurrentImage
|
||||
//
|
||||
this.groupBoxCurrentImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBoxCurrentImage.Controls.Add(this.pictureBox1);
|
||||
this.groupBoxCurrentImage.Controls.Add(this.labelCurrentImage);
|
||||
this.groupBoxCurrentImage.Location = new System.Drawing.Point(469, 56);
|
||||
this.groupBoxCurrentImage.Name = "groupBoxCurrentImage";
|
||||
this.groupBoxCurrentImage.Size = new System.Drawing.Size(365, 426);
|
||||
this.groupBoxCurrentImage.TabIndex = 108;
|
||||
this.groupBoxCurrentImage.TabStop = false;
|
||||
this.groupBoxCurrentImage.Text = "Current image";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.BackColor = System.Drawing.Color.Red;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(19, 107);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(52, 52);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.pictureBox1.TabIndex = 109;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// labelCurrentImage
|
||||
//
|
||||
this.labelCurrentImage.AutoSize = true;
|
||||
this.labelCurrentImage.Location = new System.Drawing.Point(16, 30);
|
||||
this.labelCurrentImage.Name = "labelCurrentImage";
|
||||
this.labelCurrentImage.Size = new System.Drawing.Size(88, 13);
|
||||
this.labelCurrentImage.TabIndex = 108;
|
||||
this.labelCurrentImage.Text = "CurrentImageInfo";
|
||||
//
|
||||
// buttonDone
|
||||
//
|
||||
this.buttonDone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDone.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonDone.Location = new System.Drawing.Point(628, 493);
|
||||
this.buttonDone.Name = "buttonDone";
|
||||
this.buttonDone.Size = new System.Drawing.Size(125, 21);
|
||||
this.buttonDone.TabIndex = 109;
|
||||
this.buttonDone.Text = "&Done";
|
||||
this.buttonDone.UseVisualStyleBackColor = true;
|
||||
this.buttonDone.Click += new System.EventHandler(this.buttonDone_Click);
|
||||
//
|
||||
// VobSubCharactersImport
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(846, 526);
|
||||
this.Controls.Add(this.buttonDone);
|
||||
this.Controls.Add(this.groupBoxCurrentImage);
|
||||
this.Controls.Add(this.labelInfo);
|
||||
this.Controls.Add(this.buttonFixesSelectAll);
|
||||
this.Controls.Add(this.buttonFixesInverse);
|
||||
this.Controls.Add(this.buttonImport);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Name = "VobSubCharactersImport";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Shown += new System.EventHandler(this.VobSubCharactersImport_Shown);
|
||||
this.groupBoxCurrentImage.ResumeLayout(false);
|
||||
this.groupBoxCurrentImage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView listView1;
|
||||
private System.Windows.Forms.Button buttonImport;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.ColumnHeader ColumnImport;
|
||||
private System.Windows.Forms.ColumnHeader ColumnText;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.Button buttonFixesSelectAll;
|
||||
private System.Windows.Forms.Button buttonFixesInverse;
|
||||
private System.Windows.Forms.Label labelInfo;
|
||||
private System.Windows.Forms.GroupBox groupBoxCurrentImage;
|
||||
private System.Windows.Forms.Label labelCurrentImage;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button buttonDone;
|
||||
}
|
||||
}
|
220
src/Forms/VobSubCharactersImport.cs
Normal file
220
src/Forms/VobSubCharactersImport.cs
Normal file
@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Nikse.SubtitleEdit.Core;
|
||||
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public sealed partial class VobSubCharactersImport : Form
|
||||
{
|
||||
|
||||
public class ListViewData
|
||||
{
|
||||
public bool Checked { get; set; }
|
||||
public BinaryOcrBitmap BinaryOcrBitmap { get; set; }
|
||||
}
|
||||
|
||||
private readonly BinaryOcrDb _existingDb;
|
||||
private readonly List<ListViewData> _data = new List<ListViewData>();
|
||||
private int _selectCount;
|
||||
|
||||
public VobSubCharactersImport(BinaryOcrDb binaryOcrDb)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_existingDb = binaryOcrDb;
|
||||
|
||||
labelInfo.Text = string.Empty;
|
||||
labelCurrentImage.Text = string.Empty;
|
||||
Text = string.Format("Import OCR images into \"{0}\"", Path.GetFileName(_existingDb.FileName));
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
}
|
||||
|
||||
private void VobSubCharactersImport_Shown(object sender, EventArgs e)
|
||||
{
|
||||
openFileDialog1.Filter = "Binary OCR db files|*.db";
|
||||
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
imageList1.ImageSize = new Size(40, 40);
|
||||
LoadImagesInListView();
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
listView1.ItemChecked += listView1_ItemChecked;
|
||||
UpdateSelectCount();
|
||||
}
|
||||
|
||||
private void LoadImagesInListView()
|
||||
{
|
||||
int existingMatches = 0;
|
||||
listView1.SmallImageList = imageList1;
|
||||
listView1.BeginUpdate();
|
||||
var importDb = new BinaryOcrDb(openFileDialog1.FileName, true);
|
||||
var list = new List<BinaryOcrBitmap>();
|
||||
list.AddRange(importDb.CompareImages);
|
||||
list.AddRange(importDb.CompareImagesExpanded);
|
||||
foreach (var bob in list.OrderBy(p => p.Text))
|
||||
{
|
||||
if (bob.ExpandCount > 0 && _existingDb.FindExactMatchExpanded(bob) < 0)
|
||||
{
|
||||
AddToListView(bob);
|
||||
}
|
||||
else if (bob.ExpandCount == 0 && _existingDb.FindExactMatch(bob) < 0)
|
||||
{
|
||||
AddToListView(bob);
|
||||
}
|
||||
else
|
||||
{
|
||||
existingMatches++;
|
||||
}
|
||||
}
|
||||
listView1.EndUpdate();
|
||||
if (listView1.Items.Count > 0)
|
||||
{
|
||||
listView1.Items[0].Selected = true;
|
||||
listView1.Items[0].Focused = true;
|
||||
}
|
||||
labelInfo.Text = string.Format("Images found not in current db: {0:#,##0} ({1:#,##0} matches already in current db)", imageList1.Images.Count, existingMatches);
|
||||
}
|
||||
|
||||
private void AddToListView(BinaryOcrBitmap bob)
|
||||
{
|
||||
_data.Add(new ListViewData { Checked = true, BinaryOcrBitmap = bob });
|
||||
|
||||
var item = new ListViewItem(string.Empty) { Tag = bob, Checked = true };
|
||||
item.SubItems.Add(bob.ToString());
|
||||
listView1.Items.Add(item);
|
||||
imageList1.Images.Add(bob.ToOldBitmap(Color.Black));
|
||||
item.ImageIndex = imageList1.Images.Count - 1;
|
||||
}
|
||||
|
||||
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (listView1.SelectedItems.Count < 1)
|
||||
return;
|
||||
|
||||
var item = listView1.SelectedItems[0];
|
||||
var bob = (BinaryOcrBitmap)item.Tag;
|
||||
labelCurrentImage.Text = "Text: " + bob.Text + Environment.NewLine +
|
||||
"Size: " + bob.Width + "x" + bob.Height + Environment.NewLine +
|
||||
"Italic: " + (bob.Italic ? "Yes" : "No") + Environment.NewLine;
|
||||
|
||||
if (pictureBox1.Image != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var b = (Bitmap)pictureBox1.Image;
|
||||
b.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var bmp = bob.ToOldBitmap();
|
||||
pictureBox1.Image = bmp;
|
||||
pictureBox1.Width = bmp.Width + 2;
|
||||
pictureBox1.Height = bmp.Height + 2;
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
}
|
||||
|
||||
private void buttonFixesSelectAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
listView1.ItemChecked -= listView1_ItemChecked;
|
||||
|
||||
foreach (ListViewItem item in listView1.Items)
|
||||
item.Checked = true;
|
||||
|
||||
foreach (ListViewData d in _data)
|
||||
d.Checked = true;
|
||||
|
||||
UpdateSelectCount();
|
||||
|
||||
listView1.ItemChecked += listView1_ItemChecked;
|
||||
|
||||
}
|
||||
|
||||
private void buttonFixesInverse_Click(object sender, EventArgs e)
|
||||
{
|
||||
listView1.ItemChecked -= listView1_ItemChecked;
|
||||
|
||||
foreach (ListViewItem item in listView1.Items)
|
||||
item.Checked = !item.Checked;
|
||||
|
||||
foreach (ListViewData d in _data)
|
||||
d.Checked = !d.Checked;
|
||||
|
||||
UpdateSelectCount();
|
||||
|
||||
listView1.ItemChecked += listView1_ItemChecked;
|
||||
}
|
||||
|
||||
private void buttonDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
|
||||
{
|
||||
if (e.Item == null)
|
||||
return;
|
||||
|
||||
var idx = e.Item.Index;
|
||||
_data[idx].Checked = listView1.Items[idx].Checked;
|
||||
UpdateSelectCount();
|
||||
}
|
||||
|
||||
private void UpdateSelectCount()
|
||||
{
|
||||
_selectCount = 0;
|
||||
foreach (ListViewData d in _data)
|
||||
{
|
||||
if (d.Checked)
|
||||
{
|
||||
_selectCount++;
|
||||
}
|
||||
}
|
||||
buttonImport.Text = string.Format("Import {0:#,##0}", _selectCount);
|
||||
}
|
||||
|
||||
private void buttonImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (ListViewData d in _data)
|
||||
{
|
||||
if (d.Checked)
|
||||
{
|
||||
if (d.BinaryOcrBitmap.ExpandCount == 0 && _existingDb.FindExactMatch(d.BinaryOcrBitmap) < 0)
|
||||
{
|
||||
count++;
|
||||
_existingDb.Add(d.BinaryOcrBitmap);
|
||||
}
|
||||
else if (d.BinaryOcrBitmap.ExpandCount > 0 && _existingDb.FindExactMatchExpanded(d.BinaryOcrBitmap) < 0)
|
||||
{
|
||||
count++;
|
||||
_existingDb.Add(d.BinaryOcrBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
_existingDb.Save();
|
||||
MessageBox.Show(string.Format("{0:#,##0} images imported", count));
|
||||
|
||||
// reload
|
||||
listView1.ItemChecked -= listView1_ItemChecked;
|
||||
listView1.Items.Clear();
|
||||
_data.Clear();
|
||||
imageList1.Images.Clear();
|
||||
LoadImagesInListView();
|
||||
listView1.ItemChecked += listView1_ItemChecked;
|
||||
UpdateSelectCount();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
126
src/Forms/VobSubCharactersImport.resx
Normal file
126
src/Forms/VobSubCharactersImport.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>157, 17</value>
|
||||
</metadata>
|
||||
</root>
|
16
src/Forms/VobSubEditCharacters.Designer.cs
generated
16
src/Forms/VobSubEditCharacters.Designer.cs
generated
@ -50,6 +50,7 @@
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.groupBoxCurrentCompareImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
@ -262,11 +263,25 @@
|
||||
this.labelCount.TabIndex = 8;
|
||||
this.labelCount.Text = "labelCount";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.button1.Location = new System.Drawing.Point(453, 27);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(123, 21);
|
||||
this.button1.TabIndex = 9;
|
||||
this.button1.Text = "&Import";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// VobSubEditCharacters
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(588, 426);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.groupBoxCurrentCompareImage);
|
||||
@ -319,5 +334,6 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem;
|
||||
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
|
||||
private System.Windows.Forms.Label labelExpandCount;
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
@ -278,9 +278,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bmp = bob.ToOldBitmap();
|
||||
labelImageInfo.Text = string.Format("Top:{0}, {1} colored pixels of {2}", bob.Y, bob.NumberOfColoredPixels, (bob.Width * bob.Height));
|
||||
|
||||
//bool italicI;
|
||||
//var isI = bob.IsLowercaseI(out italicI);
|
||||
//labelImageInfo.Text = string.Format("T:{0} j{1} :{2} i{3}{4} '{5} #{6}/{7}", bob.Y, bob.IsLowercaseJ(), bob.IsColon(), isI, italicI ? "i" : "", bob.IsApostrophe(), bob.NumberOfColoredPixels, (bob.Width * bob.Height));
|
||||
bool italicI;
|
||||
var isI = bob.IsLowercaseI(out italicI);
|
||||
labelImageInfo.Text = string.Format("T:{0} j{1} :{2} i{3}{4} '{5} #{6}/{7}", bob.Y, bob.IsLowercaseJ(), bob.IsColon(), isI, italicI ? "i" : "", bob.IsApostrophe(), bob.NumberOfColoredPixels, (bob.Width * bob.Height));
|
||||
|
||||
if (bob.ExpandCount > 0)
|
||||
{
|
||||
@ -635,5 +635,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var form = new VobSubCharactersImport(_binOcrDb))
|
||||
{
|
||||
form.ShowDialog(this);
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,11 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary
|
||||
}
|
||||
|
||||
public Bitmap ToOldBitmap()
|
||||
{
|
||||
return ToOldBitmap(Color.White);
|
||||
}
|
||||
|
||||
public Bitmap ToOldBitmap(Color color)
|
||||
{
|
||||
if (ExpandedList != null && ExpandedList.Count > 0)
|
||||
{
|
||||
@ -274,7 +279,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary
|
||||
}
|
||||
}
|
||||
|
||||
return nbmp.ToOldBitmap(); // Resursive
|
||||
return nbmp.ToOldBitmap(color); // Resursive
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,7 +290,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary
|
||||
{
|
||||
Color c = Color.Transparent;
|
||||
if (GetPixel(x, y) > 0)
|
||||
c = Color.White;
|
||||
c = color;
|
||||
nbmp.SetPixel(x, y, c);
|
||||
}
|
||||
}
|
||||
|
@ -721,6 +721,12 @@
|
||||
<Compile Include="Forms\VisualSync.Designer.cs">
|
||||
<DependentUpon>VisualSync.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\VobSubCharactersImport.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\VobSubCharactersImport.Designer.cs">
|
||||
<DependentUpon>VobSubCharactersImport.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\VobSubEditCharacters.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -1206,6 +1212,9 @@
|
||||
<DependentUpon>VisualSync.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\VobSubCharactersImport.resx">
|
||||
<DependentUpon>VobSubCharactersImport.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\VobSubNOcrCharacterInspect.resx">
|
||||
<DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Loading…
Reference in New Issue
Block a user