Browse Source

Merge remote-tracking branch 'origin/master' into af/simd-conversion

af/merge-core
Anton Firszov 7 years ago
parent
commit
fefd21d40e
  1. 22
      README.md
  2. 4
      src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
  3. 2
      src/ImageSharp/ColorSpaces/CieLab.cs
  4. 2
      src/ImageSharp/ColorSpaces/CieLch.cs
  5. 2
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  6. 2
      src/ImageSharp/ColorSpaces/CieLuv.cs
  7. 2
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  8. 2
      src/ImageSharp/ColorSpaces/CieXyy.cs
  9. 2
      src/ImageSharp/ColorSpaces/CieXyz.cs
  10. 2
      src/ImageSharp/ColorSpaces/Cmyk.cs
  11. 2
      src/ImageSharp/ColorSpaces/Hsl.cs
  12. 2
      src/ImageSharp/ColorSpaces/Hsv.cs
  13. 2
      src/ImageSharp/ColorSpaces/HunterLab.cs
  14. 2
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  15. 2
      src/ImageSharp/ColorSpaces/Lms.cs
  16. 2
      src/ImageSharp/ColorSpaces/Rgb.cs
  17. 2
      src/ImageSharp/ColorSpaces/YCbCr.cs
  18. 4
      src/ImageSharp/Common/Extensions/EncoderExtensions.cs
  19. 4
      src/ImageSharp/Common/Helpers/TestHelpers.cs
  20. 8
      src/ImageSharp/Configuration.cs
  21. 6
      src/ImageSharp/Formats/Gif/GifConstants.cs
  22. 8
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
  23. 2
      src/ImageSharp/Formats/Png/PngConstants.cs
  24. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  25. 2
      src/ImageSharp/IO/IFileSystem.cs
  26. 17
      src/ImageSharp/IO/LocalFileSystem.cs
  27. 3
      src/ImageSharp/Image.FromBytes.cs
  28. 4
      src/ImageSharp/Image.FromFile.cs
  29. 3
      src/ImageSharp/ImageExtensions.cs
  30. 4
      src/ImageSharp/ImageSharp.csproj
  31. 2
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
  32. 2
      src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs
  33. 4
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs
  34. 6
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.cs
  35. 9
      src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs
  36. 5
      src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs
  37. 4
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
  38. 2
      tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
  39. 2
      tests/ImageSharp.Tests/Formats/Png/PngChunkTypeTests.cs
  40. 2
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs
  41. 5
      tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs
  42. 26
      tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs

22
README.md

