mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Ocr via image-compare can now expand selection to the left (for right-to-left languages)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@242 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
3ebc31d79a
commit
6f38ad9d65
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
@ -10,7 +11,6 @@ using System.Xml;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using Nikse.SubtitleEdit.Logic.OCR;
|
||||
using Nikse.SubtitleEdit.Logic.VobSub;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
@ -163,6 +163,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
italicToolStripMenuItem.Text = Configuration.Settings.Language.General.Italic;
|
||||
saveImageAsToolStripMenuItem.Text = language.SaveSubtitleImageAs;
|
||||
saveAllImagesToolStripMenuItem.Text = language.SaveAllSubtitleImagesAs;
|
||||
checkBoxRightToLeft.Checked = Configuration.Settings.VobSubOcr.RightToLeft;
|
||||
|
||||
comboBoxTesseractLanguages.Left = labelTesseractLanguage.Left + labelTesseractLanguage.Width;
|
||||
|
||||
@ -764,6 +765,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (index+1 < list.Count && list[index+1].Bitmap != null) // only allow expand to EndOfLine or space
|
||||
{
|
||||
|
||||
index++;
|
||||
expandSelectionList.Add(list[index]);
|
||||
}
|
||||
@ -860,7 +862,25 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return line;
|
||||
}
|
||||
|
||||
private static ImageSplitterItem GetExpandedSelection(Bitmap bitmap, List<ImageSplitterItem> expandSelectionList)
|
||||
private ImageSplitterItem GetExpandedSelection(Bitmap bitmap, List<ImageSplitterItem> expandSelectionList)
|
||||
{
|
||||
if (checkBoxRightToLeft.Checked)
|
||||
{
|
||||
int minimumX = expandSelectionList[expandSelectionList.Count - 1].X - expandSelectionList[expandSelectionList.Count - 1].Bitmap.Width;
|
||||
int maximumX = expandSelectionList[0].X;
|
||||
int minimumY = expandSelectionList[0].Y;
|
||||
int maximumY = expandSelectionList[0].Y + expandSelectionList[0].Bitmap.Height;
|
||||
foreach (ImageSplitterItem item in expandSelectionList)
|
||||
{
|
||||
if (item.Y < minimumY)
|
||||
minimumY = item.Y;
|
||||
if (item.Y + item.Bitmap.Height > maximumY)
|
||||
maximumY = item.Y + item.Bitmap.Height;
|
||||
}
|
||||
Bitmap part = ImageSplitter.Copy(bitmap, new Rectangle(minimumX, minimumY, maximumX - minimumX, maximumY - minimumY));
|
||||
return new ImageSplitterItem(minimumX, minimumY, part);
|
||||
}
|
||||
else
|
||||
{
|
||||
int minimumX = expandSelectionList[0].X;
|
||||
int maximumX = expandSelectionList[expandSelectionList.Count - 1].X + expandSelectionList[expandSelectionList.Count - 1].Bitmap.Width;
|
||||
@ -876,6 +896,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Bitmap part = ImageSplitter.Copy(bitmap, new Rectangle(minimumX, minimumY, maximumX - minimumX, maximumY - minimumY));
|
||||
return new ImageSplitterItem(minimumX, minimumY, part);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetStringWithItalicTags(List<CompareMatch> matches)
|
||||
{
|
||||
@ -1064,6 +1085,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ButtonStartOcrClick(object sender, EventArgs e)
|
||||
{
|
||||
Configuration.Settings.VobSubOcr.RightToLeft = checkBoxRightToLeft.Checked;
|
||||
_lastLine = null;
|
||||
buttonOK.Enabled = false;
|
||||
buttonCancel.Enabled = false;
|
||||
|
@ -321,6 +321,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public int LastModiLanguageId { get; set; }
|
||||
public string LastOcrMethod { get; set; }
|
||||
public string TesseractLastLanguage { get; set; }
|
||||
public bool RightToLeft { get; set; }
|
||||
|
||||
public VobSubOcrSettings()
|
||||
{
|
||||
@ -329,6 +330,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
LastImageCompareFolder = "English";
|
||||
LastModiLanguageId = 9;
|
||||
LastOcrMethod = "Tesseract";
|
||||
RightToLeft = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -838,6 +840,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
subNode = node.SelectSingleNode("TesseractLastLanguage");
|
||||
if (subNode != null)
|
||||
settings.VobSubOcr.TesseractLastLanguage = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("RightToLeft");
|
||||
if (subNode != null)
|
||||
settings.VobSubOcr.RightToLeft = Convert.ToBoolean(subNode.InnerText);
|
||||
|
||||
foreach (XmlNode listNode in doc.DocumentElement.SelectNodes("MultipleSearchAndReplaceList/MultipleSearchAndReplaceItem"))
|
||||
{
|
||||
@ -1012,6 +1017,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
textWriter.WriteElementString("LastModiLanguageId", settings.VobSubOcr.LastModiLanguageId.ToString());
|
||||
textWriter.WriteElementString("LastOcrMethod", settings.VobSubOcr.LastOcrMethod);
|
||||
textWriter.WriteElementString("TesseractLastLanguage", settings.VobSubOcr.TesseractLastLanguage);
|
||||
textWriter.WriteElementString("RightToLeft", settings.VobSubOcr.RightToLeft.ToString());
|
||||
textWriter.WriteEndElement();
|
||||
|
||||
textWriter.WriteStartElement("MultipleSearchAndReplaceList", "");
|
||||
|
Loading…
Reference in New Issue
Block a user