mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-18 00:13:10 +00:00
94baab1c45
With the approaching games, PKM sprites are a different size from the 3DS era (as already hinted by LGPE, which has 56x68). It'll be a little easier to manage with this portion of the library walled off from the rest of the codebase. Eventually the net46 target will use fody or something to merge in these extra dependency dll's automatically to not disturb the usual exe/dll experience.
33 lines
No EOL
1.1 KiB
C#
33 lines
No EOL
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using PKHeX.Core;
|
|
using PKHeX.Drawing;
|
|
|
|
namespace PKHeX.WinForms
|
|
{
|
|
public static class CGearExtensions
|
|
{
|
|
public static Bitmap GetBitmap(CGearBackground bg)
|
|
{
|
|
return ImageUtil.GetBitmap(bg.GetImageData(), CGearBackground.Width, CGearBackground.Height);
|
|
}
|
|
|
|
public static CGearBackground GetCGearBackground(Bitmap img)
|
|
{
|
|
const int Width = CGearBackground.Width;
|
|
const int Height = CGearBackground.Height;
|
|
if (img.Width != Width)
|
|
throw new ArgumentException($"Invalid image width. Expected {Width} pixels wide.");
|
|
if (img.Height != Height)
|
|
throw new ArgumentException($"Invalid image height. Expected {Height} pixels high.");
|
|
|
|
// get raw bytes of image
|
|
byte[] data = ImageUtil.GetPixelData(img);
|
|
const int bpp = 4;
|
|
Debug.Assert(data.Length == Width * Height * bpp);
|
|
|
|
return CGearBackground.GetBackground(data, bpp);
|
|
}
|
|
}
|
|
} |