Browse Source

Merge branch 'main' into patch-1

pull/2453/head
James Jackson-South 3 years ago
committed by GitHub
parent
commit
92915812e7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
  2. 1
      src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs
  3. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  4. 24
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
  5. 1
      tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
  6. 3
      tests/ImageSharp.Tests/TestImages.cs
  7. 3
      tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png
  8. 3
      tests/Images/Input/Bmp/bit1datamatrix.bmp
  9. 3
      tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff

2
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -668,7 +668,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals
if (quantizedPixelRow.Length % 8 != 0)
{
int startIdx = quantizedPixelRow.Length - 7;
int startIdx = quantizedPixelRow.Length - (quantizedPixelRow.Length % 8);
endIdx = quantizedPixelRow.Length;
Write1BitPalette(stream, startIdx, endIdx, quantizedPixelRow);
}

1
src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs

@ -44,6 +44,7 @@ internal static class HorizontalPredictor
UndoRgb24Bit(pixelBytes, width);
break;
case TiffColorType.Rgba8888:
case TiffColorType.Cmyk:
UndoRgba32Bit(pixelBytes, width);
break;
case TiffColorType.Rgb161616:

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats;
/// <summary>
/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 635535.
/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 65535.
/// <para>
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para>

24
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -370,6 +370,30 @@ public class BmpEncoderTests
TestBmpEncoderCore(provider, bitsPerPixel);
}
[Theory]
[WithFile(BlackWhitePalletDataMatrix, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel1)]
public void Encode_Issue2467<TPixel>(TestImageProvider<TPixel> provider, BmpBitsPerPixel bitsPerPixel)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage();
using var reencodedStream = new MemoryStream();
var encoder = new BmpEncoder
{
BitsPerPixel = bitsPerPixel,
SupportTransparency = false,
Quantizer = KnownQuantizers.Octree
};
image.SaveAsBmp(reencodedStream, encoder);
reencodedStream.Seek(0, SeekOrigin.Begin);
using Image<TPixel> reencodedImage = Image.Load<TPixel>(reencodedStream);
reencodedImage.DebugSave(provider);
reencodedImage.CompareToOriginal(provider);
}
private static void TestBmpEncoderCore<TPixel>(
TestImageProvider<TPixel> provider,
BmpBitsPerPixel bitsPerPixel,

1
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs

@ -308,6 +308,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester
[Theory]
[WithFile(Cmyk, PixelTypes.Rgba32)]
[WithFile(CmykLzwPredictor, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_Cmyk<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

3
tests/ImageSharp.Tests/TestImages.cs

@ -407,6 +407,8 @@ public static class TestImages
public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp";
public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp";
public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp";
public static readonly string[] BitFields =
{
Rgb32bfdef,
@ -958,6 +960,7 @@ public static class TestImages
public const string Cmyk = "Tiff/Cmyk.tiff";
public const string Cmyk64BitDeflate = "Tiff/cmyk_deflate_64bit.tiff";
public const string CmykLzwPredictor = "Tiff/Cmyk-lzw-predictor.tiff";
public const string Issues1716Rgb161616BitLittleEndian = "Tiff/Issues/Issue1716.tiff";
public const string Issues1891 = "Tiff/Issues/Issue1891.tiff";

3
tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_Cmyk_Rgba32_Cmyk-lzw-predictor.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:db076491d7afc78cb5de99cb1e7a9c53f891157bf064994c60d453aec75b9c90
size 512

3
tests/Images/Input/Bmp/bit1datamatrix.bmp

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3b2288e2a059b15c7855eb141c05e3ce69431e7c3ddef851033f7fd9ca39a2d4
size 102

3
tests/Images/Input/Tiff/Cmyk-lzw-predictor.tiff

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d322e42dd61c528e91ba9d16310248a4b9a77094a22761dcb9e6f132fc16fe1b
size 1080
Loading…
Cancel
Save