-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[API Proposal]: System.Drawing.Imaging.ImageFormat.Heif
and Webp
.
#70422
Comments
Tagging subscribers to this area: @dotnet/area-system-drawing Issue DetailsBackground and motivationGDI+ seems to support the newer HEIF and WebP image formats. We should expose this functionality to API Proposalnamespace System.Drawing.Common;
public class ImageFormat {
// I need to find in which version of Windows they were introduced.
[SupportedOSPlatform("winTBD")]
public static ImageFormat Heif { get; }
[SupportedOSPlatform("winTBD")]
public static ImageFormat Webp { get; }
} API Usage// Fancy the value
Bitmap bmp = new Bitmap(184, 475);
// ...
bmp.Save("myimage.heif", ImageFormat.Heif);
bmp.Save("myimage.webp", ImageFormap.Webp); Alternative DesignsUsers can use these formats by creating an RisksNo response
|
System.Drawing.Common.ImageFormat.Heif
and Webp
.System.Drawing.Imaging.ImageFormat.Heif
and Webp
.
Aside from these two, we match the GDI+ list. Although we're generally adding not features to this library, its goal is to expose GDI+, we do want to enable these new formats, and in this case it's simply a matter of passing through different constants. |
It's more than a matter of missing constants. System.Drawing currently throws Also, WIC has both decoder and encoder for HEIC/HEIF (although they don't work without the HEVC Video Extensions installed from Microsoft Store), but it only has a decoder for WebP. The above example to save as WebP wouldn't work even if everything were wired up correctly. |
Just tested static void TestFormats()
{
Guid ImageFormatHEIF = new(0xb96b3cb6, 0x0728, 0x11d3, 0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e);
Guid ImageFormatWEBP = new(0xb96b3cb7, 0x0728, 0x11d3, 0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e);
using var img = new Bitmap(256, 256);
img.Save("test.webp", new ImageFormat(ImageFormatWEBP));
img.Save("test.heif", new ImageFormat(ImageFormatHEIF));
} |
namespace System.Drawing.Imaging;
public class ImageFormat
{
[SupportedOSPlatform("windows10.0.17763.0")]
public static ImageFormat Heif { get; }
[SupportedOSPlatform("windows10.0.17763.0")]
public static ImageFormat Webp { get; }
} |
Background and motivation
GDI+ seems to support the newer HEIF and WebP image formats since Windows 10 1809 1. We should expose this functionality to
System.Drawing.Common
.API Proposal
API Usage
Alternative Designs
Users can use these formats by creating an
ImageFormat
object with the format's GUID but it is not easily found in the documentation.Risks
No response
Footnotes
Source: I bisected Windows 10 SDK versions and checked the contents of
gdiplusimaging.h
. ↩The text was updated successfully, but these errors were encountered: