Skip to content

Commit

Permalink
Update SpritesheetEditor.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
GZHYBFHHJ committed Apr 10, 2024
1 parent 22f31bf commit 560bffe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ABStudio/Forms/SpritesheetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ private static string[] GenerateSaveExtensionTable(bool allowPVR)

public SpritesheetEditor(string path, DATFile file)
{
spritesheet = new Bitmap(1, 1);

InitializeComponent();

originalPath = path;
Expand Down Expand Up @@ -499,6 +497,14 @@ private void LoadBitmap(string path=null)

private void RefreshZoom()
{
if (spritesheet == null)
{
// On some computers, this method may be called by `InitializeComponent` in the class constructor.
// In this case, `spritesheet` is null, which can cause NullReferenceException to be thrown.

spritesheet = new Bitmap(1, 1);
}

float w = spritesheet.Width * zoom;
float h = spritesheet.Height * zoom;

Expand Down

0 comments on commit 560bffe

Please sign in to comment.