diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 0f432fbda9..e1611b059b 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -141,7 +141,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals _ => 0 }; - byte[] iccProfileData = Array.Empty(); + byte[]? iccProfileData = null; int iccProfileSize = 0; if (metadata.IccProfile != null) { @@ -181,7 +181,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals /// The metadata. /// The icc profile data. /// The bitmap information header. - private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, short bpp, int bytesPerLine, ImageMetadata metadata, byte[] iccProfileData) + private BmpInfoHeader CreateBmpInfoHeader(int width, int height, int infoHeaderSize, short bpp, int bytesPerLine, ImageMetadata metadata, byte[]? iccProfileData) { int hResolution = 0; int vResolution = 0; @@ -235,7 +235,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals if (this.infoHeaderType is BmpInfoHeaderType.WinVersion5 && metadata.IccProfile != null) { - infoHeader.ProfileSize = iccProfileData.Length; + infoHeader.ProfileSize = iccProfileData!.Length; infoHeader.CsType = BmpColorSpace.PROFILE_EMBEDDED; infoHeader.Intent = BmpRenderingIntent.LCS_GM_IMAGES; } @@ -249,7 +249,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals /// The stream to write to. /// The color profile data. /// The buffer. - private static void WriteColorProfile(Stream stream, byte[] iccProfileData, Span buffer) + private static void WriteColorProfile(Stream stream, byte[]? iccProfileData, Span buffer) { if (iccProfileData != null) {