From c122185ea030fcbad2e7aaab9d0a3d6cf30d6798 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 6 Apr 2024 11:29:51 +1000 Subject: [PATCH] Clear pixel buffers on decode. --- .../Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs | 5 +++-- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs index 532892e060..220bc16798 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs @@ -116,7 +116,8 @@ public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData) this.pixelBuffer = allocator.Allocate2D( frame.PixelWidth, frame.PixelHeight, - this.configuration.PreferContiguousImageBuffers); + this.configuration.PreferContiguousImageBuffers, + AllocationOptions.Clean); this.paddedProxyPixelRow = allocator.Allocate(frame.PixelWidth + 3); // component processors from spectral to Rgba32 @@ -215,4 +216,4 @@ public void Dispose() this.pixelBuffer?.Dispose(); } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index d101ccd94a..523ead871e 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -97,7 +97,7 @@ public Image Decode(BufferedReadStream stream, CancellationToken throw new UnknownImageFormatException("Width or height cannot be 0"); } - var image = Image.CreateUninitialized(this.Configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata); + Image image = new(this.Configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.fileHeader.ColorMapType == 1)