@ -22,7 +22,7 @@ Designed to democratize image processing, ImageSharp brings you an incredibly po
Compared to `System.Drawing` we have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks. Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments. Compared to `System.Drawing` we have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks. Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments.
Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios. Built against .NET Standard 1.3 ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
### Documentation ### Documentation
For all SixLabors projects, including ImageSharp: For all SixLabors projects, including ImageSharp:
@ -83,24 +83,6 @@ using (Image<Rgba32> image = Image.Load("foo.jpg"))
image.Save("bar.jpg"); // Automatic encoder selected based on extension. image.Save("bar.jpg"); // Automatic encoder selected based on extension.
} }
``` ```
On netstandard 1.1 - 1.2
```csharp
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
// Image.Load(Stream stream) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(Stream stream))
using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg"))
using (Image<Rgba32> image = Image.Load(stream))
{
image.Mutate(x => x
.Resize(image.Width / 2, image.Height / 2)
.Grayscale());
image.Save(output);
}
```
Setting individual pixel values can be performed as follows: Setting individual pixel values can be performed as follows:
@ -133,7 +115,7 @@ If you prefer, you can compile ImageSharp yourself (please do and help!)
Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**: Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**:
- [Visual Studio Code](https://code.visualstudio.com/) with [C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) - [Visual Studio Code](https://code.visualstudio.com/) with [C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
- [.Net Core](https://www.microsoft.com/net/core#linuxubuntu) - [.NET Core](https://www.microsoft.com/net/core#linuxubuntu)
To clone ImageSharp locally click the "Clone in Windows" button above or run the following git commands. To clone ImageSharp locally click the "Clone in Windows" button above or run the following git commands.

4
src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

@ -5,8 +5,8 @@
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> <VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> <VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<Authors>SixLabors and contributors</Authors> <Authors>SixLabors and contributors</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<LangVersion>7.2</LangVersion> <LangVersion>7.3</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName> <AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName>

2
src/ImageSharp/ColorSpaces/CieLab.cs

@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLab other && this.Equals(other); public override bool Equals(object obj) => obj is CieLab other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieLch.cs

@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieLch({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieLch({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other); public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other); public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
public override int GetHashCode() => HashHelpers.Combine(this.X.GetHashCode(), this.Y.GetHashCode()); public override int GetHashCode() => HashHelpers.Combine(this.X.GetHashCode(), this.Y.GetHashCode());
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieXyChromaticityCoordinates({this.X:#0.##}, {this.Y:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieXyChromaticityCoordinates({this.X:#0.##}, {this.Y:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyChromaticityCoordinates other && this.Equals(other); public override bool Equals(object obj) => obj is CieXyChromaticityCoordinates other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyy other && this.Equals(other); public override bool Equals(object obj) => obj is CieXyy other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})"; public override string ToString() => FormattableString.Invariant($"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other); public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})"; public override string ToString() => FormattableString.Invariant($"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other); public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Hsl.cs

@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"Hsl({this.H:#0.##}, {this.S:#0.##}, {this.L:#0.##})"; public override string ToString() => FormattableString.Invariant($"Hsl({this.H:#0.##}, {this.S:#0.##}, {this.L:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsl other && this.Equals(other); public override bool Equals(object obj) => obj is Hsl other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Hsv.cs

@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"Hsv({this.H:#0.##}, {this.S:#0.##}, {this.V:#0.##})"; public override string ToString() => FormattableString.Invariant($"Hsv({this.H:#0.##}, {this.S:#0.##}, {this.V:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsv other && this.Equals(other); public override bool Equals(object obj) => obj is Hsv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})"; public override string ToString() => FormattableString.Invariant($"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other); public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"LinearRgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})"; public override string ToString() => FormattableString.Invariant($"LinearRgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other); public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Lms.cs

@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"Lms({this.L:#0.##}, {this.M:#0.##}, {this.S:#0.##})"; public override string ToString() => FormattableString.Invariant($"Lms({this.L:#0.##}, {this.M:#0.##}, {this.S:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Lms other && this.Equals(other); public override bool Equals(object obj) => obj is Lms other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Rgb.cs

@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"Rgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})"; public override string ToString() => FormattableString.Invariant($"Rgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Rgb other && this.Equals(other); public override bool Equals(object obj) => obj is Rgb other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
} }
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() => $"YCbCr({this.Y}, {this.Cb}, {this.Cr})"; public override string ToString() => FormattableString.Invariant($"YCbCr({this.Y}, {this.Cb}, {this.Cr})");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other); public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other);

4
src/ImageSharp/Common/Extensions/EncoderExtensions.cs

@ -20,14 +20,10 @@ namespace SixLabors.ImageSharp
/// <returns>The string.</returns> /// <returns>The string.</returns>
public static string GetString(this Encoding encoding, ReadOnlySpan<byte> buffer) public static string GetString(this Encoding encoding, ReadOnlySpan<byte> buffer)
{ {
#if NETSTANDARD1_1
return encoding.GetString(buffer.ToArray());
#else
fixed (byte* bytes = buffer) fixed (byte* bytes = buffer)
{ {
return encoding.GetString(bytes, buffer.Length); return encoding.GetString(bytes, buffer.Length);
} }
#endif
} }
} }
} }

4
src/ImageSharp/Common/Helpers/TestHelpers.cs

@ -13,9 +13,7 @@ namespace SixLabors.ImageSharp.Common.Helpers
/// Only intended to be used in tests! /// Only intended to be used in tests!
/// </summary> /// </summary>
internal const string ImageSharpBuiltAgainst = internal const string ImageSharpBuiltAgainst =
#if NETSTANDARD1_1 #if NETCOREAPP2_1
"netstandard1.1";
#elif NETCOREAPP2_1
"netcoreapp2.1"; "netcoreapp2.1";
#else #else
"netstandard2.0"; "netstandard2.0";

8
src/ImageSharp/Configuration.cs

@ -3,15 +3,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;
#if !NETSTANDARD1_1
using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.IO;
#endif
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.Memory; using SixLabors.Memory;
@ -100,12 +97,10 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
internal int MaxHeaderSize => this.ImageFormatsManager.MaxHeaderSize; internal int MaxHeaderSize => this.ImageFormatsManager.MaxHeaderSize;
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Gets or sets the filesystem helper for accessing the local file system. /// Gets or sets the filesystem helper for accessing the local file system.
/// </summary> /// </summary>
internal IFileSystem FileSystem { get; set; } = new LocalFileSystem(); internal IFileSystem FileSystem { get; set; } = new LocalFileSystem();
#endif
/// <summary> /// <summary>
/// Gets or sets the image operations provider factory. /// Gets or sets the image operations provider factory.
@ -135,10 +130,7 @@ namespace SixLabors.ImageSharp
MemoryAllocator = this.MemoryAllocator, MemoryAllocator = this.MemoryAllocator,
ImageOperationsProvider = this.ImageOperationsProvider, ImageOperationsProvider = this.ImageOperationsProvider,
ReadOrigin = this.ReadOrigin, ReadOrigin = this.ReadOrigin,
#if !NETSTANDARD1_1
FileSystem = this.FileSystem FileSystem = this.FileSystem
#endif
}; };
} }

6
src/ImageSharp/Formats/Gif/GifConstants.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary> /// <summary>
/// The ASCII encoded bytes used to identify the GIF file. /// The ASCII encoded bytes used to identify the GIF file.
/// </summary> /// </summary>
internal static readonly byte[] MagicNumber = Encoding.UTF8.GetBytes(FileType + FileVersion); internal static readonly byte[] MagicNumber = Encoding.ASCII.GetBytes(FileType + FileVersion);
/// <summary> /// <summary>
/// The extension block introducer <value>!</value>. /// The extension block introducer <value>!</value>.
@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary> /// <summary>
/// The ASCII encoded application identification bytes. /// The ASCII encoded application identification bytes.
/// </summary> /// </summary>
internal static readonly byte[] NetscapeApplicationIdentificationBytes = Encoding.UTF8.GetBytes(NetscapeApplicationIdentification); internal static readonly byte[] NetscapeApplicationIdentificationBytes = Encoding.ASCII.GetBytes(NetscapeApplicationIdentification);
/// <summary> /// <summary>
/// The Netscape looping application sub block size. /// The Netscape looping application sub block size.
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary> /// <summary>
/// Gets the default encoding to use when reading comments. /// Gets the default encoding to use when reading comments.
/// </summary> /// </summary>
public static readonly Encoding DefaultEncoding = Encoding.GetEncoding("ASCII"); public static readonly Encoding DefaultEncoding = Encoding.ASCII;
/// <summary> /// <summary>
/// The list of mimetypes that equate to a gif. /// The list of mimetypes that equate to a gif.

8
src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs

