From bf8c17cb83a59dd1bd38b85def966c2ca9d1b3da Mon Sep 17 00:00:00 2001 From: Johannes Bildstein Date: Thu, 24 Aug 2017 16:19:57 +0200 Subject: [PATCH 01/13] handle CultureNotFoundException when reading MultilocalizedUnicodeTagDataEntry --- .../DataReader/IccDataReader.TagDataEntry.cs | 44 +++++++---- .../TestDataIcc/IccTestDataTagDataEntry.cs | 73 +++++++++++++++---- 2 files changed, 88 insertions(+), 29 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 711de818b3..0fe03284fd 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -476,19 +476,7 @@ namespace ImageSharp string languageCode = this.ReadAsciiString(2); string countryCode = this.ReadAsciiString(2); - if (string.IsNullOrWhiteSpace(languageCode)) - { - culture[i] = CultureInfo.InvariantCulture; - } - else if (string.IsNullOrWhiteSpace(countryCode)) - { - culture[i] = new CultureInfo(languageCode); - } - else - { - culture[i] = new CultureInfo($"{languageCode}-{countryCode}"); - } - + culture[i] = ReadCulture(languageCode, countryCode); length[i] = this.ReadUInt32(); offset[i] = this.ReadUInt32(); } @@ -500,6 +488,36 @@ namespace ImageSharp } return new IccMultiLocalizedUnicodeTagDataEntry(text); + + CultureInfo ReadCulture(string language, string country) + { + if (string.IsNullOrWhiteSpace(language)) + { + return CultureInfo.InvariantCulture; + } + else if (string.IsNullOrWhiteSpace(country)) + { + try + { + return new CultureInfo(language); + } + catch (CultureNotFoundException) + { + return CultureInfo.InvariantCulture; + } + } + else + { + try + { + return new CultureInfo($"{language}-{country}"); + } + catch (CultureNotFoundException) + { + return ReadCulture(language, null); + } + } + } } /// diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index 05942ab618..377cf24e7e 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -455,15 +455,46 @@ namespace ImageSharp.Tests #region MultiLocalizedUnicodeTagDataEntry - private static readonly IccLocalizedString LocalizedString_Rand_enUs = new IccLocalizedString(new CultureInfo("en-US"), IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand_deDE = new IccLocalizedString(new CultureInfo("de-DE"), IccTestDataPrimitives.Unicode_ValRand3); - private static readonly IccLocalizedString LocalizedString_Rand2_deDE = new IccLocalizedString(new CultureInfo("de-DE"), IccTestDataPrimitives.Unicode_ValRand2); - private static readonly IccLocalizedString LocalizedString_Rand_en = new IccLocalizedString(new CultureInfo("en"), IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand_enUS = CreateLocalizedString("en", "US", IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand_deDE = CreateLocalizedString("de", "DE", IccTestDataPrimitives.Unicode_ValRand3); + private static readonly IccLocalizedString LocalizedString_Rand2_deDE = CreateLocalizedString("de", "DE", IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand2_esXL = CreateLocalizedString("es", "XL", IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand2_xyXL = CreateLocalizedString("xy", "XL", IccTestDataPrimitives.Unicode_ValRand2); + private static readonly IccLocalizedString LocalizedString_Rand_en = CreateLocalizedString("en", null, IccTestDataPrimitives.Unicode_ValRand2); private static readonly IccLocalizedString LocalizedString_Rand_Invariant = new IccLocalizedString(CultureInfo.InvariantCulture, IccTestDataPrimitives.Unicode_ValRand3); - private static readonly IccLocalizedString[] LocalizedString_RandArr_enUs_deDE = new IccLocalizedString[] + private static IccLocalizedString CreateLocalizedString(string language, string country, string text) { - LocalizedString_Rand_enUs, + CultureInfo culture; + if (country == null) + { + try + { + culture = new CultureInfo(language); + } + catch (CultureNotFoundException) + { + culture = CultureInfo.InvariantCulture; + } + } + else + { + try + { + culture = new CultureInfo($"{language}-{country}"); + } + catch (CultureNotFoundException) + { + return CreateLocalizedString(language, null, text); + } + } + + return new IccLocalizedString(culture, text); + } + + private static readonly IccLocalizedString[] LocalizedString_RandArr_enUS_deDE = new IccLocalizedString[] + { + LocalizedString_Rand_enUS, LocalizedString_Rand_deDE, }; private static readonly IccLocalizedString[] LocalizedString_RandArr_en_Invariant = new IccLocalizedString[] @@ -471,13 +502,15 @@ namespace ImageSharp.Tests LocalizedString_Rand_en, LocalizedString_Rand_Invariant, }; - private static readonly IccLocalizedString[] LocalizedString_SameArr_enUs_deDE = new IccLocalizedString[] + private static readonly IccLocalizedString[] LocalizedString_SameArr_enUS_deDE_esXL_xyXL = new IccLocalizedString[] { - LocalizedString_Rand_enUs, - LocalizedString_Rand2_deDE + LocalizedString_Rand_enUS, + LocalizedString_Rand2_deDE, + LocalizedString_Rand2_esXL, + LocalizedString_Rand2_xyXL, }; - public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr_enUs_deDE); + public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_RandArr_enUS_deDE); public static readonly byte[] MultiLocalizedUnicode_Arr = ArrayHelper.Concat ( IccTestDataPrimitives.UInt32_2, @@ -530,19 +563,27 @@ namespace ImageSharp.Tests IccTestDataPrimitives.Unicode_Rand3 ); - public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val3 = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_SameArr_enUs_deDE); + public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicode_Val3 = new IccMultiLocalizedUnicodeTagDataEntry(LocalizedString_SameArr_enUS_deDE_esXL_xyXL); public static readonly byte[] MultiLocalizedUnicode_Arr3 = ArrayHelper.Concat ( - IccTestDataPrimitives.UInt32_2, + IccTestDataPrimitives.UInt32_4, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 + new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 + new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 + + new byte[] { (byte)'e', (byte)'s', (byte)'X', (byte)'L' }, + new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 + new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 + + new byte[] { (byte)'x', (byte)'y', (byte)'X', (byte)'L' }, + new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 + new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 IccTestDataPrimitives.Unicode_Rand2 ); @@ -670,8 +711,8 @@ namespace ImageSharp.Tests ( new IccProfileSequenceIdentifier[] { - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUs_deDE), - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUs_deDE), + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileId_ValRand, LocalizedString_RandArr_enUS_deDE), } ); public static readonly byte[] ProfileSequenceIdentifier_Arr = ArrayHelper.Concat From 7810b388264fdb55cb3e4b7e2567ff3b9447184f Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Fri, 25 Aug 2017 13:51:23 +1000 Subject: [PATCH 02/13] Update all dependencies --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 4 ++-- src/ImageSharp/ImageSharp.csproj | 12 ++++++------ .../General/PixelConversion_ConvertFromRgba32.cs | 2 +- .../ImageSharp.Benchmarks.csproj | 5 +++-- .../ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj | 4 ++-- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 8 ++++---- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 10562b08ca..ddf18e4280 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -36,8 +36,8 @@ - - + + All diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 8733131a74..44734ddec6 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -35,16 +35,16 @@ - + All - - + + - - + + - + ..\..\ImageSharp.ruleset diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs index e096fd828c..0f025c9a40 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion_ConvertFromRgba32.cs @@ -142,7 +142,7 @@ namespace ImageSharp.Benchmarks.General [Params(32)] public int Count { get; set; } - [Setup] + [GlobalSetup] public void Setup() { this.compatibleMemLayoutRunner = new ConversionRunner(this.Count); diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 72593a0da4..ae0fff1038 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -9,14 +9,15 @@ false + - + - + diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index b9124afc6a..c62f0519a6 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index b0429d9ede..a070dbdb74 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -10,10 +10,10 @@ - - - - + + + + From 1594bdbae00ae6fa4248f88cfd28b5456d701036 Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Fri, 25 Aug 2017 13:54:38 +1000 Subject: [PATCH 03/13] Fix png decode span bug on Core 2.0 --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index d9df44a091..633d151b6a 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -272,7 +272,7 @@ namespace ImageSharp.Formats /// is less than or equals than zero. private static Span ToArrayByBitsLength(Span source, int bytesPerScanline, int bits) { - Guard.NotNull(source, nameof(source)); + Guard.MustBeGreaterThan(source.Length, 0, nameof(source)); Guard.MustBeGreaterThan(bits, 0, nameof(bits)); if (bits >= 8) From 761996d3a9cacb4cf2d1f4f2185e14871b54226c Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Fri, 25 Aug 2017 14:09:26 +1000 Subject: [PATCH 04/13] Fix BMDN dependency issue --- tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index ae0fff1038..f488e05463 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -9,12 +9,11 @@ false - - + From fadb70224d6edd8ec45dc505db9699600e9ade03 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 28 Aug 2017 23:11:24 +0200 Subject: [PATCH 05/13] Minor optimization for the PaethFilter decoder. --- .../Formats/Png/Filters/PaethFilter.cs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs index ec12eca058..f0f5ae0995 100644 --- a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs @@ -31,22 +31,21 @@ namespace ImageSharp.Formats ref byte prevBaseRef = ref previousScanline.DangerousGetPinnableReference(); // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) - for (int x = 1; x < scanline.Length; x++) + int offset = bytesPerPixel + 1; + for (int x = 1; x < offset; x++) { - if (x - bytesPerPixel < 1) - { - ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); - byte above = Unsafe.Add(ref prevBaseRef, x); - scan = (byte)((scan + PaethPredicator(0, above, 0)) % 256); - } - else - { - ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); - byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); - byte above = Unsafe.Add(ref prevBaseRef, x); - byte upperLeft = Unsafe.Add(ref prevBaseRef, x - bytesPerPixel); - scan = (byte)((scan + PaethPredicator(left, above, upperLeft)) % 256); - } + ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); + byte above = Unsafe.Add(ref prevBaseRef, x); + scan = (byte)(scan + above); + } + + for (int x = offset; x < scanline.Length; x++) + { + ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); + byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); + byte above = Unsafe.Add(ref prevBaseRef, x); + byte upperLeft = Unsafe.Add(ref prevBaseRef, x - bytesPerPixel); + scan = (byte)(scan + PaethPredicator(left, above, upperLeft)); } } From 2dc1decf44c9c97868de31dcce898a8a54021955 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 28 Aug 2017 23:13:41 +0200 Subject: [PATCH 06/13] Added missing clear for the previousScanline when going to the next pass --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 633d151b6a..f58322ee5d 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -515,7 +515,7 @@ namespace ImageSharp.Formats this.currentRowBytesRead = 0; Span scanSpan = this.scanline.Slice(0, bytesPerInterlaceScanline); - Span prevSpan = this.previousScanline.Span.Slice(0, bytesPerInterlaceScanline); + Span prevSpan = this.previousScanline.Slice(0, bytesPerInterlaceScanline); var filterType = (FilterType)scanSpan[0]; switch (filterType) @@ -556,6 +556,8 @@ namespace ImageSharp.Formats } this.pass++; + this.previousScanline.Clear(); + if (this.pass < 7) { this.currentRow = Adam7FirstRow[this.pass]; From 0d5dacaadfa19f18c11a73fda83068117ac01334 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 28 Aug 2017 23:22:07 +0200 Subject: [PATCH 07/13] Added missing reset to zero for the Adam7 pass. --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index f58322ee5d..6429b68fa3 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -564,6 +564,7 @@ namespace ImageSharp.Formats } else { + this.pass = 0; break; } } From 23bc28c247a5ca3d197493b145027bf9c13438d8 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 28 Aug 2017 23:38:20 +0200 Subject: [PATCH 08/13] Fiked typo --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4f87647ffc..11444a3b23 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,7 +2,7 @@ - [ ] I have written a descriptive pull-request title - [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open -- [ ] I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules :cop:. +- [ ] I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:. - [ ] I have provided test coverage for my change (where applicable) ### Description From 4d5beeec14deba995f7855ae97ae030576ed27bd Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 31 Aug 2017 10:46:25 +0100 Subject: [PATCH 09/13] enable reading bmp with larger headers --- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 24 +++++++++++++++---- tests/ImageSharp.Tests/TestImages.cs | 4 +++- .../TestImages/Formats/Bmp/BITMAPV5HEADER.bmp | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/ImageSharp.Tests/TestImages/Formats/Bmp/BITMAPV5HEADER.bmp diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 108006adea..3dcbf40756 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -375,11 +375,18 @@ namespace ImageSharp.Formats // read header size this.currentStream.Read(data, 0, BmpInfoHeader.HeaderSizeSize); int headerSize = BitConverter.ToInt32(data, 0); - if (headerSize < BmpInfoHeader.HeaderSizeSize || headerSize > BmpInfoHeader.MaxHeaderSize) + if (headerSize < BmpInfoHeader.BitmapCoreHeaderSize) { throw new NotSupportedException($"This kind of bitmap files (header size $headerSize) is not supported."); } + int skipAmmount = 0; + if (headerSize > BmpInfoHeader.MaxHeaderSize) + { + skipAmmount = headerSize - BmpInfoHeader.MaxHeaderSize; + headerSize = BmpInfoHeader.MaxHeaderSize; + } + // read the rest of the header this.currentStream.Read(data, BmpInfoHeader.HeaderSizeSize, headerSize - BmpInfoHeader.HeaderSizeSize); @@ -388,14 +395,23 @@ namespace ImageSharp.Formats case BmpInfoHeader.BitmapCoreHeaderSize: this.infoHeader = this.ParseBitmapCoreHeader(data); break; - case BmpInfoHeader.BitmapInfoHeaderSize: this.infoHeader = this.ParseBitmapInfoHeader(data); break; - default: - throw new NotSupportedException($"This kind of bitmap files (header size $headerSize) is not supported."); + if (headerSize > BmpInfoHeader.BitmapInfoHeaderSize) + { + this.infoHeader = this.ParseBitmapInfoHeader(data); + break; + } + else + { + throw new NotSupportedException($"This kind of bitmap files (header size $headerSize) is not supported."); + } } + + // skip the remaining header because we can't read those parts + this.currentStream.Skip(skipAmmount); } /// diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index da27ab081a..764d768ae0 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -117,7 +117,9 @@ namespace ImageSharp.Tests public const string F = "Bmp/F.bmp"; public const string NegHeight = "Bmp/neg_height.bmp"; public const string CoreHeader = "Bmp/BitmapCoreHeaderQR.bmp"; - public static readonly string[] All = { Car, F, NegHeight, CoreHeader }; + public const string V5Header = "Bmp/BITMAPV5HEADER.bmp"; + + public static readonly string[] All = { Car, F, NegHeight, CoreHeader, V5Header }; } public static class Gif diff --git a/tests/ImageSharp.Tests/TestImages/Formats/Bmp/BITMAPV5HEADER.bmp b/tests/ImageSharp.Tests/TestImages/Formats/Bmp/BITMAPV5HEADER.bmp new file mode 100644 index 0000000000..1ab56bb007 --- /dev/null +++ b/tests/ImageSharp.Tests/TestImages/Formats/Bmp/BITMAPV5HEADER.bmp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d99f80a05e0ddb6309c84846dfac7d2ef4e9cdda6ed437646bc0edfee7d3130 +size 174026 From b93e3c5639d6ad74596f60d9d7eb98c7a39535d2 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 1 Sep 2017 21:14:55 +0200 Subject: [PATCH 10/13] Fixed typo --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ff3c9605c6..6692c20695 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# How to contribute to ImageSHarp +# How to contribute to ImageSharp #### **Did you find a bug?** From a8aee461635ec573be6e79d4f1187292e655b0f8 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 1 Sep 2017 21:21:41 +0200 Subject: [PATCH 11/13] Changed url to repo in the links. --- .github/CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6692c20695..188c11ff31 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,9 +2,9 @@ #### **Did you find a bug?** -- Please **ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/JimBobSquarePants/ImageSharp/issues). +- Please **ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/SixLabors/ImageSharp/issues). -- If you're unable to find an open issue addressing the problem, please [open a new one](https://github.com/JimBobSquarePants/ImageSharp/issues/new). Be sure to include a **title, the applicable version, a clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. Please do not hijack existing issues. +- If you're unable to find an open issue addressing the problem, please [open a new one](https://github.com/SixLabors/ImageSharp/issues/new). Be sure to include a **title, the applicable version, a clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. Please do not hijack existing issues. #### **Did you write a patch that fixes a bug?** From 16be5eeb0e8019db242a37a12ca9faf6d6efc6ce Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 1 Sep 2017 23:18:21 +0200 Subject: [PATCH 12/13] Fixed links and added files to the solution. --- .github/ISSUE_TEMPLATE.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- ImageSharp.sln | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index e2c1276eb8..a172605e64 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,7 +3,7 @@ - [ ] I have written a descriptive issue title - [ ] I have verified that I am running the latest version of ImageSharp - [ ] I have verified if the problem exist in both `DEBUG` and `RELEASE` mode -- [ ] I have searched [open](https://github.com/JimBobSquarePants/ImageSharp/issuess) and [closed](https://github.com/JimBobSquarePants/ImageSharp/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported +- [ ] I have searched [open](https://github.com/SixLabors/ImageSharp/issues) and [closed](https://github.com/SixLabors/ImageSharp/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported ### Description diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 11444a3b23..4be3511650 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ ### Prerequisites - [ ] I have written a descriptive pull-request title -- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open +- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/SixLabors/ImageSharp/pulls) open - [ ] I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:. - [ ] I have provided test coverage for my change (where applicable) diff --git a/ImageSharp.sln b/ImageSharp.sln index a584c56868..a004f13711 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.14 +VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" ProjectSection(SolutionItems) = preProject @@ -14,7 +14,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt features.md = features.md ImageSharp.ruleset = ImageSharp.ruleset ImageSharp.sln.DotSettings = ImageSharp.sln.DotSettings + .github\ISSUE_TEMPLATE.md = .github\ISSUE_TEMPLATE.md NuGet.config = NuGet.config + .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md README.md = README.md EndProjectSection EndProject From 7d9288681299aeb175a81a5e4258c8f6231ec912 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 2 Sep 2017 10:30:33 +0100 Subject: [PATCH 13/13] expose registered ImageFormats publicly --- src/ImageSharp/Configuration.cs | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index a9322467cb..b0291dec56 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -76,6 +76,11 @@ namespace ImageSharp /// public ParallelOptions ParallelOptions { get; } = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; + /// + /// Gets the currently registered s. + /// + public IEnumerable ImageFormats => this.imageFormats; + /// /// Gets the maximum header size of all the formats. /// @@ -96,11 +101,6 @@ namespace ImageSharp /// internal IEnumerable> ImageEncoders => this.mimeTypeEncoders; - /// - /// Gets the currently registered s. - /// - internal IEnumerable ImageFormats => this.imageFormats; - #if !NETSTANDARD1_1 /// /// Gets or sets the fielsystem helper for accessing the local file system. @@ -195,29 +195,12 @@ namespace ImageSharp this.SetMaxHeaderSize(); } - /// - /// Creates the default instance with the following s preregistered: - /// - /// - /// - /// - /// - /// The default configuration of - internal static Configuration CreateDefaultInstance() - { - return new Configuration( - new PngConfigurationModule(), - new JpegConfigurationModule(), - new GifConfigurationModule(), - new BmpConfigurationModule()); - } - /// /// For the specified mime type find the decoder. /// /// The format to discover /// The if found otherwise null - internal IImageDecoder FindDecoder(IImageFormat format) + public IImageDecoder FindDecoder(IImageFormat format) { Guard.NotNull(format, nameof(format)); if (this.mimeTypeDecoders.TryGetValue(format, out IImageDecoder decoder)) @@ -233,7 +216,7 @@ namespace ImageSharp /// /// The format to discover /// The if found otherwise null - internal IImageEncoder FindEncoder(IImageFormat format) + public IImageEncoder FindEncoder(IImageFormat format) { Guard.NotNull(format, nameof(format)); if (this.mimeTypeEncoders.TryGetValue(format, out IImageEncoder encoder)) @@ -244,6 +227,23 @@ namespace ImageSharp return null; } + /// + /// Creates the default instance with the following s preregistered: + /// + /// + /// + /// + /// + /// The default configuration of + internal static Configuration CreateDefaultInstance() + { + return new Configuration( + new PngConfigurationModule(), + new JpegConfigurationModule(), + new GifConfigurationModule(), + new BmpConfigurationModule()); + } + /// /// Sets the max header size. ///