dotnet / dotnet/winforms

Saving JPEG as PNG using System.Drawing.Bitmap does not work on Windows 11 24H2

Open
#12,339 7 comments 0 reactions 0 assignees View on GitHub
external-OS-issue
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### .NET version

.NET 8.0

### Did it work in .NET Framework?

Not tested/verified

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

_No response_

### Issue description

Applications that read JPEG data and save as PNG using System.Drawing.Bitmap methods output incorrect PNG images on Windows 11 24H2. Output images contain only the top-left quarters of the respective source image content, enlarged 2x. No errors are reported.

### Steps to reproduce

Sample app code is attached as a Visual Studio 2022 solution: [WinFormsAppNet8.zip](https://github.com/user-attachments/files/17394030/WinFormsAppNet8.zip)

using System.Drawing;
using System.Drawing.Imaging;

var bitmap1 = new Bitmap(jpgPath);
var stream2 = new MemoryStream();
bitmap1.Save(stream2, ImageFormat.Png);
var bitmap2 = new Bitmap(stream2);

Result on Windows 11 24H2: bitmap2 contains only the top-left quarter of bitmap1 content, enlarged 2x.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.