@ -14,22 +14,22 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// <summary> /// <summary>
/// Describes the EXIF specific markers /// Describes the EXIF specific markers
/// </summary> /// </summary>
public static readonly byte[] JFifMarker = Encoding.UTF8.GetBytes("JFIF\0"); public static readonly byte[] JFifMarker = Encoding.ASCII.GetBytes("JFIF\0");
/// <summary> /// <summary>
/// Describes the EXIF specific markers /// Describes the EXIF specific markers
/// </summary> /// </summary>
public static readonly byte[] IccMarker = Encoding.UTF8.GetBytes("ICC_PROFILE\0"); public static readonly byte[] IccMarker = Encoding.ASCII.GetBytes("ICC_PROFILE\0");
/// <summary> /// <summary>
/// Describes the ICC specific markers /// Describes the ICC specific markers
/// </summary> /// </summary>
public static readonly byte[] ExifMarker = Encoding.UTF8.GetBytes("Exif\0\0"); public static readonly byte[] ExifMarker = Encoding.ASCII.GetBytes("Exif\0\0");
/// <summary> /// <summary>
/// Describes Adobe specific markers <see href="http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe"/> /// Describes Adobe specific markers <see href="http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe"/>
/// </summary> /// </summary>
public static readonly byte[] AdobeMarker = Encoding.UTF8.GetBytes("Adobe"); public static readonly byte[] AdobeMarker = Encoding.ASCII.GetBytes("Adobe");
/// <summary> /// <summary>
/// Returns a value indicating whether the passed bytes are a match to the profile identifier /// Returns a value indicating whether the passed bytes are a match to the profile identifier

2
src/ImageSharp/Formats/Png/PngConstants.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary> /// <summary>
/// The default encoding for text metadata. /// The default encoding for text metadata.
/// </summary> /// </summary>
public static readonly Encoding DefaultEncoding = Encoding.GetEncoding("ASCII"); public static readonly Encoding DefaultEncoding = Encoding.ASCII;
/// <summary> /// <summary>
/// The list of mimetypes that equate to a png. /// The list of mimetypes that equate to a png.

2
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -1005,7 +1005,7 @@ namespace SixLabors.ImageSharp.Formats.Png
if (this.crc.Value != chunk.Crc) if (this.crc.Value != chunk.Crc)
{ {
string chunkTypeName = Encoding.UTF8.GetString(chunkType); string chunkTypeName = Encoding.ASCII.GetString(chunkType);
throw new ImageFormatException($"CRC Error. PNG {chunkTypeName} chunk is corrupt!"); throw new ImageFormatException($"CRC Error. PNG {chunkTypeName} chunk is corrupt!");
} }

2
src/ImageSharp/IO/IFileSystem.cs

@ -5,7 +5,6 @@ using System.IO;
namespace SixLabors.ImageSharp.IO namespace SixLabors.ImageSharp.IO
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// A simple interface representing the filesystem. /// A simple interface representing the filesystem.
/// </summary> /// </summary>
@ -25,5 +24,4 @@ namespace SixLabors.ImageSharp.IO
/// <returns>A stream representing the file to open.</returns> /// <returns>A stream representing the file to open.</returns>
Stream Create(string path); Stream Create(string path);
} }
#endif
} }

17
src/ImageSharp/IO/LocalFileSystem.cs

@ -1,30 +1,19 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
namespace SixLabors.ImageSharp.IO namespace SixLabors.ImageSharp.IO
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// A wrapper around the local File apis. /// A wrapper around the local File apis.
/// </summary> /// </summary>
internal class LocalFileSystem : IFileSystem internal class LocalFileSystem : IFileSystem
{ {
/// <inheritdoc/> /// <inheritdoc/>
public Stream OpenRead(string path) public Stream OpenRead(string path) => File.OpenRead(path);
{
return File.OpenRead(path);
}
/// <inheritdoc/> /// <inheritdoc/>
public Stream Create(string path) public Stream Create(string path) => File.Create(path);
{
return File.Create(path);
}
} }
#endif }
}

3
src/ImageSharp/Image.FromBytes.cs

@ -174,8 +174,6 @@ namespace SixLabors.ImageSharp
} }
} }
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// By reading the header on the provided byte array this calculates the images format. /// By reading the header on the provided byte array this calculates the images format.
/// </summary> /// </summary>
@ -303,6 +301,5 @@ namespace SixLabors.ImageSharp
} }
} }
} }
#endif
} }
} }

4
src/ImageSharp/Image.FromFile.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
#if !NETSTANDARD1_1
using System; using System;
using System.IO; using System.IO;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
@ -212,5 +211,4 @@ namespace SixLabors.ImageSharp
} }
} }
} }
} }
#endif

