Browse Source

Fix alpha channel and add inverted test

pull/368/head
James Jackson-South 9 years ago
parent
commit
cce1bf93d4
  1. 9
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  2. 4
      tests/ImageSharp.Tests/TestImages.cs
  3. BIN
      tests/Images/Input/Bmp/test8-inverted.bmp
  4. BIN
      tests/Images/Input/Bmp/test8.bmp

9
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -371,15 +371,15 @@ namespace SixLabors.ImageSharp.Formats.Bmp
padding = 4 - padding; padding = 4 - padding;
} }
byte[] row = new byte[arrayWidth + padding]; using (var row = Buffer<byte>.CreateClean(arrayWidth + padding))
{
var color = default(TPixel); var color = default(TPixel);
var rgba = new Rgba32(0, 0, 0, 255);
var rgba = default(Rgba32);
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
int newY = Invert(y, height, inverted); int newY = Invert(y, height, inverted);
this.currentStream.Read(row, 0, row.Length); this.currentStream.Read(row.Array, 0, row.Length);
int offset = 0; int offset = 0;
Span<TPixel> pixelRow = pixels.GetRowSpan(newY); Span<TPixel> pixelRow = pixels.GetRowSpan(newY);
@ -403,6 +403,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
} }
} }
} }
}
/// <summary> /// <summary>
/// Reads the 16 bit color palette from the stream /// Reads the 16 bit color palette from the stream

4
tests/ImageSharp.Tests/TestImages.cs

@ -135,8 +135,10 @@ namespace SixLabors.ImageSharp.Tests
public const string CoreHeader = "Bmp/BitmapCoreHeaderQR.bmp"; public const string CoreHeader = "Bmp/BitmapCoreHeaderQR.bmp";
public const string V5Header = "Bmp/BITMAPV5HEADER.bmp"; public const string V5Header = "Bmp/BITMAPV5HEADER.bmp";
public const string RLE = "Bmp/RunLengthEncoded.bmp"; public const string RLE = "Bmp/RunLengthEncoded.bmp";
public const string Bit8 = "Bmp/test8.bmp";
public const string Bit8Inverted = "Bmp/test8-inverted.bmp";
public static readonly string[] All = { Car, F, NegHeight, CoreHeader, V5Header, RLE }; public static readonly string[] All = { Car, F, NegHeight, CoreHeader, V5Header, RLE, Bit8, Bit8Inverted };
} }
public static class Gif public static class Gif

BIN
tests/Images/Input/Bmp/test8-inverted.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
tests/Images/Input/Bmp/test8.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Loading…
Cancel
Save