diff options
Diffstat (limited to 'src/Ryujinx/AppHost.cs')
-rw-r--r-- | src/Ryujinx/AppHost.cs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 8c643f340..0db8ef414 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs | |||
@@ -367,32 +367,24 @@ namespace Ryujinx.Ava | |||
367 | } | 367 | } |
368 | 368 | ||
369 | var colorType = e.IsBgra ? SKColorType.Bgra8888 : SKColorType.Rgba8888; | 369 | var colorType = e.IsBgra ? SKColorType.Bgra8888 : SKColorType.Rgba8888; |
370 | using var bitmap = new SKBitmap(new SKImageInfo(e.Width, e.Height, colorType, SKAlphaType.Premul)); | 370 | using SKBitmap bitmap = new SKBitmap(new SKImageInfo(e.Width, e.Height, colorType, SKAlphaType.Premul)); |
371 | 371 | ||
372 | Marshal.Copy(e.Data, 0, bitmap.GetPixels(), e.Data.Length); | 372 | Marshal.Copy(e.Data, 0, bitmap.GetPixels(), e.Data.Length); |
373 | 373 | ||
374 | SKBitmap bitmapToSave = null; | 374 | using SKBitmap bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height); |
375 | using SKCanvas canvas = new SKCanvas(bitmapToSave); | ||
375 | 376 | ||
376 | if (e.FlipX || e.FlipY) | 377 | canvas.Clear(SKColors.Black); |
377 | { | ||
378 | bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height); | ||
379 | |||
380 | using var canvas = new SKCanvas(bitmapToSave); | ||
381 | |||
382 | canvas.Clear(SKColors.Transparent); | ||
383 | 378 | ||
384 | float scaleX = e.FlipX ? -1 : 1; | 379 | float scaleX = e.FlipX ? -1 : 1; |
385 | float scaleY = e.FlipY ? -1 : 1; | 380 | float scaleY = e.FlipY ? -1 : 1; |
386 | 381 | ||
387 | var matrix = SKMatrix.CreateScale(scaleX, scaleY, bitmap.Width / 2f, bitmap.Height / 2f); | 382 | var matrix = SKMatrix.CreateScale(scaleX, scaleY, bitmap.Width / 2f, bitmap.Height / 2f); |
388 | 383 | ||
389 | canvas.SetMatrix(matrix); | 384 | canvas.SetMatrix(matrix); |
390 | 385 | canvas.DrawBitmap(bitmap, SKPoint.Empty); | |
391 | canvas.DrawBitmap(bitmap, new SKPoint(e.FlipX ? -bitmap.Width : 0, e.FlipY ? -bitmap.Height : 0)); | ||
392 | } | ||
393 | 386 | ||
394 | SaveBitmapAsPng(bitmapToSave ?? bitmap, path); | 387 | SaveBitmapAsPng(bitmapToSave, path); |
395 | bitmapToSave?.Dispose(); | ||
396 | 388 | ||
397 | Logger.Notice.Print(LogClass.Application, $"Screenshot saved to {path}", "Screenshot"); | 389 | Logger.Notice.Print(LogClass.Application, $"Screenshot saved to {path}", "Screenshot"); |
398 | } | 390 | } |