Skip to content

Output file image has artifacts #11

Closed
@Msey

Description

@Msey

To convert heic image to number of png frames or just one jpg file i'm using examples from your main page like this one:

using (var fs = new FileStream("filename.heic", FileMode.Open))
{
    HeicImage image = HeicImage.Load(fs);
     
    var pixels = image.GetByteArray(Heic.Decoder.PixelFormat.Bgra32);
    var width = (int)image.Width;
    var height = (int)image.Height;
     
    var wbitmap = new WriteableBitmap(width, height, 72, 72, PixelFormats.Bgra32, null);
    var rect = new Int32Rect(0, 0, width, height);
    wbitmap.WritePixels(rect, pixels, 4 * width, 0);
    
    using FileStream saveStream = new FileStream("output.jpg", FileMode.OpenOrCreate);
    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(wbitmap));
    encoder.Save(saveStream);
}

But the output image is tiled with strange squares

image

What the cause of it and how to solve the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions