Open harborsiem opened 3 years ago
Tagging subscribers to this area: @safern, @tannergooding See info in area-owners.md if you want to be subscribed.
Author: | harborsiem |
---|---|
Assignees: | - |
Labels: | `area-System.Drawing`, `untriaged` |
Milestone: | - |
This is a request to support this bitmap format in System.Drawing. Clearly GDI+ doesn't recognize this format and it appears that GDI doesn't either.
The suggestion looks worth investigating, but we'd probably want to parse without using any Win32 APIs so this has a chance of working on Unix. I would think we'd want to add an overload with a new option to avoid breaking existing apps that are depending on not getting transparency.
Using Image.LoadFromFile()
or Image.LoadFromHBitmap()
doesn't work either. Drawing directly to the Graphics
object has the same behavior so this has nothing to do with PictureBox
.
@JeremyKuhne I don't think that an overload of the Bitmap ctor with a new option is a good idea. When using a Png image with alpha channel you will get the transparency direct. When you have a look to a ToolStripButton with the WinForms Designer for example, you will get the image as a resource. When you choose a .bmp file for the Image, you get no alpha channel. But when you choose a .png then you get the alpha channel and the Image looks good.
See the Cut32.png file:
@harborsiem If compatibility wasn't an issue I'd agree with you. I suspect, however, that there are likely bitmaps in user apps that have transparency that, of course, currently don't apply the transparency. Forcing developers to update existing assets needs to have a really good justification behind it, particularly as assets can come indirectly through dependencies that may be out of the developer's ability to update.
From the WinForms perspective this is something I'd feel more comfortable being an opt-in. The System.Drawing owners have to ultimately make the design call.
I have the same problem, the intermediate results are stored in bmp format in stream/bytes, and when reading from stream, the alpha channel disappears.
.NET SDK (gemäß "global.json"): Version: 5.0.103 Commit: 72dec52dbd
Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.103\
Host (useful for support): Version: 5.0.3 Commit: c636bbdc8a
Problem description: Bitmap class has no transparency informations (alpha channel) when loading from file or stream with an alpha channel..
Expected behavior: The left side is the current situation. The right side is the expected one.
Minimal repro: TestBitmap.zip See possible solution in file AlphaBitmap.cs