aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-07-20 16:27:40 -0300
committerGitHub <noreply@github.com>2024-07-20 16:27:40 -0300
commit99f04ac1a64400d45052e4a83c572e50ba86de0d (patch)
treed7ccf3799c5a27dca23c1d5f9cd36c2be15bc941
parentce09450743ad36f6478af1a21b5fbff283f08e59 (diff)
Fix Skia saving screenshot with transparent background and incorrect origin (#7073)1.1.1356
* Fix Skia saving screenshot with transparent background and incorrect origin * Remove code that is no longer necessary
-rw-r--r--src/Ryujinx/AppHost.cs28
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 }