3
src/ImageSharp/ImageExtensions.cs

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
@ -17,7 +16,6 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
public static partial class ImageExtensions public static partial class ImageExtensions
{ {
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Writes the image to the given stream using the currently loaded image format. /// Writes the image to the given stream using the currently loaded image format.
/// </summary> /// </summary>
@ -78,7 +76,6 @@ namespace SixLabors.ImageSharp
source.Save(fs, encoder); source.Save(fs, encoder);
} }
} }
#endif
/// <summary> /// <summary>
/// Writes the image to the given stream using the currently loaded image format. /// Writes the image to the given stream using the currently loaded image format.

4
src/ImageSharp/ImageSharp.csproj

@ -5,7 +5,7 @@
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> <VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> <VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<Authors>Six Labors and contributors</Authors> <Authors>Six Labors and contributors</Authors>
<TargetFrameworks>netstandard1.1;netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks> <TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>SixLabors.ImageSharp</AssemblyName> <AssemblyName>SixLabors.ImageSharp</AssemblyName>
@ -47,7 +47,7 @@
<PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" /> <PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' OR '$(TargetFramework)' == 'netstandard1.3'"> <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" /> <PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />

2
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs

@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
Guard.MustBeGreaterThan(length, 0, nameof(length)); Guard.MustBeGreaterThan(length, 0, nameof(length));
string value = AsciiEncoding.GetString(this.data, this.AddIndex(length), length); string value = Encoding.ASCII.GetString(this.data, this.AddIndex(length), length);
// remove data after (potential) null terminator // remove data after (potential) null terminator
int pos = value.IndexOf('\0'); int pos = value.IndexOf('\0');

2
src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs

@ -11,8 +11,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// </summary> /// </summary>
internal sealed partial class IccDataReader internal sealed partial class IccDataReader
{ {
private static readonly Encoding AsciiEncoding = Encoding.GetEncoding("ASCII");
/// <summary> /// <summary>
/// The data that is read /// The data that is read
/// </summary> /// </summary>

4
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs

@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return 0; return 0;
} }
byte[] data = AsciiEncoding.GetBytes(value); byte[] data = Encoding.ASCII.GetBytes(value);
this.dataStream.Write(data, 0, data.Length); this.dataStream.Write(data, 0, data.Length);
return data.Length; return data.Length;
} }
@ -215,7 +215,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
value = value.Substring(0, Math.Min(length - lengthAdjust, value.Length)); value = value.Substring(0, Math.Min(length - lengthAdjust, value.Length));
byte[] textData = AsciiEncoding.GetBytes(value); byte[] textData = Encoding.ASCII.GetBytes(value);
int actualLength = Math.Min(length - lengthAdjust, textData.Length); int actualLength = Math.Min(length - lengthAdjust, textData.Length);
this.dataStream.Write(textData, 0, actualLength); this.dataStream.Write(textData, 0, actualLength);
for (int i = 0; i < length - actualLength; i++) for (int i = 0; i < length - actualLength; i++)

6
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.cs

