Update ImageSharp and fix API usage
This commit is contained in:
parent
2505a1abcd
commit
511bebe83c
5 changed files with 23 additions and 24 deletions
|
@ -42,8 +42,8 @@
|
|||
<PackageVersion Include="Silk.NET.Vulkan" Version="2.16.0" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.16.0" />
|
||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.16.0" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="1.0.4" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.3" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.2" />
|
||||
<PackageVersion Include="SPB" Version="0.0.4-build32" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="8.0.2" />
|
||||
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace Ryujinx.UI.Windows
|
|||
{
|
||||
using MemoryStream streamJpg = MemoryStreamManager.Shared.GetStream();
|
||||
|
||||
Image avatarImage = Image.Load(data, new PngDecoder());
|
||||
Image avatarImage = Image.Load(data);
|
||||
|
||||
avatarImage.Mutate(x => x.BackgroundColor(new Rgba32(
|
||||
(byte)(_backgroundColor.Red * 255),
|
||||
|
|
|
@ -44,10 +44,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
private readonly Color _textSelectedColor;
|
||||
private readonly Color _textOverCursorColor;
|
||||
|
||||
private readonly IBrush _panelBrush;
|
||||
private readonly IBrush _disabledBrush;
|
||||
private readonly IBrush _cursorBrush;
|
||||
private readonly IBrush _selectionBoxBrush;
|
||||
private readonly Brush _panelBrush;
|
||||
private readonly Brush _disabledBrush;
|
||||
private readonly Brush _cursorBrush;
|
||||
private readonly Brush _selectionBoxBrush;
|
||||
|
||||
private readonly Pen _textBoxOutlinePen;
|
||||
private readonly Pen _cursorPen;
|
||||
|
@ -97,10 +97,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
_cursorBrush = new SolidBrush(_textNormalColor);
|
||||
_selectionBoxBrush = new SolidBrush(selectionBackgroundColor);
|
||||
|
||||
_textBoxOutlinePen = new Pen(borderColor, _textBoxOutlineWidth);
|
||||
_cursorPen = new Pen(_textNormalColor, cursorWidth);
|
||||
_selectionBoxPen = new Pen(selectionBackgroundColor, cursorWidth);
|
||||
_padPressedPen = new Pen(borderColor, _padPressedPenWidth);
|
||||
_textBoxOutlinePen = new SolidPen(borderColor, _textBoxOutlineWidth);
|
||||
_cursorPen = new SolidPen(_textNormalColor, cursorWidth);
|
||||
_selectionBoxPen = new SolidPen(selectionBackgroundColor, cursorWidth);
|
||||
_padPressedPen = new SolidPen(borderColor, _padPressedPenWidth);
|
||||
|
||||
_inputTextFontSize = 20;
|
||||
|
||||
|
@ -178,7 +178,6 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
private static void SetGraphicsOptions(IImageProcessingContext context)
|
||||
{
|
||||
context.GetGraphicsOptions().Antialias = true;
|
||||
context.GetShapeGraphicsOptions().GraphicsOptions.Antialias = true;
|
||||
}
|
||||
|
||||
private void DrawImmutableElements()
|
||||
|
@ -293,31 +292,31 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
}
|
||||
private static RectangleF MeasureString(string text, Font font)
|
||||
{
|
||||
RendererOptions options = new(font);
|
||||
TextOptions options = new(font);
|
||||
|
||||
if (text == "")
|
||||
{
|
||||
FontRectangle emptyRectangle = TextMeasurer.Measure(" ", options);
|
||||
FontRectangle emptyRectangle = TextMeasurer.MeasureSize(" ", options);
|
||||
|
||||
return new RectangleF(0, emptyRectangle.Y, 0, emptyRectangle.Height);
|
||||
}
|
||||
|
||||
FontRectangle rectangle = TextMeasurer.Measure(text, options);
|
||||
FontRectangle rectangle = TextMeasurer.MeasureSize(text, options);
|
||||
|
||||
return new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
|
||||
}
|
||||
|
||||
private static RectangleF MeasureString(ReadOnlySpan<char> text, Font font)
|
||||
{
|
||||
RendererOptions options = new(font);
|
||||
TextOptions options = new(font);
|
||||
|
||||
if (text == "")
|
||||
{
|
||||
FontRectangle emptyRectangle = TextMeasurer.Measure(" ", options);
|
||||
FontRectangle emptyRectangle = TextMeasurer.MeasureSize(" ", options);
|
||||
return new RectangleF(0, emptyRectangle.Y, 0, emptyRectangle.Height);
|
||||
}
|
||||
|
||||
FontRectangle rectangle = TextMeasurer.Measure(text, options);
|
||||
FontRectangle rectangle = TextMeasurer.MeasureSize(text, options);
|
||||
|
||||
return new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
|
||||
}
|
||||
|
@ -350,7 +349,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
// Draw the cursor on top of the text and redraw the text with a different color if necessary.
|
||||
|
||||
Color cursorTextColor;
|
||||
IBrush cursorBrush;
|
||||
Brush cursorBrush;
|
||||
Pen cursorPen;
|
||||
|
||||
float cursorPositionYTop = inputTextY + 1;
|
||||
|
@ -435,7 +434,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
new PointF(cursorPositionXLeft, cursorPositionYBottom),
|
||||
};
|
||||
|
||||
context.DrawLines(cursorPen, points);
|
||||
context.DrawLine(cursorPen, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -562,12 +561,12 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||
|
||||
// Convert the pixel format used in the image to the one used in the Switch surface.
|
||||
|
||||
if (!_surface.TryGetSinglePixelSpan(out Span<Argb32> pixels))
|
||||
if (!_surface.DangerousTryGetSinglePixelMemory(out Memory<Argb32> pixels))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_bufferData = MemoryMarshal.AsBytes(pixels).ToArray();
|
||||
_bufferData = MemoryMarshal.AsBytes(pixels.Span).ToArray();
|
||||
Span<uint> dataConvert = MemoryMarshal.Cast<byte, uint>(_bufferData);
|
||||
|
||||
Debug.Assert(_bufferData.Length == _surfaceInfo.Size);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||
if (ViewModel.SelectedImage != null)
|
||||
{
|
||||
MemoryStream streamJpg = new();
|
||||
Image avatarImage = Image.Load(ViewModel.SelectedImage, new PngDecoder());
|
||||
Image avatarImage = Image.Load(ViewModel.SelectedImage);
|
||||
|
||||
avatarImage.Mutate(x => x.BackgroundColor(new Rgba32(
|
||||
ViewModel.BackgroundColor.R,
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public static Bgra32[] GetBuffer(Image<Bgra32> image)
|
||||
{
|
||||
return image.TryGetSinglePixelSpan(out var data) ? data.ToArray() : Array.Empty<Bgra32>();
|
||||
return image.DangerousTryGetSinglePixelMemory(out var data) ? data.ToArray() : Array.Empty<Bgra32>();
|
||||
}
|
||||
|
||||
private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxHitCount, PaletteColor color)
|
||||
|
|
Loading…
Add table
Reference in a new issue