From a1f9a28f96b2fe2fe7233ce680ccb3075991ec43 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 01:16:29 +0000 Subject: [PATCH 1/3] Initial plan From 06c4f510c25275707fd90b29de18024a69136bde Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 01:20:35 +0000 Subject: [PATCH 2/3] Fix bitmap disposal, isDrawing reset, and indentation per review comments Co-authored-by: TheJoeFin <7809853+TheJoeFin@users.noreply.github.com> --- Text-Grab/Utilities/OcrUtilities.cs | 4 ++-- Text-Grab/Views/GrabFrame.xaml.cs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Text-Grab/Utilities/OcrUtilities.cs b/Text-Grab/Utilities/OcrUtilities.cs index fcaa4c20..cc794ebf 100644 --- a/Text-Grab/Utilities/OcrUtilities.cs +++ b/Text-Grab/Utilities/OcrUtilities.cs @@ -133,7 +133,7 @@ public static async Task GetRegionsTextAsTableAsync(Window passedWindow, int thisCorrectedTop = (int)absPosPoint.Y + selectedRegion.Top; Rectangle correctedRegion = new(thisCorrectedLeft, thisCorrectedTop, selectedRegion.Width, selectedRegion.Height); - Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(correctedRegion); + using Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(correctedRegion); double scale = await GetIdealScaleFactorForOcrAsync(bmp, compatibleLanguage); using Bitmap scaledBitmap = ImageMethods.ScaleBitmapUniform(bmp, scale); DpiScale dpiScale = VisualTreeHelper.GetDpi(passedWindow); @@ -212,7 +212,7 @@ public static async Task GetTextFromBitmapSourceAsTableAsync(BitmapSourc public static async Task<(IOcrLinesWords?, double)> GetOcrResultFromRegionAsync(Rectangle region, ILanguage language) { language = GetCompatibleOcrLanguage(language); - Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(region); + using Bitmap bmp = ImageMethods.GetRegionOfScreenAsBitmap(region); if (language is WindowsAiLang) { diff --git a/Text-Grab/Views/GrabFrame.xaml.cs b/Text-Grab/Views/GrabFrame.xaml.cs index 949000f6..44d9a1e3 100644 --- a/Text-Grab/Views/GrabFrame.xaml.cs +++ b/Text-Grab/Views/GrabFrame.xaml.cs @@ -1387,7 +1387,11 @@ private async Task DrawOcrRectanglesAsync(string searchWord = "") } if (ocrResultOfWindow is null) + { + isDrawing = false; + reDrawTimer.Start(); return; + } isSpaceJoining = CurrentLanguage!.IsSpaceJoining(); @@ -2687,7 +2691,7 @@ private void ResetGrabFrame() if (!hasLoadedImageSource) frameContentImageSource = null; - ClearRenderedWordBorders(); + ClearRenderedWordBorders(); MatchesTXTBLK.Text = "- Matches"; UpdateFrameText(); } From 1fcc08a4c9696bb523b6697fd80c6f1af0a987b2 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Sat, 7 Mar 2026 19:41:32 -0600 Subject: [PATCH 3/3] Remove using statement for selectionBitmap in table OCR Disposing selectionBitmap with a using statement caused app crashes. Now, the bitmap is not disposed immediately, and a comment was added to highlight the issue and the need for further investigation. --- Text-Grab/Views/FullscreenGrab.SelectionStyles.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Text-Grab/Views/FullscreenGrab.SelectionStyles.cs b/Text-Grab/Views/FullscreenGrab.SelectionStyles.cs index c518740e..777e916d 100644 --- a/Text-Grab/Views/FullscreenGrab.SelectionStyles.cs +++ b/Text-Grab/Views/FullscreenGrab.SelectionStyles.cs @@ -1064,7 +1064,9 @@ private async Task CommitSelectionAsync(FullscreenCaptureResult selection, bool } else if (isTable) { - using Bitmap selectionBitmap = ImageMethods.GetRegionOfScreenAsBitmap(selection.CaptureRegion.AsRectangle()); + // TODO: Look into why this happens and find a better way to dispose the bitmap + // DO NOT add a using statement to this selected bitmap, it crashes the app + Bitmap selectionBitmap = ImageMethods.GetRegionOfScreenAsBitmap(selection.CaptureRegion.AsRectangle()); TextFromOCR = await OcrUtilities.GetTextFromBitmapAsTableAsync(selectionBitmap, selectedOcrLang); } else