Skip to content

Commit 9291581

Browse files
Merge branch 'main' into patch-1
2 parents c09d20e + 6a7e5ff commit 9291581

File tree

9 files changed

+40
-2
lines changed

9 files changed

+40
-2
lines changed

src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ private void Write1BitPixelData<TPixel>(Configuration configuration, Stream stre
668668

669669
if (quantizedPixelRow.Length % 8 != 0)
670670
{
671-
int startIdx = quantizedPixelRow.Length - 7;
671+
int startIdx = quantizedPixelRow.Length - (quantizedPixelRow.Length % 8);
672672
endIdx = quantizedPixelRow.Length;
673673
Write1BitPalette(stream, startIdx, endIdx, quantizedPixelRow);
674674
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static void Undo(Span<byte> pixelBytes, int width, TiffColorType colorTyp
4444
UndoRgb24Bit(pixelBytes, width);
4545
break;
4646
case TiffColorType.Rgba8888:
47+
case TiffColorType.Cmyk:
4748
UndoRgba32Bit(pixelBytes, width);
4849
break;
4950
case TiffColorType.Rgb161616:

src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace SixLabors.ImageSharp.PixelFormats;
99

1010
/// <summary>
11-
/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 635535.
11+
/// Packed pixel type containing three 16-bit unsigned normalized values ranging from 0 to 65535.
1212
/// <para>
1313
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
1414
/// </para>

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,30 @@ public void Encode_WorksWithDiscontiguousBuffers<TPixel>(TestImageProvider<TPixe
370370
TestBmpEncoderCore(provider, bitsPerPixel);
371371
}
372372

373+
[Theory]
374+
[WithFile(BlackWhitePalletDataMatrix, PixelTypes.Rgb24, BmpBitsPerPixel.Pixel1)]
375+
public void Encode_Issue2467<TPixel>(TestImageProvider<TPixel> provider, BmpBitsPerPixel bitsPerPixel)
376+
where TPixel : unmanaged, IPixel<TPixel>
377+
{
378+
using Image<TPixel> image = provider.GetImage();
379+
380+
using var reencodedStream = new MemoryStream();
381+
var encoder = new BmpEncoder
382+
{
383+
BitsPerPixel = bitsPerPixel,
384+
SupportTransparency = false,
385+
Quantizer = KnownQuantizers.Octree
386+
};
387+
image.SaveAsBmp(reencodedStream, encoder);
388+
reencodedStream.Seek(0, SeekOrigin.Begin);
389+
390+
using Image<TPixel> reencodedImage = Image.Load<TPixel>(reencodedStream);
391+
392+
reencodedImage.DebugSave(provider);
393+
394+
reencodedImage.CompareToOriginal(provider);
395+
}
396+
373397
private static void TestBmpEncoderCore<TPixel>(
374398
TestImageProvider<TPixel> provider,
375399
BmpBitsPerPixel bitsPerPixel,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public void TiffDecoder_CanDecode_CieLab<TPixel>(TestImageProvider<TPixel> provi
308308

309309
[Theory]
310310
[WithFile(Cmyk, PixelTypes.Rgba32)]
311+
[WithFile(CmykLzwPredictor, PixelTypes.Rgba32)]
311312
public void TiffDecoder_CanDecode_Cmyk<TPixel>(TestImageProvider<TPixel> provider)
312313
where TPixel : unmanaged, IPixel<TPixel>
313314
{

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ public static class Bmp
407407
public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp";
408408
public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp";
409409

410+
public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp";
411+
410412
public static readonly string[] BitFields =
411413
{
412414
Rgb32bfdef,
@@ -958,6 +960,7 @@ public static class Tiff
958960

959961
public const string Cmyk = "Tiff/Cmyk.tiff";
960962
public const string Cmyk64BitDeflate = "Tiff/cmyk_deflate_64bit.tiff";
963+
public const string CmykLzwPredictor = "Tiff/Cmyk-lzw-predictor.tiff";
961964

962965
public const string Issues1716Rgb161616BitLittleEndian = "Tiff/Issues/Issue1716.tiff";
963966
public const string Issues1891 = "Tiff/Issues/Issue1891.tiff";
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:3b2288e2a059b15c7855eb141c05e3ce69431e7c3ddef851033f7fd9ca39a2d4
3+
size 102
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:d322e42dd61c528e91ba9d16310248a4b9a77094a22761dcb9e6f132fc16fe1b
3+
size 1080

0 commit comments

Comments
 (0)