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:
commit
bc2acc3e93
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user