diff --git a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs index 76c376b761..c28dcc1ae6 100644 --- a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs +++ b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseInfoProvider.cs @@ -104,8 +104,10 @@ namespace ColorPicker.Mouse var rect = new Rectangle((int)mousePosition.X, (int)mousePosition.Y, 1, 1); using (var bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb)) { - var g = Graphics.FromImage(bmp); - g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); + using (var g = Graphics.FromImage(bmp)) // Ensure Graphics object is disposed + { + g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy); + } return bmp.GetPixel(0, 0); }