Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public static void ProcessInterlacedGrayscaleScanline<TPixel>(
{
byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor);
Rgba32 rgba32 = default;
for (int x = pixelOffset; x < header.Width; x += increment)
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
rgba32.R = luminance;
rgba32.G = luminance;
rgba32.B = luminance;
Expand Down
20 changes: 11 additions & 9 deletions tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ public partial class PngDecoderTests
TestImages.Png.GrayTrns16BitInterlaced
};

public static readonly string[] TestImagesGrayAlpha8Bit =
public static readonly string[] TestImagesGray8BitInterlaced =
{
TestImages.Png.GrayAlpha8Bit,
TestImages.Png.GrayAlpha8Bit2
TestImages.Png.GrayAlpha1BitInterlaced,
TestImages.Png.GrayAlpha2BitInterlaced,
TestImages.Png.Gray4BitInterlaced,
TestImages.Png.GrayAlpha8BitInterlaced
};

public static readonly TheoryData<string, int, int, PixelResolutionUnit> RatioFiles =
Expand Down Expand Up @@ -130,8 +132,8 @@ public void Decode_64Bpp<TPixel>(TestImageProvider<TPixel> provider)
}

[Theory]
[WithFileCollection(nameof(TestImagesGrayAlpha8Bit), PixelTypes.Rgba32)]
public void Decoder_Gray8bitWithAlpha<TPixel>(TestImageProvider<TPixel> provider)
[WithFileCollection(nameof(TestImagesGray8BitInterlaced), PixelTypes.Rgba32)]
public void Decoder_Gray8bitInterlaced<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(new PngDecoder()))
Expand Down Expand Up @@ -166,8 +168,8 @@ public void Decode_GrayAlpha16Bit<TPixel>(TestImageProvider<TPixel> provider)
}

[Theory]
[WithFile(TestImages.Png.Splash, PixelTypes)]
public void Decoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider)
[WithFile(TestImages.Png.GrayAlpha8BitInterlaced, PixelTypes)]
public void Decoder_CanDecodeGrey8bitWithAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(new PngDecoder()))
Expand All @@ -178,8 +180,8 @@ public void Decoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel
}

[Theory]
[WithFile(TestImages.Png.GrayAlpha8Bit2, PixelTypes)]
public void Decoder_CanDecodeGrey8bitWithAlpha<TPixel>(TestImageProvider<TPixel> provider)
[WithFile(TestImages.Png.Splash, PixelTypes)]
public void Decoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(new PngDecoder()))
Expand Down
5 changes: 4 additions & 1 deletion tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static class Png
public const string Gray4Bpp = "Png/gray_4bpp.png";
public const string Gray16Bit = "Png/gray-16.png";
public const string GrayAlpha8Bit = "Png/gray-alpha-8.png";
public const string GrayAlpha8Bit2 = "Png/rollsroyce.png";
public const string GrayAlpha8BitInterlaced = "Png/rollsroyce.png";
public const string GrayAlpha1BitInterlaced = "Png/iftbbn0g01.png";
public const string GrayAlpha2BitInterlaced = "Png/iftbbn0g02.png";
public const string Gray4BitInterlaced = "Png/iftbbn0g04.png";
public const string GrayAlpha16Bit = "Png/gray-alpha-16.png";
public const string GrayTrns16BitInterlaced = "Png/gray-16-tRNS-interlaced.png";
public const string Rgb24BppTrans = "Png/rgb-8-tRNS.png";
Expand Down
Binary file added tests/Images/Input/Png/iftbbn0g01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Images/Input/Png/iftbbn0g02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Images/Input/Png/iftbbn0g04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.