Fix Skia saving screenshot with transparent background and incorrect origin (#7073)
* Fix Skia saving screenshot with transparent background and incorrect origin * Remove code that is no longer necessary
This commit is contained in:
parent
ce09450743
commit
99f04ac1a6
@ -367,19 +367,14 @@ namespace Ryujinx.Ava
|
|||||||
}
|
}
|
||||||
|
|
||||||
var colorType = e.IsBgra ? SKColorType.Bgra8888 : SKColorType.Rgba8888;
|
var colorType = e.IsBgra ? SKColorType.Bgra8888 : SKColorType.Rgba8888;
|
||||||
using var bitmap = new SKBitmap(new SKImageInfo(e.Width, e.Height, colorType, SKAlphaType.Premul));
|
using SKBitmap bitmap = new SKBitmap(new SKImageInfo(e.Width, e.Height, colorType, SKAlphaType.Premul));
|
||||||
|
|
||||||
Marshal.Copy(e.Data, 0, bitmap.GetPixels(), e.Data.Length);
|
Marshal.Copy(e.Data, 0, bitmap.GetPixels(), e.Data.Length);
|
||||||
|
|
||||||
SKBitmap bitmapToSave = null;
|
using SKBitmap bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height);
|
||||||
|
using SKCanvas canvas = new SKCanvas(bitmapToSave);
|
||||||
|
|
||||||
if (e.FlipX || e.FlipY)
|
canvas.Clear(SKColors.Black);
|
||||||
{
|
|
||||||
bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height);
|
|
||||||
|
|
||||||
using var canvas = new SKCanvas(bitmapToSave);
|
|
||||||
|
|
||||||
canvas.Clear(SKColors.Transparent);
|
|
||||||
|
|
||||||
float scaleX = e.FlipX ? -1 : 1;
|
float scaleX = e.FlipX ? -1 : 1;
|
||||||
float scaleY = e.FlipY ? -1 : 1;
|
float scaleY = e.FlipY ? -1 : 1;
|
||||||
@ -387,12 +382,9 @@ namespace Ryujinx.Ava
|
|||||||
var matrix = SKMatrix.CreateScale(scaleX, scaleY, bitmap.Width / 2f, bitmap.Height / 2f);
|
var matrix = SKMatrix.CreateScale(scaleX, scaleY, bitmap.Width / 2f, bitmap.Height / 2f);
|
||||||
|
|
||||||
canvas.SetMatrix(matrix);
|
canvas.SetMatrix(matrix);
|
||||||
|
canvas.DrawBitmap(bitmap, SKPoint.Empty);
|
||||||
|
|
||||||
canvas.DrawBitmap(bitmap, new SKPoint(e.FlipX ? -bitmap.Width : 0, e.FlipY ? -bitmap.Height : 0));
|
SaveBitmapAsPng(bitmapToSave, path);
|
||||||
}
|
|
||||||
|
|
||||||
SaveBitmapAsPng(bitmapToSave ?? bitmap, path);
|
|
||||||
bitmapToSave?.Dispose();
|
|
||||||
|
|
||||||
Logger.Notice.Print(LogClass.Application, $"Screenshot saved to {path}", "Screenshot");
|
Logger.Notice.Print(LogClass.Application, $"Screenshot saved to {path}", "Screenshot");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user