@ -3,7 +3,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Text;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
@ -12,9 +11,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// </summary> /// </summary>
internal sealed partial class IccDataWriter : IDisposable internal sealed partial class IccDataWriter : IDisposable
{ {
private static readonly bool IsLittleEndian = BitConverter.IsLittleEndian;
private static readonly Encoding AsciiEncoding = Encoding.GetEncoding("ASCII");
/// <summary> /// <summary>
/// The underlying stream where the data is written to /// The underlying stream where the data is written to
/// </summary> /// </summary>
@ -181,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <returns>The number of bytes written</returns> /// <returns>The number of bytes written</returns>
private unsafe int WriteBytes(byte* data, int length) private unsafe int WriteBytes(byte* data, int length)
{ {
if (IsLittleEndian) if (BitConverter.IsLittleEndian)
{ {
for (int i = length - 1; i >= 0; i--) for (int i = length - 1; i >= 0; i--)
{ {

9
src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs

@ -3,10 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if !NETSTANDARD1_1
using System.Security.Cryptography; using System.Security.Cryptography;
#endif
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{ {
@ -100,8 +97,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/> /// <inheritdoc/>
public IccProfile DeepClone() => new IccProfile(this); public IccProfile DeepClone() => new IccProfile(this);
#if !NETSTANDARD1_1
/// <summary> /// <summary>
/// Calculates the MD5 hash value of an ICC profile /// Calculates the MD5 hash value of an ICC profile
/// </summary> /// </summary>
@ -147,8 +142,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
} }
} }
#endif
/// <summary> /// <summary>
/// Checks for signs of a corrupt profile. /// Checks for signs of a corrupt profile.
/// </summary> /// </summary>
@ -227,4 +220,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
this.entries = new List<IccTagDataEntry>(reader.ReadTagData(this.data)); this.entries = new List<IccTagDataEntry>(reader.ReadTagData(this.data));
} }
} }
} }

5
src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -51,12 +50,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
writer.WriteXyzNumber(header.PcsIlluminant); writer.WriteXyzNumber(header.PcsIlluminant);
writer.WriteAsciiString(header.CreatorSignature, 4, false); writer.WriteAsciiString(header.CreatorSignature, 4, false);
#if !NETSTANDARD1_1
IccProfileId id = IccProfile.CalculateHash(writer.GetData()); IccProfileId id = IccProfile.CalculateHash(writer.GetData());
writer.WriteProfileId(id); writer.WriteProfileId(id);
#else
writer.WriteProfileId(IccProfileId.Zero);
#endif
} }
private void WriteTagTable(IccDataWriter writer, IccTagTableEntry[] table) private void WriteTagTable(IccDataWriter writer, IccTagTableEntry[] table)

4
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs

@ -12,8 +12,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// </summary> /// </summary>
internal sealed class IccDataTagDataEntry : IccTagDataEntry, IEquatable<IccDataTagDataEntry> internal sealed class IccDataTagDataEntry : IccTagDataEntry, IEquatable<IccDataTagDataEntry>
{ {
private static readonly Encoding AsciiEncoding = Encoding.GetEncoding("ASCII");
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="IccDataTagDataEntry"/> class. /// Initializes a new instance of the <see cref="IccDataTagDataEntry"/> class.
/// </summary> /// </summary>
@ -60,7 +58,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// Gets the <see cref="Data"/> decoded as 7bit ASCII. /// Gets the <see cref="Data"/> decoded as 7bit ASCII.
/// If <see cref="IsAscii"/> is false, returns null /// If <see cref="IsAscii"/> is false, returns null
/// </summary> /// </summary>
public string AsciiString => this.IsAscii ? AsciiEncoding.GetString(this.Data, 0, this.Data.Length) : null; public string AsciiString => this.IsAscii ? Encoding.ASCII.GetString(this.Data, 0, this.Data.Length) : null;
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(IccTagDataEntry other) public override bool Equals(IccTagDataEntry other)

2
tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj

@ -5,7 +5,7 @@
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<RootNamespace>SixLabors.ImageSharp.Benchmarks</RootNamespace> <RootNamespace>SixLabors.ImageSharp.Benchmarks</RootNamespace>
<AssemblyName>ImageSharp.Benchmarks</AssemblyName> <AssemblyName>ImageSharp.Benchmarks</AssemblyName>
<LangVersion>7.2</LangVersion> <LangVersion>7.3</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net461'"> <PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier> <RuntimeIdentifier>win7-x64</RuntimeIdentifier>

2
tests/ImageSharp.Tests/Formats/Png/PngChunkTypeTests.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
private static PngChunkType GetType(string text) private static PngChunkType GetType(string text)
{ {
return (PngChunkType)BinaryPrimitives.ReadInt32BigEndian(Encoding.UTF8.GetBytes(text)); return (PngChunkType)BinaryPrimitives.ReadInt32BigEndian(Encoding.ASCII.GetBytes(text));
} }
} }
} }

