Remove layer null check

Move to the place that triggered the null
This commit is contained in:
Kurt 2020-10-30 19:56:16 -07:00
parent a33120c93e
commit 80a5d8e451
2 changed files with 3 additions and 4 deletions

View file

@ -16,10 +16,8 @@ namespace PKHeX.Drawing
return LayerImage(baseLayer, overLayer, x, y); return LayerImage(baseLayer, overLayer, x, y);
} }
public static Bitmap LayerImage(Image? baseLayer, Image overLayer, int x, int y) public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y)
{ {
if (baseLayer is null)
return (Bitmap)overLayer;
Bitmap img = new Bitmap(baseLayer); Bitmap img = new Bitmap(baseLayer);
using Graphics gr = Graphics.FromImage(img); using Graphics gr = Graphics.FromImage(img);
gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height); gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height);

View file

@ -108,6 +108,7 @@ namespace PKHeX.WinForms.Controls
frame = ImageUtil.GetBitmap(frameData, imgWidth, imgHeight); frame = ImageUtil.GetBitmap(frameData, imgWidth, imgHeight);
if (ExtraLayer != null) if (ExtraLayer != null)
frame = ImageUtil.LayerImage(frame, ExtraLayer, 0, 0); frame = ImageUtil.LayerImage(frame, ExtraLayer, 0, 0);
if (OriginalBackground != null)
frame = ImageUtil.LayerImage(OriginalBackground, frame, 0, 0); frame = ImageUtil.LayerImage(OriginalBackground, frame, 0, 0);
return GlowCache[frameIndex] = frame; return GlowCache[frameIndex] = frame;
} }