Update ImageSharp.Drawing version

- migrate to ImageSharp v2+
This commit is contained in:
VaDiM 2022-11-18 05:32:28 +03:00
parent c22d92009a
commit 7fa5b4f355
3 changed files with 9 additions and 6 deletions

View File

@ -9,7 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.3" /> <PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta13" /> <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta15" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,6 +2,7 @@
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Tga; using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -45,11 +46,13 @@ namespace AssetStudio
public static byte[] ConvertToBytes<TPixel>(this Image<TPixel> image) where TPixel : unmanaged, IPixel<TPixel> public static byte[] ConvertToBytes<TPixel>(this Image<TPixel> image) where TPixel : unmanaged, IPixel<TPixel>
{ {
if (image.TryGetSinglePixelSpan(out var pixelSpan)) using (image)
{ {
return MemoryMarshal.AsBytes(pixelSpan).ToArray(); Span<byte> imageSpan = new byte[image.Width * image.Height * 4];
image.CopyPixelDataTo(imageSpan);
return MemoryMarshal.AsBytes(imageSpan).ToArray();
} }
return null;
} }
} }
} }

View File

@ -96,8 +96,8 @@ namespace AssetStudio
using (var mask = new Image<Bgra32>(rect.Width, rect.Height, SixLabors.ImageSharp.Color.Black)) using (var mask = new Image<Bgra32>(rect.Width, rect.Height, SixLabors.ImageSharp.Color.Black))
{ {
mask.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, path)); mask.Mutate(x => x.Fill(options, SixLabors.ImageSharp.Color.Red, path));
var bursh = new ImageBrush(mask); var brush = new ImageBrush(mask);
spriteImage.Mutate(x => x.Fill(graphicsOptions, bursh)); spriteImage.Mutate(x => x.Fill(options, brush));
spriteImage.Mutate(x => x.Flip(FlipMode.Vertical)); spriteImage.Mutate(x => x.Flip(FlipMode.Vertical));
return spriteImage; return spriteImage;
} }