2
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs

@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
{ {
// Needs a minimum length of 9 for pHYs chunk. // Needs a minimum length of 9 for pHYs chunk.
memStream.Write(new byte[] { 0, 0, 0, 9 }, 0, 4); memStream.Write(new byte[] { 0, 0, 0, 9 }, 0, 4);
memStream.Write(Encoding.GetEncoding("ASCII").GetBytes(chunkName), 0, 4); // 4 bytes chunk header memStream.Write(Encoding.ASCII.GetBytes(chunkName), 0, 4); // 4 bytes chunk header
memStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 9); // 9 bytes of chunk data memStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 9); // 9 bytes of chunk data
memStream.Write(new byte[] { 0, 0, 0, 0 }, 0, 4); // Junk Crc memStream.Write(new byte[] { 0, 0, 0, 0 }, 0, 4); // Junk Crc
} }

5
tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs

@ -9,9 +9,6 @@ namespace SixLabors.ImageSharp.Tests.Icc
{ {
public class IccProfileTests public class IccProfileTests
{ {
#if !NETSTANDARD1_1
[Theory] [Theory]
[MemberData(nameof(IccTestDataProfiles.ProfileIdTestData), MemberType = typeof(IccTestDataProfiles))] [MemberData(nameof(IccTestDataProfiles.ProfileIdTestData), MemberType = typeof(IccTestDataProfiles))]
public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccProfileId expected) public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccProfileId expected)
@ -33,8 +30,6 @@ namespace SixLabors.ImageSharp.Tests.Icc
Assert.Equal(data, copy); Assert.Equal(data, copy);
} }
#endif
[Theory] [Theory]
[MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))]
public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected)

26
tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs

@ -14,20 +14,12 @@ namespace SixLabors.ImageSharp.Tests
public static readonly byte[] Header_Random_Id_Array = public static readonly byte[] Header_Random_Id_Array =
{ {
#if !NETSTANDARD1_1 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38,
0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38,
#else
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#endif
}; };
public static readonly byte[] Profile_Random_Id_Array = public static readonly byte[] Profile_Random_Id_Array =
{ {
#if !NETSTANDARD1_1 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F,
0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F,
#else
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#endif
}; };
public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue( public static readonly IccProfileHeader Header_Random_Write = CreateHeaderRandomValue(
@ -35,13 +27,7 @@ namespace SixLabors.ImageSharp.Tests
new IccProfileId(1, 2, 3, 4), // should be overwritten new IccProfileId(1, 2, 3, 4), // should be overwritten
"ijkl"); // should be overwritten to "acsp" "ijkl"); // should be overwritten to "acsp"
public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, public static readonly IccProfileHeader Header_Random_Read = CreateHeaderRandomValue(132, Header_Random_Id_Value, "acsp");
#if !NETSTANDARD1_1
Header_Random_Id_Value,
#else
IccProfileId.Zero,
#endif
"acsp");
public static readonly byte[] Header_Random_Array = CreateHeaderRandomArray(132, 0, Header_Random_Id_Array); public static readonly byte[] Header_Random_Array = CreateHeaderRandomArray(132, 0, Header_Random_Id_Array);
@ -120,11 +106,7 @@ namespace SixLabors.ImageSharp.Tests
); );
public static readonly IccProfile Profile_Random_Val = new IccProfile(CreateHeaderRandomValue(168, public static readonly IccProfile Profile_Random_Val = new IccProfile(CreateHeaderRandomValue(168,
#if !NETSTANDARD1_1
Profile_Random_Id_Value, Profile_Random_Id_Value,
#else
IccProfileId.Zero,
#endif
"acsp"), "acsp"),
new IccTagDataEntry[] new IccTagDataEntry[]
{ {
@ -239,4 +221,4 @@ namespace SixLabors.ImageSharp.Tests
new object[] { Header_Random_Array, true }, new object[] { Header_Random_Array, true },
}; };
} }
} }
Loading…
Cancel
Save