diff --git a/src/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs b/src/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
index ca758378627..389223c06e1 100644
--- a/src/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
+++ b/src/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
@@ -35,3 +35,13 @@ public Matrix(System.Numerics.Matrix3x2 matrix) { }
public System.Numerics.Matrix3x2 MatrixElements { get { throw null; } set { } }
}
}
+namespace System.Drawing.Imaging
+{
+ public sealed partial class ImageFormat
+ {
+ [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows10.0.17763.0")]
+ public static ImageFormat Heif { get { throw null; } }
+ [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows10.0.17763.0")]
+ public static ImageFormat Webp { get { throw null; } }
+ }
+}
diff --git a/src/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs b/src/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs
index 1ab594ed93d..9bbb729a629 100644
--- a/src/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs
@@ -10,6 +10,8 @@
namespace System.Drawing
{
+ [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Heif and Webp are referenced here for " +
+ "design-time support, the user is responsible to ensure that they are used on a supported version of Windows.")]
public class ImageFormatConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
@@ -63,6 +65,10 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(
return ImageFormat.Tiff;
else if (strFormat.Equals("Wmf", StringComparison.OrdinalIgnoreCase))
return ImageFormat.Wmf;
+ else if (strFormat.Equals("Heif", StringComparison.OrdinalIgnoreCase))
+ return ImageFormat.Heif;
+ else if (strFormat.Equals("Webp", StringComparison.OrdinalIgnoreCase))
+ return ImageFormat.Webp;
throw new FormatException(SR.Format(SR.ConvertInvalidPrimitive, strFormat, nameof(ImageFormat)));
}
@@ -128,7 +134,9 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex
ImageFormat.Png,
ImageFormat.Tiff,
ImageFormat.Exif,
- ImageFormat.Icon
+ ImageFormat.Icon,
+ ImageFormat.Heif,
+ ImageFormat.Webp
});
}
diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs
index ca4e867fcba..1a37c8b2db5 100644
--- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs
+++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
+using System.Runtime.Versioning;
namespace System.Drawing.Imaging
{
@@ -24,6 +25,8 @@ public sealed class ImageFormat
private static readonly ImageFormat s_tiff = new ImageFormat(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}"));
private static readonly ImageFormat s_exif = new ImageFormat(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}"));
private static readonly ImageFormat s_icon = new ImageFormat(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}"));
+ private static readonly ImageFormat s_heif = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}"));
+ private static readonly ImageFormat s_webp = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}"));
private Guid _guid;
@@ -123,6 +126,30 @@ public static ImageFormat Icon
get { return s_icon; }
}
+ ///
+ /// Specifies the High Efficiency Image Format (HEIF).
+ ///
+ ///
+ /// This format is supported since Windows 10 1809.
+ ///
+ [SupportedOSPlatform("windows10.0.17763.0")]
+ public static ImageFormat Heif
+ {
+ get { return s_heif; }
+ }
+
+ ///
+ /// Specifies the WebP image format.
+ ///
+ ///
+ /// This format is supported since Windows 10 1809.
+ ///
+ [SupportedOSPlatform("windows10.0.17763.0")]
+ public static ImageFormat Webp
+ {
+ get { return s_webp; }
+ }
+
///
/// Returns a value indicating whether the specified object is an equivalent to this
/// .
@@ -170,6 +197,8 @@ public override string ToString()
if (this.Guid == s_tiff.Guid) return "Tiff";
if (this.Guid == s_exif.Guid) return "Exif";
if (this.Guid == s_icon.Guid) return "Icon";
+ if (this.Guid == s_heif.Guid) return "Heif";
+ if (this.Guid == s_webp.Guid) return "Webp";
return $"[ImageFormat: {_guid}]";
}
}
diff --git a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs
index c22d7b3d43f..646bccb5053 100644
--- a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs
+++ b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs
@@ -19,6 +19,8 @@ public class ImageFormatTests
private static ImageFormat IconImageFormat = new ImageFormat(new Guid("b96b3cb5-0728-11d3-9d7b-0000f81ef32e"));
private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e"));
private static ImageFormat WmfImageFormat = new ImageFormat(new Guid("b96b3cad-0728-11d3-9d7b-0000f81ef32e"));
+ private static ImageFormat HeifImageFormat = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}"));
+ private static ImageFormat WebpImageFormat = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}"));
private static ImageFormat CustomImageFormat = new ImageFormat(new Guid("48749428-316f-496a-ab30-c819a92b3137"));
public static IEnumerable