<PackageReference Include="System.Drawing.Common" Version="9.0.0-preview.7.24405.4" />

ImageFormat

public sealed class ImageFormat
Specifies the file format of the image. Not inheritable.
using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Windows.Win32; namespace System.Drawing.Imaging { [NullableContext(1)] [Nullable(0)] [TypeConverter(typeof(ImageFormatConverter))] public sealed class ImageFormat { private static readonly ImageFormat s_memoryBMP = new ImageFormat(PInvokeCore.ImageFormatMemoryBMP); private static readonly ImageFormat s_bmp = new ImageFormat(PInvokeCore.ImageFormatBMP); private static readonly ImageFormat s_emf = new ImageFormat(PInvokeCore.ImageFormatEMF); private static readonly ImageFormat s_wmf = new ImageFormat(PInvokeCore.ImageFormatWMF); private static readonly ImageFormat s_jpeg = new ImageFormat(PInvokeCore.ImageFormatJPEG); private static readonly ImageFormat s_png = new ImageFormat(PInvokeCore.ImageFormatPNG); private static readonly ImageFormat s_gif = new ImageFormat(PInvokeCore.ImageFormatGIF); private static readonly ImageFormat s_tiff = new ImageFormat(PInvokeCore.ImageFormatTIFF); private static readonly ImageFormat s_exif = new ImageFormat(PInvokeCore.ImageFormatEXIF); private static readonly ImageFormat s_icon = new ImageFormat(PInvokeCore.ImageFormatIcon); private static readonly ImageFormat s_heif = new ImageFormat(PInvokeCore.ImageFormatHEIF); private static readonly ImageFormat s_webp = new ImageFormat(PInvokeCore.ImageFormatWEBP); private readonly Guid _guid; public Guid Guid => _guid; public static ImageFormat MemoryBmp => s_memoryBMP; public static ImageFormat Bmp => s_bmp; public static ImageFormat Emf => s_emf; public static ImageFormat Wmf => s_wmf; public static ImageFormat Gif => s_gif; public static ImageFormat Jpeg => s_jpeg; public static ImageFormat Png => s_png; public static ImageFormat Tiff => s_tiff; public static ImageFormat Exif => s_exif; public static ImageFormat Icon => s_icon; [SupportedOSPlatform("windows10.0.17763.0")] public static ImageFormat Heif { get { return s_heif; } } [SupportedOSPlatform("windows10.0.17763.0")] public static ImageFormat Webp { get { return s_webp; } } internal Guid Encoder => ImageCodecInfoHelper.GetEncoderClsid(_guid); public ImageFormat(Guid guid) { _guid = guid; } [NullableContext(2)] public override bool Equals([NotNullWhen(true)] object o) { ImageFormat imageFormat = o as ImageFormat; if (imageFormat != null) return _guid == imageFormat._guid; return false; } public override int GetHashCode() { return _guid.GetHashCode(); } public override string ToString() { if (Guid == PInvokeCore.ImageFormatMemoryBMP) return "MemoryBMP"; if (Guid == PInvokeCore.ImageFormatBMP) return "Bmp"; if (Guid == PInvokeCore.ImageFormatEMF) return "Emf"; if (Guid == PInvokeCore.ImageFormatWMF) return "Wmf"; if (Guid == PInvokeCore.ImageFormatGIF) return "Gif"; if (Guid == PInvokeCore.ImageFormatJPEG) return "Jpeg"; if (Guid == PInvokeCore.ImageFormatPNG) return "Png"; if (Guid == PInvokeCore.ImageFormatTIFF) return "Tiff"; if (Guid == PInvokeCore.ImageFormatEXIF) return "Exif"; if (Guid == PInvokeCore.ImageFormatIcon) return "Icon"; if (Guid == PInvokeCore.ImageFormatHEIF) return "Heif"; if (Guid == PInvokeCore.ImageFormatWEBP) return "Webp"; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(15, 1); defaultInterpolatedStringHandler.AppendLiteral("[ImageFormat: "); defaultInterpolatedStringHandler.AppendFormatted(_guid); defaultInterpolatedStringHandler.AppendLiteral("]"); return defaultInterpolatedStringHandler.ToStringAndClear(); } } }