Browse Source

Add test images for fax3 compressed tiff

pull/1570/head
Brian Popow 5 years ago
parent
commit
250ba56fa5
  1. 48
      src/ImageSharp/Formats/Tiff/Compression/T4BitReader.cs
  2. 6
      tests/ImageSharp.Tests/TestImages.cs
  3. 3
      tests/Images/Input/Tiff/Calliphora_ccitt_fax3.tif
  4. 3
      tests/Images/Input/Tiff/ccitt_fax3_all_makeupcodes_codes.tif
  5. 3
      tests/Images/Input/Tiff/ccitt_fax3_all_terminating_codes.tif

48
src/ImageSharp/Formats/Tiff/Compression/T4BitReader.cs

@ -174,14 +174,30 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression
{ 0x9A, 1600 }, { 0x9B, 1728 }
};
private static readonly Dictionary<uint, uint> WhiteLen11MakeupCodes = new Dictionary<uint, uint>()
{
{ 0x8, 1792 }, { 0xC, 1856 }, { 0xD, 1920 }
};
private static readonly Dictionary<uint, uint> WhiteLen12MakeupCodes = new Dictionary<uint, uint>()
{
{ 0x12, 1984 }, { 0x13, 2048 }, { 0x14, 2112 }, { 0x15, 2176 }, { 0x16, 2240 }, { 0x17, 2304}, { 0x1C, 2368 }, { 0x1D, 2432 }, { 0x1E, 2496 }, { 0x1F, 2560 }
};
private static readonly Dictionary<uint, uint> BlackLen10MakeupCodes = new Dictionary<uint, uint>()
{
{ 0xF, 64 }
};
private static readonly Dictionary<uint, uint> BlackLen11MakeupCodes = new Dictionary<uint, uint>()
{
{ 0x8, 1792 }, { 0xC, 1856 }, { 0xD, 1920 }
};
private static readonly Dictionary<uint, uint> BlackLen12MakeupCodes = new Dictionary<uint, uint>()
{
{ 0xC8, 128 }, { 0xC9, 192 }, { 0x5B, 256 }, { 0x33, 320 }, { 0x34, 384 }, { 0x35, 448 }
{ 0xC8, 128 }, { 0xC9, 192 }, { 0x5B, 256 }, { 0x33, 320 }, { 0x34, 384 }, { 0x35, 448 },
{ 0x12, 1984 }, { 0x13, 2048 }, { 0x14, 2112 }, { 0x15, 2176 }, { 0x16, 2240 }, { 0x17, 2304}, { 0x1C, 2368 }, { 0x1D, 2432 }, { 0x1E, 2496 }, { 0x1F, 2560 }
};
private static readonly Dictionary<uint, uint> BlackLen13MakeupCodes = new Dictionary<uint, uint>()
@ -481,6 +497,16 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression
{
return WhiteLen9MakeupCodes[this.value];
}
case 11:
{
return WhiteLen11MakeupCodes[this.value];
}
case 12:
{
return WhiteLen12MakeupCodes[this.value];
}
}
return 0;
@ -495,6 +521,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression
return BlackLen10MakeupCodes[this.value];
}
case 11:
{
return BlackLen11MakeupCodes[this.value];
}
case 12:
{
return BlackLen12MakeupCodes[this.value];
@ -547,6 +578,16 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression
{
return WhiteLen9MakeupCodes.ContainsKey(this.value);
}
case 11:
{
return WhiteLen11MakeupCodes.ContainsKey(this.value);
}
case 12:
{
return WhiteLen12MakeupCodes.ContainsKey(this.value);
}
}
return false;
@ -561,6 +602,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression
return BlackLen10MakeupCodes.ContainsKey(this.value);
}
case 11:
{
return BlackLen11MakeupCodes.ContainsKey(this.value);
}
case 12:
{
return BlackLen12MakeupCodes.ContainsKey(this.value);

6
tests/ImageSharp.Tests/TestImages.cs

@ -511,6 +511,10 @@ namespace SixLabors.ImageSharp.Tests
public const string Calliphora_RgbLzw_Predictor = "Tiff/Calliphora_rgb_lzw.tiff";
public const string Calliphora_RgbPackbits = "Tiff/Calliphora_rgb_packbits.tiff";
public const string Calliphora_RgbUncompressed = "Tiff/Calliphora_rgb_uncompressed.tiff";
public const string Calliphora_Fax3Compressed = "Tiff/Calliphora_ccitt_fax3.tif";
public const string CcittFax3AllTermCodes = "Tiff/ccitt_fax3_all_terminating_codes.tif";
public const string CcittFax3AllMakupCodes = "Tiff/ccitt_fax3_all_makeup_codes.tif";
public const string GrayscaleDeflateMultistrip = "Tiff/grayscale_deflate_multistrip.tiff";
public const string GrayscaleUncompressed = "Tiff/grayscale_uncompressed.tiff";
@ -541,7 +545,7 @@ namespace SixLabors.ImageSharp.Tests
public const string SampleMetadata = "Tiff/metadata_sample.tiff";
public static readonly string[] All = { Calliphora_GrayscaleUncompressed, Calliphora_PaletteUncompressed, /*Calliphora_RgbDeflate_Predictor, Calliphora_RgbLzwe_Predictor, */ Calliphora_RgbPackbits, Calliphora_RgbUncompressed, GrayscaleDeflateMultistrip, GrayscaleUncompressed, PaletteDeflateMultistrip, PaletteUncompressed, /*RgbDeflate_Predictor,*/ RgbDeflateMultistrip, /*RgbJpeg,*/ /*RgbLzw_Predictor, RgbLzwMultistrip_Predictor,*/ RgbLzw_NoPredictor_Multistrip, RgbLzw_NoPredictor_Multistrip_Motorola, RgbLzw_NoPredictor_Singlestrip_Motorola, RgbPackbits, RgbPackbitsMultistrip, RgbUncompressed, /* MultiframeLzw_Predictor, MultiFrameDifferentVariants, SampleMetadata,*/ SmallRgbDeflate, SmallRgbLzw, };
public static readonly string[] All = { Calliphora_GrayscaleUncompressed, Calliphora_PaletteUncompressed, /*Calliphora_RgbDeflate_Predictor, Calliphora_RgbLzwe_Predictor, */ Calliphora_RgbPackbits, Calliphora_RgbUncompressed, Calliphora_Fax3Compressed, CcittFax3AllTermCodes, CcittFax3AllMakupCodes, GrayscaleDeflateMultistrip, GrayscaleUncompressed, PaletteDeflateMultistrip, PaletteUncompressed, /*RgbDeflate_Predictor,*/ RgbDeflateMultistrip, /*RgbJpeg,*/ /*RgbLzw_Predictor, RgbLzwMultistrip_Predictor,*/ RgbLzw_NoPredictor_Multistrip, RgbLzw_NoPredictor_Multistrip_Motorola, RgbLzw_NoPredictor_Singlestrip_Motorola, RgbPackbits, RgbPackbitsMultistrip, RgbUncompressed, /* MultiframeLzw_Predictor, MultiFrameDifferentVariants, SampleMetadata,*/ SmallRgbDeflate, SmallRgbLzw, };
public static readonly string[] Multiframes = { MultiframeDeflateWithPreview /*MultiframeLzw_Predictor, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ };

3
tests/Images/Input/Tiff/Calliphora_ccitt_fax3.tif

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a45c92b187e7a59247ccc50f418379e91fd169b39fa7fc8a6dcda9b092fc3013
size 125776

3
tests/Images/Input/Tiff/ccitt_fax3_all_makeupcodes_codes.tif

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3b1a0af9ace55d5d4b86225cb569a8632b6a6bb621fa1dc56a7d3d6404eba7bb
size 360

3
tests/Images/Input/Tiff/ccitt_fax3_all_terminating_codes.tif

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:faa92346ccff9cc7e3275b31cbc4ec054e27d0d0ed20a215a22b6178c2d7adf0
size 564
Loading…
Cancel
Save