You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until 2.88.8 you will have a default PNG level of compression when calling SKBitMap.Encode(Stream, SKEncodedImageFormat.Png, int). Starting with 3.0.0 no compression is applied when calling this method.
This is a regression since the previous behavior is broken (suddenly the encoded images are huge) and there is no way to change the compression level in SKBitmap.Encode.
The PNG compression itself seems to work fine though, if tested with SKPixmap.Encode and SKPngEncoderOptions.Default.
Code
using SkiaSharp;using System.Reflection;namespaceConsoleApp1{internalclassProgram{staticvoidMain(){
Console.WriteLine($"{typeof(SKImageInfo).Assembly.GetName().Name}, {typeof(SKImageInfo).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion}");// create empty 1000x1000 bitmapusingvarbitmap=new SKBitmap(1000,1000);// encode bitmap with default settingsusingvaroutputStream=new MemoryStream();
bitmap.Encode(outputStream, SKEncodedImageFormat.Png,default);
Console.WriteLine($"SKBitmap.Encode size: {outputStream.Length}");// get the pixmapusingvarpixmap=new SKPixmap(bitmap.Info, bitmap.GetPixels());// encode it with default SKPngEncoderOptions (that's ZLibLevel 6)usingvardata= pixmap.Encode(SKPngEncoderOptions.Default)!;
Console.WriteLine($"SKPixmap.Encode size: {data.Size}");}}}
Expected Behavior
Calling SKBitmap.Encode for PNGs should use the default compression as below:
sungaila
changed the title
[BUG] 3.0.0 regression for PNG compression for SKBitmap.Encode
[BUG] 3.0.0 regression for PNG compression with SKBitmap.Encode
Sep 21, 2024
Description
Until 2.88.8 you will have a default PNG level of compression when calling
SKBitMap.Encode(Stream, SKEncodedImageFormat.Png, int)
. Starting with 3.0.0 no compression is applied when calling this method.This is a regression since the previous behavior is broken (suddenly the encoded images are huge) and there is no way to change the compression level in
SKBitmap.Encode
.The PNG compression itself seems to work fine though, if tested with
SKPixmap.Encode
andSKPngEncoderOptions.Default
.Code
Expected Behavior
Calling
SKBitmap.Encode
for PNGs should use the default compression as below:Actual Behavior
In SkiaSharp 3.0.0 calling
SKBitmap.Encode
for PNGs will result in no compression. UsingSKPixmap.Encode
still works though.Version of SkiaSharp
3.x (Alpha)
Last Known Good Version of SkiaSharp
2.88.2 (Previous)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Android, Linux, macOS, Windows
Platform / Operating System Version
This regression was observed on Windows, Linux, macOS and Android.
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: