Skip to content

Commit

Permalink
Merge pull request #112 from Milkitic/dependabot/nuget/master/SixLabo…
Browse files Browse the repository at this point in the history
…rs.ImageSharp-3.1.4

Bump SixLabors.ImageSharp from 2.1.7 to 3.1.4
  • Loading branch information
Milkitic authored Apr 22, 2024
2 parents 488033a + 5b2dbed commit 333b515
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/MilkiBotFramework.Imaging.Wpf/WpfDrawingProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ await Application.Current.Dispatcher.InvokeAsync(async () =>

try
{
return await Image.LoadAsync(retStream, new PngDecoder());
return await PngDecoder.Instance.DecodeAsync(new PngDecoderOptions(), retStream);
}
finally
{
Expand Down
31 changes: 12 additions & 19 deletions src/MilkiBotFramework/Imaging/ImageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static Image GetResizedImage(Image source, float uniformScaleRate)

public static Image GetRotatedImage(Image source, float angle, bool crop = false, Size resize = default)
{
if (resize == Size.Empty) resize = source.Size();
if (resize == Size.Empty) resize = source.Size;

var returnBitmap = source
.Clone(k => k
Expand Down Expand Up @@ -169,7 +169,7 @@ public static Image GetRotatedImage(Image source, float angle, bool crop = false

public static Image GetTranslatedBitmap(Image source, int x, int y, Size resize = default)
{
if (resize == Size.Empty) resize = source.Size();
if (resize == Size.Empty) resize = source.Size;
var returnBitmap = source
.Clone(k => k
.AutoOrient()
Expand All @@ -191,25 +191,18 @@ public static async Task SaveGifToFileAsync(string path, Image gif, Color[]? pal
gif.Mutate(k => k.Quantize());
var encoder = new GifEncoder
{
ColorTableMode = GifColorTableMode.Global,
GlobalPixelSamplingStrategy = new ExtensivePixelSamplingStrategy(),
Quantizer = new OctreeQuantizer(new QuantizerOptions
{
DitherScale = QuantizerConstants.MinDitherScale,
})
};

if (palettes != null)
{
encoder.ColorTableMode = GifColorTableMode.Local;
encoder.Quantizer = new PaletteQuantizer(new ReadOnlyMemory<Color>(palettes),
new QuantizerOptions
ColorTableMode = palettes == null ? GifColorTableMode.Global : GifColorTableMode.Local,
PixelSamplingStrategy = new ExtensivePixelSamplingStrategy(),
Quantizer = palettes == null
? new OctreeQuantizer(new QuantizerOptions
{
DitherScale = QuantizerConstants.MinDitherScale
}
);
}

})
: new PaletteQuantizer(new ReadOnlyMemory<Color>(palettes), new QuantizerOptions
{
DitherScale = QuantizerConstants.MinDitherScale
})
};
await gif.SaveAsGifAsync(path, encoder);
}

Expand Down
2 changes: 1 addition & 1 deletion src/MilkiBotFramework/MilkiBotFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<!-- ReSharper disable once VulnerablePackage -->
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.7" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="Websocket.Client" Version="5.1.1" />
<PackageReference Include="YamlDotNet" Version="15.1.2" />
</ItemGroup>
Expand Down

0 comments on commit 333b515

Please sign in to comment.