1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 18:23:21 +08:00

Merge pull request #25318 from peppy/fix-follow-point-scrathces

Fix potential texture corruption when cropping gameplay textures of weird aspect ratios
This commit is contained in:
Bartłomiej Dach 2023-10-31 11:02:59 +01:00 committed by GitHub
commit bc2acc3e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,7 +115,18 @@ namespace osu.Game.Skinning
maxSize *= texture.ScaleAdjust;
var croppedTexture = texture.Crop(new RectangleF(texture.Width / 2f - maxSize.X / 2f, texture.Height / 2f - maxSize.Y / 2f, maxSize.X, maxSize.Y));
// Importantly, check per-axis for the minimum dimension to avoid accidentally inflating
// textures with weird aspect ratios.
float newWidth = Math.Min(texture.Width, maxSize.X);
float newHeight = Math.Min(texture.Height, maxSize.Y);
var croppedTexture = texture.Crop(new RectangleF(
texture.Width / 2f - newWidth / 2f,
texture.Height / 2f - newHeight / 2f,
newWidth,
newHeight
));
croppedTexture.ScaleAdjust = texture.ScaleAdjust;
return croppedTexture;
}