mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-22 10:07:37 +00:00
* Fix Color Picker resource leak (#38122) Added a using statement to properly dispose of the Graphics object created from the Bitmap. This fixes resource leak. * Fix CI complain * Update MouseInfoProvider.cs fix whitespace --------- Co-authored-by: Kai Tao <69313318+vanzue@users.noreply.github.com>
This commit is contained in:
parent
d986592737
commit
bec6754aa3
@ -104,8 +104,10 @@ namespace ColorPicker.Mouse
|
|||||||
var rect = new Rectangle((int)mousePosition.X, (int)mousePosition.Y, 1, 1);
|
var rect = new Rectangle((int)mousePosition.X, (int)mousePosition.Y, 1, 1);
|
||||||
using (var bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb))
|
using (var bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb))
|
||||||
{
|
{
|
||||||
var g = Graphics.FromImage(bmp);
|
using (var g = Graphics.FromImage(bmp)) // Ensure Graphics object is disposed
|
||||||
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
|
{
|
||||||
|
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
|
||||||
|
}
|
||||||
|
|
||||||
return bmp.GetPixel(0, 0);
|
return bmp.GetPixel(0, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user