Skip to content

Commit 8f0b4d3

Browse files
authored
Merge pull request #2717 from SixLabors/backport/v2-clear-buffers
V2 - Clear Pixel Buffers on Decode.
2 parents a78ce27 + c122185 commit 8f0b4d3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public override void InjectFrameData(JpegFrame frame, IRawJpegData jpegData)
116116
this.pixelBuffer = allocator.Allocate2D<TPixel>(
117117
frame.PixelWidth,
118118
frame.PixelHeight,
119-
this.configuration.PreferContiguousImageBuffers);
119+
this.configuration.PreferContiguousImageBuffers,
120+
AllocationOptions.Clean);
120121
this.paddedProxyPixelRow = allocator.Allocate<TPixel>(frame.PixelWidth + 3);
121122

122123
// component processors from spectral to Rgba32
@@ -215,4 +216,4 @@ public void Dispose()
215216
this.pixelBuffer?.Dispose();
216217
}
217218
}
218-
}
219+
}

src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
9797
throw new UnknownImageFormatException("Width or height cannot be 0");
9898
}
9999

100-
var image = Image.CreateUninitialized<TPixel>(this.Configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata);
100+
Image<TPixel> image = new(this.Configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata);
101101
Buffer2D<TPixel> pixels = image.GetRootFramePixelBuffer();
102102

103103
if (this.fileHeader.ColorMapType == 1)

0 commit comments

Comments
 (0)