From d529bcadf45b6ef2914c6aab165b65262c6e1c59 Mon Sep 17 00:00:00 2001 From: MayNL Date: Mon, 30 Mar 2026 14:58:24 -0400 Subject: [PATCH] Fix crash when selecting invalid image file types --- PCK-Studio/Controls/PckEditor.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/PCK-Studio/Controls/PckEditor.cs b/PCK-Studio/Controls/PckEditor.cs index 21ca3ab9..54487926 100644 --- a/PCK-Studio/Controls/PckEditor.cs +++ b/PCK-Studio/Controls/PckEditor.cs @@ -906,10 +906,18 @@ namespace PckStudio.Controls case PckAssetType.CapeFile: case PckAssetType.TextureFile: { - Image img = asset.GetTexture(); - previewPictureBox.Image = img; - labelImageSize.Text = $"{previewPictureBox.Image.Size.Width}x{previewPictureBox.Image.Size.Height}"; + try + { + Image img = asset.GetTexture(); + previewPictureBox.Image = img; + labelImageSize.Text = $"{previewPictureBox.Image.Size.Width}x{previewPictureBox.Image.Size.Height}"; + } + catch(System.ArgumentException ex) + { + previewPictureBox.Image = Resources.NoImageFound; + MessageBox.Show(this, "Not a valid .PNG or .TGA image or invalid image data found"); + } if (asset.Type != PckAssetType.TextureFile) break;