Clamp stripe height to img height

No more out of range settings crashing the logic :)
This commit is contained in:
Kurt
2022-06-07 23:59:01 -07:00
parent c75f543f8b
commit a28c1b628e

View File

@@ -128,6 +128,9 @@ public static Image ApplyEncounterColor(IEncounterTemplate enc, Image img, Sprit
if (type == SpriteBackgroundType.BottomStripe)
{
int stripeHeight = SpriteBuilder.ShowEncounterThicknessStripe; // from bottom
if ((uint)stripeHeight > img.Height) // clamp negative & too-high values back to height.
stripeHeight = img.Height;
byte opacity = SpriteBuilder.ShowEncounterOpacityStripe;
return ImageUtil.ChangeTransparentTo(img, color, opacity, img.Width * 4 * (img.Height - stripeHeight));
}