mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-09-23 09:12:56 +00:00
Add exception check for empty texture
This commit is contained in:
@@ -1118,7 +1118,7 @@ namespace PckStudio.Controls
|
|||||||
previewPictureBox.Image = img;
|
previewPictureBox.Image = img;
|
||||||
labelImageSize.Text = $"{previewPictureBox.Image.Size.Width}x{previewPictureBox.Image.Size.Height}";
|
labelImageSize.Text = $"{previewPictureBox.Image.Size.Width}x{previewPictureBox.Image.Size.Height}";
|
||||||
}
|
}
|
||||||
catch(System.ArgumentException ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
previewPictureBox.Image = Resources.NoImageFound;
|
previewPictureBox.Image = Resources.NoImageFound;
|
||||||
MessageBox.Show(this, "Not a valid .PNG or .TGA image or invalid image data found");
|
MessageBox.Show(this, "Not a valid .PNG or .TGA image or invalid image data found");
|
||||||
@@ -1803,11 +1803,10 @@ namespace PckStudio.Controls
|
|||||||
{
|
{
|
||||||
TreeNode node = treeViewMain.SelectedNode;
|
TreeNode node = treeViewMain.SelectedNode;
|
||||||
|
|
||||||
// abb = "Abbreviated Path"
|
string abbreviatedPath = Path.GetDirectoryName(asset.Filename);
|
||||||
string abbPath = Path.GetDirectoryName(asset.Filename);
|
int startIndex = abbreviatedPath.IndexOf(node.Text);
|
||||||
int startIndex = abbPath.IndexOf(node.Text);
|
abbreviatedPath = abbreviatedPath.Substring(startIndex, abbreviatedPath.Length - startIndex);
|
||||||
abbPath = abbPath.Substring(startIndex, abbPath.Length - startIndex);
|
string finalPath = ($"{outPath}/{abbreviatedPath}/").Replace('\\', '/');
|
||||||
string finalPath = ($"{outPath}/{abbPath}/").Replace('\\', '/');
|
|
||||||
|
|
||||||
if (!Directory.Exists(finalPath))
|
if (!Directory.Exists(finalPath))
|
||||||
Directory.CreateDirectory(finalPath);
|
Directory.CreateDirectory(finalPath);
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ namespace PckStudio.Core.Extensions
|
|||||||
{
|
{
|
||||||
throw new Exception("Asset is not suitable to contain image data.");
|
throw new Exception("Asset is not suitable to contain image data.");
|
||||||
}
|
}
|
||||||
|
if (asset.Size == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Asset is has no data.");
|
||||||
|
}
|
||||||
return asset.GetDeserializedData(ImageDeserializer.DefaultDeserializer);
|
return asset.GetDeserializedData(ImageDeserializer.DefaultDeserializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user