mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 04:26:54 -05:00
Dispose of file-loaded bitmap after use
Image.FromFile locks the file until the object is disposed; adjust all uses of Image.FromFile to dispose when finished. Closes #3857 ty @SNBeast !
This commit is contained in:
@@ -288,9 +288,7 @@ private void SetFlagsFromFileName(string inpFileName)
|
||||
if (FileUtil.GetFileSize(inpFileName) > 2058)
|
||||
return; // 24*20*4(ARGB)=1920
|
||||
|
||||
Bitmap bmp; try { bmp = (Bitmap)Image.FromFile(inpFileName); }
|
||||
catch { return; }
|
||||
|
||||
using var bmp = (Bitmap)Image.FromFile(inpFileName);
|
||||
if (bmp.Width != 24 || bmp.Height != 20)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
@@ -38,8 +38,7 @@ private void B_ImportPNG_Click(object sender, EventArgs e)
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
Bitmap img = (Bitmap)Image.FromFile(ofd.FileName);
|
||||
|
||||
using var img = (Bitmap)Image.FromFile(ofd.FileName);
|
||||
try
|
||||
{
|
||||
bg = CGearImage.GetCGearBackground(img);
|
||||
|
||||
Reference in New Issue
Block a user