Browse Source
Merge pull request #676 from SixLabors/js/defect-675
Fix 1 bit bmp decoding and add extra test images.
af/merge-core
James Jackson-South
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
30 additions and
8 deletions
-
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
-
tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Bmp/pal1.bmp
-
tests/Images/Input/Bmp/pal1p1.bmp
-
tests/Images/Input/Bmp/pal4.bmp
|
|
|
@ -373,11 +373,9 @@ namespace SixLabors.ImageSharp.Formats.Bmp |
|
|
|
for (int x = 0; x < arrayWidth; x++) |
|
|
|
{ |
|
|
|
int colOffset = x * ppb; |
|
|
|
|
|
|
|
for (int shift = 0; shift < ppb && (x + shift) < width; shift++) |
|
|
|
for (int shift = 0, newX = colOffset; shift < ppb && newX < width; shift++, newX++) |
|
|
|
{ |
|
|
|
int colorIndex = ((rowSpan[offset] >> (8 - bits - (shift * bits))) & mask) * 4; |
|
|
|
int newX = colOffset + shift; |
|
|
|
|
|
|
|
// Stored in b-> g-> r order.
|
|
|
|
rgba.Bgr = Unsafe.As<byte, Bgr24>(ref colors[colorIndex]); |
|
|
|
|
|
|
|
@ -17,10 +17,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
{ |
|
|
|
public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; |
|
|
|
|
|
|
|
public static readonly string[] AllBmpFiles = |
|
|
|
{ |
|
|
|
Car, F, NegHeight, CoreHeader, V5Header, RLE, RLEInverted, Bit8, Bit8Inverted, Bit16, Bit16Inverted |
|
|
|
}; |
|
|
|
public static readonly string[] AllBmpFiles = All; |
|
|
|
|
|
|
|
public static readonly TheoryData<string, int, int, PixelResolutionUnit> RatioFiles = |
|
|
|
new TheoryData<string, int, int, PixelResolutionUnit> |
|
|
|
|
|
|
|
@ -165,12 +165,30 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string V5Header = "Bmp/BITMAPV5HEADER.bmp"; |
|
|
|
public const string RLE = "Bmp/RunLengthEncoded.bmp"; |
|
|
|
public const string RLEInverted = "Bmp/RunLengthEncoded-inverted.bmp"; |
|
|
|
public const string Bit1 = "Bmp/pal1.bmp"; |
|
|
|
public const string Bit1Pal1 = "Bmp/pal1p1.bmp"; |
|
|
|
public const string Bit4 = "Bmp/pal4.bmp"; |
|
|
|
public const string Bit8 = "Bmp/test8.bmp"; |
|
|
|
public const string Bit8Inverted = "Bmp/test8-inverted.bmp"; |
|
|
|
public const string Bit16 = "Bmp/test16.bmp"; |
|
|
|
public const string Bit16Inverted = "Bmp/test16-inverted.bmp"; |
|
|
|
|
|
|
|
public static readonly string[] All = { Car, F, NegHeight, CoreHeader, V5Header, RLE, RLEInverted, Bit8, Bit8Inverted, Bit16, Bit16Inverted }; |
|
|
|
public static readonly string[] All |
|
|
|
= { |
|
|
|
Car, |
|
|
|
F, |
|
|
|
NegHeight, |
|
|
|
CoreHeader, |
|
|
|
V5Header, RLE, |
|
|
|
RLEInverted, |
|
|
|
Bit1, |
|
|
|
Bit1Pal1, |
|
|
|
Bit4, |
|
|
|
Bit8, |
|
|
|
Bit8Inverted, |
|
|
|
Bit16, |
|
|
|
Bit16Inverted |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public static class Gif |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:c631861fa4c4e959d2abc6e0db0106253989b0101223cb08020e116e19c97f77 |
|
|
|
size 1086 |
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:620eb83715dd99a640b6c61f5337c2f01fd19246d4759a2bc0480b8ee960bf63 |
|
|
|
size 1082 |
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:01f7bfaaf5110a404fb68451a860970750c155e5c46e1721fa6b9c500be0ca2c |
|
|
|
size 4198 |