Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Encode overload with Stream destination produces "corruption" at the bottom. #3139

Open
1 task done
ha-ves opened this issue Jan 14, 2025 · 1 comment
Open
1 task done
Labels

Comments

@ha-ves
Copy link

ha-ves commented Jan 14, 2025

Description

The overload of SKPixmap

public bool Encode(Stream dst, SKEncodedImageFormat encoder, int quality)

is producing a black bar that is cropping the bottom part, but when i use this overload

public SKData Encode(SKEncodedImageFormat encoder, int quality)

and manually save the SKData its fine without cropping the bottom part.

It might have been a SKManagedWStream issue.

Code

var pxs = Marshal.AllocHGlobal(skInfo.BytesSize);

var bmp2 = new SKPixmap(skInfo.WithSize(640, 640), pxs);
image.ScalePixels(bmp2, SKSamplingOptions.Default);

bmp2.Encode(File.Create("save2.png"), SKEncodedImageFormat.Png, 100);

var enc = bmp2.Encode(SKEncodedImageFormat.Png, 100);
var f = File.Create("save3.png");
enc.SaveTo(f);

Expected Behavior

No black bar just like save3.png

Actual Behavior

Produces a black bar at the bottom for save2.png

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

3.116.0 (Current)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

Save2.png

save2.png

save2

Save3.png

save3.png

save3

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ha-ves
Copy link
Author

ha-ves commented Jan 14, 2025

As I was writing this issue, I realized it has different behavior when uploaded to github.
Notice the bottom part.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: New
Development

No branches or pull requests

1 participant