Apply suggestions from code review
Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
4ccc073be9
commit
e6b8c43281
4 changed files with 7 additions and 3 deletions
|
@ -315,6 +315,7 @@ namespace Ryujinx.Ava
|
||||||
bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height);
|
bitmapToSave = new SKBitmap(bitmap.Width, bitmap.Height);
|
||||||
|
|
||||||
using var canvas = new SKCanvas(bitmapToSave);
|
using var canvas = new SKCanvas(bitmapToSave);
|
||||||
|
|
||||||
canvas.Clear(SKColors.Transparent);
|
canvas.Clear(SKColors.Transparent);
|
||||||
|
|
||||||
float scaleX = e.FlipX ? -1 : 1;
|
float scaleX = e.FlipX ? -1 : 1;
|
||||||
|
@ -324,8 +325,7 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
canvas.SetMatrix(matrix);
|
canvas.SetMatrix(matrix);
|
||||||
|
|
||||||
SKPoint drawPosition = new SKPoint(e.FlipX ? -bitmap.Width : 0, e.FlipY ? -bitmap.Height : 0);
|
canvas.DrawBitmap(bitmap, new SKPoint(e.FlipX ? -bitmap.Width : 0, e.FlipY ? -bitmap.Height : 0));
|
||||||
canvas.DrawBitmap(bitmap, drawPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveBitmapAsPng(bitmapToSave ?? bitmap, path);
|
SaveBitmapAsPng(bitmapToSave ?? bitmap, path);
|
||||||
|
@ -345,6 +345,7 @@ namespace Ryujinx.Ava
|
||||||
{
|
{
|
||||||
using var data = bitmap.Encode(SKEncodedImageFormat.Png, 100);
|
using var data = bitmap.Encode(SKEncodedImageFormat.Png, 100);
|
||||||
using var stream = File.OpenWrite(path);
|
using var stream = File.OpenWrite(path);
|
||||||
|
|
||||||
data.SaveTo(stream);
|
data.SaveTo(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ namespace Ryujinx.Ava.UI.Views.User
|
||||||
{
|
{
|
||||||
using var streamJpg = new MemoryStream();
|
using var streamJpg = new MemoryStream();
|
||||||
using var bitmap = SKBitmap.Decode(ViewModel.SelectedImage);
|
using var bitmap = SKBitmap.Decode(ViewModel.SelectedImage);
|
||||||
|
|
||||||
using var newBitmap = new SKBitmap(bitmap.Width, bitmap.Height);
|
using var newBitmap = new SKBitmap(bitmap.Width, bitmap.Height);
|
||||||
|
|
||||||
using (var canvas = new SKCanvas(newBitmap))
|
using (var canvas = new SKCanvas(newBitmap))
|
||||||
{
|
{
|
||||||
canvas.Clear(new SKColor(
|
canvas.Clear(new SKColor(
|
||||||
|
|
|
@ -110,6 +110,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
||||||
{
|
{
|
||||||
using var image = SKImage.FromBitmap(resizedBitmap);
|
using var image = SKImage.FromBitmap(resizedBitmap);
|
||||||
using var dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100);
|
using var dataJpeg = image.Encode(SKEncodedImageFormat.Jpeg, 100);
|
||||||
|
|
||||||
dataJpeg.SaveTo(streamJpg);
|
dataJpeg.SaveTo(streamJpg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
public static SKColor[] GetBuffer(SKBitmap image)
|
public static SKColor[] GetBuffer(SKBitmap image)
|
||||||
{
|
{
|
||||||
var pixels = new SKColor[image.Width * image.Height];
|
var pixels = new SKColor[image.Width * image.Height];
|
||||||
|
|
||||||
for (int y = 0; y < image.Height; y++)
|
for (int y = 0; y < image.Height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < image.Width; x++)
|
for (int x = 0; x < image.Width; x++)
|
||||||
|
@ -131,6 +132,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
pixels[x + y * image.Width] = image.GetPixel(x, y);
|
pixels[x + y * image.Width] = image.GetPixel(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue