From acef8c4fbe36946c8554b724d1b5fa038335ad56 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Mon, 1 Jun 2020 13:25:34 +0200 Subject: [PATCH] Fix nOCR issue with expanded match --- src/Forms/Ocr/AddBetterMultiMatchNOcr.cs | 2 +- src/Forms/Ocr/VobSubNOcrCharacterInspect.cs | 15 ++++++++++++++- src/Logic/Ocr/NOcrDb.cs | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Forms/Ocr/AddBetterMultiMatchNOcr.cs b/src/Forms/Ocr/AddBetterMultiMatchNOcr.cs index 75d6aa45d..78f076f68 100644 --- a/src/Forms/Ocr/AddBetterMultiMatchNOcr.cs +++ b/src/Forms/Ocr/AddBetterMultiMatchNOcr.cs @@ -32,7 +32,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr UiUtil.FixLargeFonts(this, buttonOK); } - internal void Initialize(System.Drawing.Bitmap bitmap, int selectedIndex, List matches, List splitterItems) + internal void Initialize(Bitmap bitmap, int selectedIndex, List matches, List splitterItems) { _wholeImage = new NikseBitmap(bitmap); _startIndex = selectedIndex; diff --git a/src/Forms/Ocr/VobSubNOcrCharacterInspect.cs b/src/Forms/Ocr/VobSubNOcrCharacterInspect.cs index a9c2fd0b6..b16f5ca9d 100644 --- a/src/Forms/Ocr/VobSubNOcrCharacterInspect.cs +++ b/src/Forms/Ocr/VobSubNOcrCharacterInspect.cs @@ -385,8 +385,21 @@ namespace Nikse.SubtitleEdit.Forms.Ocr { using (var form = new AddBetterMultiMatchNOcr()) { + var tempImageList = new List(); var idx = _indexLookup[listBoxInspectItems.SelectedIndex]; - form.Initialize(_bitmap, idx, _matchList, _imageList); + for (int i = idx; i < _imageList.Count; i++) + { + tempImageList.Add(_imageList[i]); + } + + var tempMatchList = new List(); + idx = listBoxInspectItems.SelectedIndex; + for (int i = idx; i < _matchList.Count; i++) + { + tempMatchList.Add(_matchList[i]); + } + + form.Initialize(_bitmap, 0, tempMatchList, tempImageList); if (form.ShowDialog(this) == DialogResult.OK) { _nocrDb.Add(form.NOcrChar); diff --git a/src/Logic/Ocr/NOcrDb.cs b/src/Logic/Ocr/NOcrDb.cs index 6dbeebf80..94960b6f6 100644 --- a/src/Logic/Ocr/NOcrDb.cs +++ b/src/Logic/Ocr/NOcrDb.cs @@ -235,7 +235,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr private static Point GetTotalSize(int listIndex, List items, int count) { - if (listIndex + count >= items.Count) + if (listIndex + count > items.Count) { return new Point(-100, -100); }