1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:47:24 +08:00

Crop oversized gameplay textures instead of downscaling them

This commit is contained in:
Salman Ahmed 2023-09-30 01:16:56 +03:00
parent 09c9baadec
commit 0bcb99f2c4

View File

@ -9,6 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
@ -112,9 +113,11 @@ namespace osu.Game.Skinning
if (texture.DisplayWidth <= maxSize.X && texture.DisplayHeight <= maxSize.Y)
return texture;
// use scale adjust property for downscaling the texture in order to meet the specified maximum dimensions.
texture.ScaleAdjust *= Math.Max(texture.DisplayWidth / maxSize.X, texture.DisplayHeight / maxSize.Y);
return texture;
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));
croppedTexture.ScaleAdjust = texture.ScaleAdjust;
return croppedTexture;
}
public static bool HasFont(this ISkin source, LegacyFont font)