Skip to content

Commit

Permalink
Fixed bug preventing indexed PNGs from being imported
Browse files Browse the repository at this point in the history
  • Loading branch information
sosuke3 committed Feb 17, 2018
1 parent 40a71c6 commit 727a76f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ZSpriteTools/ZSpriteToolForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@ private void importPNGToolStripMenuItem_Click(object sender, EventArgs e)
if (result == DialogResult.OK)
{
Bitmap tempBitmap = (Bitmap)Image.FromFile(ofd.FileName);
if(tempBitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb)
{
var clone = new Bitmap(tempBitmap.Width, tempBitmap.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics gr = Graphics.FromImage(clone))
{
gr.DrawImage(tempBitmap, new Rectangle(0, 0, tempBitmap.Width, tempBitmap.Height));
}
tempBitmap = clone;
}
if (tempBitmap.Width != 128 || tempBitmap.Height != 448)
{
MessageBox.Show("Invalid PNG image. Must be 128 x 448 pixels", "Error");
Expand Down

0 comments on commit 727a76f

Please sign in to comment.