Skip to content

Commit

Permalink
Feature: Bitmap RLE undefined pixel handling (SixLabors#927)
Browse files Browse the repository at this point in the history
* Add bitmap decoder option, how to treat skipped pixels for RLE

* Refactored bitmap tests into smaller tests, instead of just one test which goes through all bitmap files

* Add another adobe v3 header bitmap testcase

* Using the constant from BmpConstants to Identify bitmaps

* Bitmap decoder now can handle oversized palette's

* Add test for invalid palette size

* Renamed RleUndefinedPixelHandling to RleSkippedPixelHandling

* Explicitly using SystemDrawingReferenceDecoder in some BitmapDecoder tests

* Add test cases for unsupported bitmaps

* Comparing RLE test images to reference decoder only on windows

* Add test case for decoding winv4 fast path

* Add another 8 Bit RLE test with magick reference decoder

* Optimize RLE skipped pixel handling

* Refactor RLE decoding to eliminate code duplication

* Using MagickReferenceDecoder for the 8-Bit RLE test
  • Loading branch information
brianpopow authored and JimBobSquarePants committed Jun 10, 2019
1 parent 4fcd7a1 commit bef4b41
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/ImageSharp.Tests/FileTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class FileTestBase
/// <summary>
/// A collection of all the bmp test images
/// </summary>
public static IEnumerable<string> AllBmpFiles = TestImages.Bmp.All;
public static IEnumerable<string> AllBmpFiles = TestImages.Bmp.Benchmark;

/// <summary>
/// A collection of all the jpeg test images
Expand Down
57 changes: 39 additions & 18 deletions tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,15 @@ public static class Bmp
public const string CoreHeader = "Bmp/BitmapCoreHeaderQR.bmp";
public const string V5Header = "Bmp/BITMAPV5HEADER.bmp";
public const string RLE8 = "Bmp/RunLengthEncoded.bmp";
public const string RLE8Cut = "Bmp/pal8rlecut.bmp";
public const string RLE8Delta = "Bmp/pal8rletrns.bmp";
public const string Rle8Delta320240 = "Bmp/rle8-delta-320x240.bmp";
public const string Rle8Blank160120 = "Bmp/rle8-blank-160x120.bmp";
public const string RLE8Inverted = "Bmp/RunLengthEncoded-inverted.bmp";
public const string RLE4 = "Bmp/pal4rle.bmp";
public const string RLEInverted = "Bmp/RunLengthEncoded-inverted.bmp";
public const string RLE4Cut = "Bmp/pal4rlecut.bmp";
public const string RLE4Delta = "Bmp/pal4rletrns.bmp";
public const string Rle4Delta320240 = "Bmp/rle4-delta-320x240.bmp";
public const string Bit1 = "Bmp/pal1.bmp";
public const string Bit1Pal1 = "Bmp/pal1p1.bmp";
public const string Bit4 = "Bmp/pal4.bmp";
Expand All @@ -256,15 +263,22 @@ public static class Bmp
public const string Os2v2 = "Bmp/pal8os2v2.bmp";
public const string LessThanFullSizedPalette = "Bmp/pal8os2sp.bmp";
public const string Pal8Offset = "Bmp/pal8offs.bmp";
public const string OversizedPalette = "Bmp/pal8oversizepal.bmp";
public const string Rgb24LargePalette = "Bmp/rgb24largepal.bmp";
public const string InvalidPaletteSize = "Bmp/invalidPaletteSize.bmp";
public const string Rgb24jpeg = "Bmp/rgb24jpeg.bmp";
public const string Rgb24png = "Bmp/rgb24png.bmp";
public const string Rgba32v4 = "Bmp/rgba32v4.bmp";

// Bitmap images with compression type BITFIELDS
// Bitmap images with compression type BITFIELDS.
public const string Rgb32bfdef = "Bmp/rgb32bfdef.bmp";
public const string Rgb32bf = "Bmp/rgb32bf.bmp";
public const string Rgb16bfdef = "Bmp/rgb16bfdef.bmp";
public const string Rgb16565 = "Bmp/rgb16-565.bmp";
public const string Rgb16565pal = "Bmp/rgb16-565pal.bmp";
public const string Issue735 = "Bmp/issue735.bmp";
public const string Rgba32bf56 = "Bmp/rgba32h56.bmp";
public const string Rgba32bf56AdobeV3 = "Bmp/rgba32h56.bmp";
public const string Rgb32h52AdobeV3 = "Bmp/rgb32h52.bmp";
public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp";
public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp";

Expand All @@ -278,25 +292,32 @@ public static readonly string[] BitFields
Issue735,
};

public static readonly string[] All
public static readonly string[] Miscellaneous
= {
Car,
F,
NegHeight,
CoreHeader,
V5Header,
RLE4,
RLE8,
RLEInverted,
Bit1,
Bit1Pal1,
Bit4,
Bit8,
Bit8Inverted,
Bit16,
Bit16Inverted,
Bit32Rgb
NegHeight
};

public static readonly string[] Benchmark
= {
Car,
F,
NegHeight,
CoreHeader,
V5Header,
RLE4,
RLE8,
RLE8Inverted,
Bit1,
Bit1Pal1,
Bit4,
Bit8,
Bit8Inverted,
Bit16,
Bit16Inverted,
Bit32Rgb
};
}

public static class Gif
Expand Down

0 comments on commit bef4b41

Please sign in to comment.