Skip to content

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

Open
@ha-ves

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions