Skip to content

Commit bef4b41

Browse files
brianpopowJimBobSquarePants
authored andcommitted
Feature: Bitmap RLE undefined pixel handling (SixLabors#927)
* 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
1 parent 4fcd7a1 commit bef4b41

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

tests/ImageSharp.Tests/FileTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public abstract class FileTestBase
2828
/// <summary>
2929
/// A collection of all the bmp test images
3030
/// </summary>
31-
public static IEnumerable<string> AllBmpFiles = TestImages.Bmp.All;
31+
public static IEnumerable<string> AllBmpFiles = TestImages.Bmp.Benchmark;
3232

3333
/// <summary>
3434
/// A collection of all the jpeg test images

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,15 @@ public static class Bmp
231231
public const string CoreHeader = "Bmp/BitmapCoreHeaderQR.bmp";
232232
public const string V5Header = "Bmp/BITMAPV5HEADER.bmp";
233233
public const string RLE8 = "Bmp/RunLengthEncoded.bmp";
234+
public const string RLE8Cut = "Bmp/pal8rlecut.bmp";
235+
public const string RLE8Delta = "Bmp/pal8rletrns.bmp";
236+
public const string Rle8Delta320240 = "Bmp/rle8-delta-320x240.bmp";
237+
public const string Rle8Blank160120 = "Bmp/rle8-blank-160x120.bmp";
238+
public const string RLE8Inverted = "Bmp/RunLengthEncoded-inverted.bmp";
234239
public const string RLE4 = "Bmp/pal4rle.bmp";
235-
public const string RLEInverted = "Bmp/RunLengthEncoded-inverted.bmp";
240+
public const string RLE4Cut = "Bmp/pal4rlecut.bmp";
241+
public const string RLE4Delta = "Bmp/pal4rletrns.bmp";
242+
public const string Rle4Delta320240 = "Bmp/rle4-delta-320x240.bmp";
236243
public const string Bit1 = "Bmp/pal1.bmp";
237244
public const string Bit1Pal1 = "Bmp/pal1p1.bmp";
238245
public const string Bit4 = "Bmp/pal4.bmp";
@@ -256,15 +263,22 @@ public static class Bmp
256263
public const string Os2v2 = "Bmp/pal8os2v2.bmp";
257264
public const string LessThanFullSizedPalette = "Bmp/pal8os2sp.bmp";
258265
public const string Pal8Offset = "Bmp/pal8offs.bmp";
266+
public const string OversizedPalette = "Bmp/pal8oversizepal.bmp";
267+
public const string Rgb24LargePalette = "Bmp/rgb24largepal.bmp";
268+
public const string InvalidPaletteSize = "Bmp/invalidPaletteSize.bmp";
269+
public const string Rgb24jpeg = "Bmp/rgb24jpeg.bmp";
270+
public const string Rgb24png = "Bmp/rgb24png.bmp";
271+
public const string Rgba32v4 = "Bmp/rgba32v4.bmp";
259272

260-
// Bitmap images with compression type BITFIELDS
273+
// Bitmap images with compression type BITFIELDS.
261274
public const string Rgb32bfdef = "Bmp/rgb32bfdef.bmp";
262275
public const string Rgb32bf = "Bmp/rgb32bf.bmp";
263276
public const string Rgb16bfdef = "Bmp/rgb16bfdef.bmp";
264277
public const string Rgb16565 = "Bmp/rgb16-565.bmp";
265278
public const string Rgb16565pal = "Bmp/rgb16-565pal.bmp";
266279
public const string Issue735 = "Bmp/issue735.bmp";
267-
public const string Rgba32bf56 = "Bmp/rgba32h56.bmp";
280+
public const string Rgba32bf56AdobeV3 = "Bmp/rgba32h56.bmp";
281+
public const string Rgb32h52AdobeV3 = "Bmp/rgb32h52.bmp";
268282
public const string Rgba321010102 = "Bmp/rgba32-1010102.bmp";
269283
public const string RgbaAlphaBitfields = "Bmp/rgba32abf.bmp";
270284

@@ -278,25 +292,32 @@ public static readonly string[] BitFields
278292
Issue735,
279293
};
280294

281-
public static readonly string[] All
295+
public static readonly string[] Miscellaneous
282296
= {
283297
Car,
284298
F,
285-
NegHeight,
286-
CoreHeader,
287-
V5Header,
288-
RLE4,
289-
RLE8,
290-
RLEInverted,
291-
Bit1,
292-
Bit1Pal1,
293-
Bit4,
294-
Bit8,
295-
Bit8Inverted,
296-
Bit16,
297-
Bit16Inverted,
298-
Bit32Rgb
299+
NegHeight
299300
};
301+
302+
public static readonly string[] Benchmark
303+
= {
304+
Car,
305+
F,
306+
NegHeight,
307+
CoreHeader,
308+
V5Header,
309+
RLE4,
310+
RLE8,
311+
RLE8Inverted,
312+
Bit1,
313+
Bit1Pal1,
314+
Bit4,
315+
Bit8,
316+
Bit8Inverted,
317+
Bit16,
318+
Bit16Inverted,
319+
Bit32Rgb
320+
};
300321
}
301322

302323
public static class Gif

0 commit comments

Comments
 (0)