Skip to content

Commit

Permalink
Editor: replaced few incorrect uses of GetSpriteBitmapAs32Bit()
Browse files Browse the repository at this point in the history
This fixes:
- Sprite export
- Copy sprite to clipboard
- Recreate spritefile

in case any sprite is non-32 bit.
  • Loading branch information
ivan-mogilko committed Aug 10, 2024
1 parent 76ef806 commit 0fbfe50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Editor/AGS.Editor/Panes/SpriteSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ private void SpriteContextMenuEventHandler(object sender, EventArgs e)
else if (item.Name == MENU_ITEM_COPY_TO_CLIPBOARD)
{
Sprite sprite = FindSpriteByNumber(_spriteNumberOnMenuActivation);
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmapAs32Bit(sprite.Number, sprite.Width, sprite.Height);
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmap(sprite.Number);

if (GetDesktopColourDepth() < 32 &&
(bmp.PixelFormat == PixelFormat.Format32bppArgb || bmp.PixelFormat == PixelFormat.Format32bppRgb))
Expand Down Expand Up @@ -1175,7 +1175,7 @@ private void CropSelectedSprites(bool symettric)

private void ExportSprite(string fileName, Sprite sprite)
{
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmapAs32Bit(sprite.Number, sprite.Width, sprite.Height);
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmap(sprite.Number);
ImportExport.ExportBitmapToFile(fileName, bmp);
bmp.Dispose();
}
Expand Down
4 changes: 2 additions & 2 deletions Editor/AGS.Editor/Utils/SpriteTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public static void ExportSprite(Sprite sprite, string path, bool updateSourcePat
}

ImageFormat format = sprite.ColorDepth < 32 && !sprite.AlphaChannel ? ImageFormat.Bmp : ImageFormat.Png;
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmapAs32Bit(sprite.Number, sprite.Width, sprite.Height);
Bitmap bmp = Factory.NativeProxy.GetSpriteBitmap(sprite.Number);
path = string.Format("{0}.{1}", path, format.ToString().ToLower());
bmp.Save(path, format);
bmp.Dispose();
Expand Down Expand Up @@ -678,7 +678,7 @@ public static void WriteSpriteFileFromSources(string filename, IWorkProgress pro
var bmp = LoadBitmapFromSource(sprite);
// TODO: this is quite suboptimal, find a way to retrieve a native handle instead?
if (bmp == null)
bmp = Factory.NativeProxy.GetSpriteBitmapAs32Bit(sprite.Number, sprite.Width, sprite.Height);
bmp = Factory.NativeProxy.GetSpriteBitmap(sprite.Number);

if (bmp != null)
{
Expand Down

0 comments on commit 0fbfe50

Please sign in to comment.