mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-08 22:26:27 +02:00
Use SkiaSharp for Avalonia in place of ImageSharp (#6269)
* Rebased Transformation all at once Use SkiaSharp instead of ImageSharp * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Change back unintentionally changed comment --------- Co-authored-by: Ac_K <Acoustik666@gmail.com> Co-authored-by: Emmanuel Hansen <emmausssss@gmail.com>
This commit is contained in:
parent
07435ad844
commit
595e514f18
7 changed files with 104 additions and 71 deletions
|
@ -32,7 +32,7 @@ using Ryujinx.UI.App.Common;
|
|||
using Ryujinx.UI.Common;
|
||||
using Ryujinx.UI.Common.Configuration;
|
||||
using Ryujinx.UI.Common.Helper;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -40,7 +40,6 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Image = SixLabors.ImageSharp.Image;
|
||||
using Key = Ryujinx.Input.Key;
|
||||
using MissingKeyException = LibHac.Common.Keys.MissingKeyException;
|
||||
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
|
||||
|
@ -1164,17 +1163,17 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
private void PrepareLoadScreen()
|
||||
{
|
||||
using MemoryStream stream = new(SelectedIcon);
|
||||
using var gameIconBmp = Image.Load<Bgra32>(stream);
|
||||
using var gameIconBmp = SKBitmap.Decode(stream);
|
||||
|
||||
var dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp).ToPixel<Bgra32>();
|
||||
var dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp);
|
||||
|
||||
const float ColorMultiple = 0.5f;
|
||||
|
||||
Color progressFgColor = Color.FromRgb(dominantColor.R, dominantColor.G, dominantColor.B);
|
||||
Color progressFgColor = Color.FromRgb(dominantColor.Red, dominantColor.Green, dominantColor.Blue);
|
||||
Color progressBgColor = Color.FromRgb(
|
||||
(byte)(dominantColor.R * ColorMultiple),
|
||||
(byte)(dominantColor.G * ColorMultiple),
|
||||
(byte)(dominantColor.B * ColorMultiple));
|
||||
(byte)(dominantColor.Red * ColorMultiple),
|
||||
(byte)(dominantColor.Green * ColorMultiple),
|
||||
(byte)(dominantColor.Blue * ColorMultiple));
|
||||
|
||||
ProgressBarForegroundColor = new SolidColorBrush(progressFgColor);
|
||||
ProgressBarBackgroundColor = new SolidColorBrush(progressBgColor);
|
||||
|
|
|
@ -9,14 +9,14 @@ using LibHac.Tools.FsSystem;
|
|||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using Color = Avalonia.Media.Color;
|
||||
using Image = SkiaSharp.SKImage;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
|
@ -130,9 +130,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
stream.Position = 0;
|
||||
|
||||
Image avatarImage = Image.LoadPixelData<Rgba32>(DecompressYaz0(stream), 256, 256);
|
||||
Image avatarImage = Image.FromPixelCopy(new SKImageInfo(256, 256, SKColorType.Rgba8888, SKAlphaType.Premul), DecompressYaz0(stream));
|
||||
|
||||
avatarImage.SaveAsPng(streamPng);
|
||||
using (SKData data = avatarImage.Encode(SKEncodedImageFormat.Png, 100))
|
||||
{
|
||||
data.SaveTo(streamPng);
|
||||
}
|
||||
|
||||
_avatarStore.Add(item.FullPath, streamPng.ToArray());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue