diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 26e499ae9a..47ce0d31eb 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -24,6 +24,7 @@ using osu.Game.Overlays; using osu.Game.Overlays.Notifications; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Processing; namespace osu.Game.Graphics { @@ -52,6 +53,9 @@ namespace osu.Game.Graphics private INotificationOverlay notificationOverlay { get; set; } private Sample shutter; + private Bindable sizeX; + private Bindable sizeY; + private Bindable scalingMode; [BackgroundDependencyLoader] private void load(OsuConfigManager config, Storage storage, AudioManager audio) @@ -62,6 +66,10 @@ namespace osu.Game.Graphics captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); shutter = audio.Samples.Get("UI/shutter"); + + sizeX = config.GetBindable(OsuSetting.ScalingSizeX); + sizeY = config.GetBindable(OsuSetting.ScalingSizeY); + scalingMode = config.GetBindable(OsuSetting.Scaling); } public bool OnPressed(KeyBindingPressEvent e) @@ -119,6 +127,19 @@ namespace osu.Game.Graphics using (var image = await host.TakeScreenshotAsync().ConfigureAwait(false)) { + if (scalingMode.Value == ScalingMode.Everything) + { + image.Mutate(m => + { + var size = m.GetCurrentSize(); + var rect = new Rectangle(Point.Empty, size); + int sx = (size.Width - (int)(size.Width * sizeX.Value)) / 2; + int sy = (size.Height - (int)(size.Height * sizeY.Value)) / 2; + rect.Inflate(-sx, -sy); + m.Crop(rect); + }); + } + clipboard.SetImage(image); (string filename, var stream) = getWritableStream();