Skip to content

Commit

Permalink
Execute RemoveStridePadding in place when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
BobLd committed Jan 5, 2025
1 parent 53cf4f2 commit f86cc58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/UglyToad.PdfPig/Images/ColorSpaceDetailsByteConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private static Span<byte> UnpackComponents(Span<byte> input, int bitsPerComponen

private static Span<byte> RemoveStridePadding(Span<byte> input, int strideWidth, int imageWidth, int imageHeight, int multiplier)
{
Span<byte> result = new byte[imageWidth * imageHeight * multiplier];
int size = imageWidth * imageHeight * multiplier;
Span<byte> result = size < input.Length ? input.Slice(0, size) : new byte[size];
// See PDFBOX-492-4.jar-8.pdf, page 2 for size > input.Length

for (int y = 0; y < imageHeight; y++)
{
int sourceIndex = y * strideWidth;
Expand Down

0 comments on commit f86cc58

Please sign in to comment.