diff --git a/ImageSharp.sln b/ImageSharp.sln index f6f2025313..9f22d8d866 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -39,6 +39,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E919DF0B EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "build", "build\build.xproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats", "src\ImageSharp.Formats\ImageSharp.Formats.xproj", "{C72B8906-260A-4688-9B7A-5CD4BDF419EC}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Bmp", "src\ImageSharp.Formats.Bmp\ImageSharp.Formats.Bmp.xproj", "{C77661B9-F793-422E-8E27-AC60ECC5F215}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Gif", "src\ImageSharp.Formats.Gif\ImageSharp.Formats.Gif.xproj", "{27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Jpeg", "src\ImageSharp.Formats.Jpeg\ImageSharp.Formats.Jpeg.xproj", "{7213767C-0003-41CA-AB18-0223CFA7CE4B}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Png", "src\ImageSharp.Formats.Png\ImageSharp.Formats.Png.xproj", "{556ABDCF-ED93-4327-BE98-F6815F78B9B8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -65,6 +75,26 @@ Global {575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|Any CPU.Build.0 = Debug|Any CPU {575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|Any CPU.ActiveCfg = Release|Any CPU {575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|Any CPU.Build.0 = Release|Any CPU + {C72B8906-260A-4688-9B7A-5CD4BDF419EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C72B8906-260A-4688-9B7A-5CD4BDF419EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C72B8906-260A-4688-9B7A-5CD4BDF419EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C72B8906-260A-4688-9B7A-5CD4BDF419EC}.Release|Any CPU.Build.0 = Release|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.Build.0 = Release|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.Build.0 = Release|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.Build.0 = Release|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -75,5 +105,10 @@ Global {299D8E18-102C-42DE-ADBF-79098EE706A8} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {2E33181E-6E28-4662-A801-E2E7DC206029} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {575A5002-DD9F-4335-AA47-1DD87FA13645} = {E919DF0B-2607-4462-8FC0-5C98FE50F8C9} + {C72B8906-260A-4688-9B7A-5CD4BDF419EC} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} + {C77661B9-F793-422E-8E27-AC60ECC5F215} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} + {7213767C-0003-41CA-AB18-0223CFA7CE4B} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} + {556ABDCF-ED93-4327-BE98-F6815F78B9B8} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} EndGlobalSection EndGlobal diff --git a/build/Program.cs b/build/Program.cs index 75fc8974ee..13056a6eb3 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -245,24 +245,47 @@ namespace ConsoleApplication internal string CalculateVersionNumber(string branch) { - var version = this.Version.ToFullString(); + var version = this.Version.ToFullString(); + + if (this.commitCount == 1 && branch == "") //master only { if (this.Version.IsPrerelease) { //prerelease always needs the build counter just not on a branch name - return $"{version}-{this.commitCount:000000}"; + return $"{version}-{this.commitCount:00000}"; } + //only 1 commit (the changing one) we will skip appending suffix return version; } + var rootSpecialVersion = ""; + + if (this.Version.IsPrerelease) + { + var parts = version.Split(new[] { '-' }, 2); + version = parts[0]; + rootSpecialVersion = parts[1]; + } + if(rootSpecialVersion.Length > 0) + { + rootSpecialVersion = "-" + rootSpecialVersion; + } if (branch == "") { branch = fallbackTag; } - return $"{version}-{branch}-{this.commitCount:000000}"; + var maxLength = 20; + maxLength -= rootSpecialVersion.Length; + maxLength -= 7; // for the counter and dashes + if(branch.Length > maxLength) + { + branch = branch.Substring(0, maxLength); + } + + return $"{version}{rootSpecialVersion}-{branch}-{this.commitCount:00000}"; } } } diff --git a/src/ImageSharp.Drawing/project.json b/src/ImageSharp.Drawing/project.json index 0e0f7a1667..147044fb93 100644 --- a/src/ImageSharp.Drawing/project.json +++ b/src/ImageSharp.Drawing/project.json @@ -71,8 +71,5 @@ "System.Runtime": "4.0.0" } } - }, - "tools": { - "dotnet-version": "1.1.0" } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs b/src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs rename to src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpCompression.cs b/src/ImageSharp.Formats.Bmp/BmpCompression.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpCompression.cs rename to src/ImageSharp.Formats.Bmp/BmpCompression.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp.Formats.Bmp/BmpDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpDecoder.cs rename to src/ImageSharp.Formats.Bmp/BmpDecoder.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs rename to src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp.Formats.Bmp/BmpEncoder.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpEncoder.cs rename to src/ImageSharp.Formats.Bmp/BmpEncoder.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs similarity index 99% rename from src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs rename to src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs index 20c899a18d..94f2b3a38b 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs @@ -46,7 +46,7 @@ namespace ImageSharp.Formats this.padding = bytesPerLine - (image.Width * (int)bitsPerPixel); // Do not use IDisposable pattern here as we want to preserve the stream. - EndianBinaryWriter writer = new EndianBinaryWriter(EndianBitConverter.Little, stream); + EndianBinaryWriter writer = new EndianBinaryWriter(Endianness.LittleEndian, stream); BmpInfoHeader infoHeader = new BmpInfoHeader { diff --git a/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs b/src/ImageSharp.Formats.Bmp/BmpFileHeader.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpFileHeader.cs rename to src/ImageSharp.Formats.Bmp/BmpFileHeader.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpFormat.cs b/src/ImageSharp.Formats.Bmp/BmpFormat.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpFormat.cs rename to src/ImageSharp.Formats.Bmp/BmpFormat.cs diff --git a/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs b/src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs rename to src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs diff --git a/src/ImageSharp.Formats.Bmp/BootstrapperExtensions.cs b/src/ImageSharp.Formats.Bmp/BootstrapperExtensions.cs new file mode 100644 index 0000000000..3ed80a5bd9 --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/BootstrapperExtensions.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class BootstrapperExtensions + { + /// + /// Adds the BMP format. + /// + /// The bootstrapper. + /// The bootstraper + public static Bootstrapper AddBmpFormat(this Bootstrapper bootstrapper) + { + bootstrapper.AddImageFormat(new BmpFormat()); + return bootstrapper; + } + } +} diff --git a/src/ImageSharp.Formats.Bmp/ImageExtensions.cs b/src/ImageSharp.Formats.Bmp/ImageExtensions.cs new file mode 100644 index 0000000000..8bbae8487b --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/ImageExtensions.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// Saves the image to the given stream with the bmp format. + /// + /// The pixel format. + /// The image this method extends. + /// The stream to save the image to. + /// Thrown if the stream is null. + /// + /// The . + /// + public static Image SaveAsBmp(this Image source, Stream stream) + where TColor : struct, IPackedPixel, IEquatable + => source.Save(stream, new BmpEncoder()); + } +} diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj new file mode 100644 index 0000000000..94916399bd --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c77661b9-f793-422e-8e27-ac60ecc5f215 + ImageSharp.Formats.Bmp + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4e0043fdd --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageSharp.Formats.Jpeg")] +[assembly: AssemblyDescription("A cross-platform library for processing of image files; written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James Jackson-South")] +[assembly: AssemblyProduct("ImageSharp")] +[assembly: AssemblyCopyright("Copyright (c) James Jackson-South and contributors.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + +// Ensure the internals can be tested. +[assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] +[assembly: InternalsVisibleTo("ImageSharp.Tests")] +[assembly: InternalsVisibleTo("ImageSharp.Tests46")] \ No newline at end of file diff --git a/src/ImageSharp/Formats/Bmp/README.md b/src/ImageSharp.Formats.Bmp/README.md similarity index 100% rename from src/ImageSharp/Formats/Bmp/README.md rename to src/ImageSharp.Formats.Bmp/README.md diff --git a/src/ImageSharp.Formats.Bmp/project.json b/src/ImageSharp.Formats.Bmp/project.json new file mode 100644 index 0000000000..8211a87aa8 --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/project.json @@ -0,0 +1,73 @@ +{ + "version": "1.0.0-*", + "title": "ImageSharp.Formats.Bmp", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:stylecop.json", "/ruleset:../../ImageSharp.ruleset" ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": "1.0.0-*", + "StyleCop.Analyzers": { + "version": "1.1.0-beta001", + "type": "build" + }, + "System.Buffers": "4.0.0", + "System.Numerics.Vectors": "4.1.1", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + } + }, + "net45": { + "dependencies": { + "System.Runtime": "4.0.0" + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/BootstrapperExtensions.cs b/src/ImageSharp.Formats.Gif/BootstrapperExtensions.cs new file mode 100644 index 0000000000..33faf854cf --- /dev/null +++ b/src/ImageSharp.Formats.Gif/BootstrapperExtensions.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class BootstrapperExtensions + { + /// + /// Adds the Gif format. + /// + /// The bootstrapper. + /// The Bootstrapper + public static Bootstrapper AddGifFormat(this Bootstrapper bootstrapper) + { + bootstrapper.AddImageFormat(new GifFormat()); + return bootstrapper; + } + } +} diff --git a/src/ImageSharp/Formats/Gif/DisposalMethod.cs b/src/ImageSharp.Formats.Gif/DisposalMethod.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/DisposalMethod.cs rename to src/ImageSharp.Formats.Gif/DisposalMethod.cs diff --git a/src/ImageSharp/Formats/Gif/GifConstants.cs b/src/ImageSharp.Formats.Gif/GifConstants.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifConstants.cs rename to src/ImageSharp.Formats.Gif/GifConstants.cs diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp.Formats.Gif/GifDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifDecoder.cs rename to src/ImageSharp.Formats.Gif/GifDecoder.cs diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp.Formats.Gif/GifDecoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifDecoderCore.cs rename to src/ImageSharp.Formats.Gif/GifDecoderCore.cs diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp.Formats.Gif/GifEncoder.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifEncoder.cs rename to src/ImageSharp.Formats.Gif/GifEncoder.cs diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp.Formats.Gif/GifEncoderCore.cs similarity index 99% rename from src/ImageSharp/Formats/Gif/GifEncoderCore.cs rename to src/ImageSharp.Formats.Gif/GifEncoderCore.cs index 8a851fd682..e5b8ba08ae 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp.Formats.Gif/GifEncoderCore.cs @@ -62,7 +62,7 @@ namespace ImageSharp.Formats } // Do not use IDisposable pattern here as we want to preserve the stream. - EndianBinaryWriter writer = new EndianBinaryWriter(EndianBitConverter.Little, stream); + EndianBinaryWriter writer = new EndianBinaryWriter(Endianness.LittleEndian, stream); // Ensure that quality can be set but has a fallback. int quality = this.Quality > 0 ? this.Quality : image.Quality; diff --git a/src/ImageSharp/Formats/Gif/GifFormat.cs b/src/ImageSharp.Formats.Gif/GifFormat.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifFormat.cs rename to src/ImageSharp.Formats.Gif/GifFormat.cs diff --git a/src/ImageSharp.Formats.Gif/Helpers/ComparableExtensions.cs b/src/ImageSharp.Formats.Gif/Helpers/ComparableExtensions.cs new file mode 100644 index 0000000000..794c7d7986 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/Helpers/ComparableExtensions.cs @@ -0,0 +1,39 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + + /// + /// Extension methods for classes that implement . + /// + internal static class ComparableExtensions + { + /// + /// Restricts a to be within a specified range. + /// + /// The The value to clamp. + /// The minimum value. If value is less than min, min will be returned. + /// The maximum value. If value is greater than max, max will be returned. + /// + /// The representing the clamped value. + /// + public static int Clamp(this int value, int min, int max) + { + if (value > max) + { + return max; + } + + if (value < min) + { + return min; + } + + return value; + } + } +} diff --git a/src/ImageSharp.Formats.Gif/Helpers/ImageMaths.cs b/src/ImageSharp.Formats.Gif/Helpers/ImageMaths.cs new file mode 100644 index 0000000000..8f377d3af0 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/Helpers/ImageMaths.cs @@ -0,0 +1,30 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.Linq; + using System.Numerics; + + /// + /// Provides common mathematical methods. + /// + internal static class ImageMaths + { + /// + /// Returns how many bits are required to store the specified number of colors. + /// Performs a Log2() on the value. + /// + /// The number of colors. + /// + /// The + /// + public static int GetBitsNeededForColorDepth(int colors) + { + return (int)Math.Ceiling(Math.Log(colors, 2)); + } + } +} diff --git a/src/ImageSharp.Formats.Gif/Helpers/StreamExtensions.cs b/src/ImageSharp.Formats.Gif/Helpers/StreamExtensions.cs new file mode 100644 index 0000000000..6de94dd229 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/Helpers/StreamExtensions.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System.Buffers; + using System.IO; + + /// + /// Extension methods for the type. + /// + internal static class StreamExtensions + { + /// + /// Skips the number of bytes in the given stream. + /// + /// The stream. + /// The count. + public static void Skip(this Stream stream, int count) + { + if (count < 1) + { + return; + } + + if (stream.CanSeek) + { + stream.Position += count; + } + else + { + byte[] foo = ArrayPool.Shared.Rent(count); + try + { + stream.Read(foo, 0, count); + } + finally + { + ArrayPool.Shared.Return(foo); + } + } + } + } +} diff --git a/src/ImageSharp.Formats.Gif/ImageExtensions.cs b/src/ImageSharp.Formats.Gif/ImageExtensions.cs new file mode 100644 index 0000000000..287305a664 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/ImageExtensions.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// Saves the image to the given stream with the gif format. + /// + /// The pixel format. + /// The image this method extends. + /// The stream to save the image to. + /// The quality to save the image to representing the number of colors. Between 1 and 256. + /// Thrown if the stream is null. + /// + /// The . + /// + public static Image SaveAsGif(this Image source, Stream stream, int quality = 256) + where TColor : struct, IPackedPixel, IEquatable + => source.Save(stream, new GifEncoder { Quality = quality }); + + /// + /// To the frame. + /// + /// The type of the color. + /// The source. + /// The frame + internal static ImageFrame ToFrame(this ImageBase source) + where TColor : struct, IPackedPixel, IEquatable + => new ImageFrame(source); + + /// + /// Clones the specified source. + /// + /// The type of the color. + /// The source. + /// The frame + internal static ImageFrame Clone(this ImageFrame source) + where TColor : struct, IPackedPixel, IEquatable + => new ImageFrame(source); + } +} diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj new file mode 100644 index 0000000000..d11c20c482 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f + ImageSharp.Formats.Gif + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp.Formats.Gif/LzwDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/LzwDecoder.cs rename to src/ImageSharp.Formats.Gif/LzwDecoder.cs diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp.Formats.Gif/LzwEncoder.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/LzwEncoder.cs rename to src/ImageSharp.Formats.Gif/LzwEncoder.cs diff --git a/src/ImageSharp/Formats/Gif/PackedField.cs b/src/ImageSharp.Formats.Gif/PackedField.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/PackedField.cs rename to src/ImageSharp.Formats.Gif/PackedField.cs diff --git a/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4e0043fdd --- /dev/null +++ b/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageSharp.Formats.Jpeg")] +[assembly: AssemblyDescription("A cross-platform library for processing of image files; written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James Jackson-South")] +[assembly: AssemblyProduct("ImageSharp")] +[assembly: AssemblyCopyright("Copyright (c) James Jackson-South and contributors.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + +// Ensure the internals can be tested. +[assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] +[assembly: InternalsVisibleTo("ImageSharp.Tests")] +[assembly: InternalsVisibleTo("ImageSharp.Tests46")] \ No newline at end of file diff --git a/src/ImageSharp/Formats/Gif/README.md b/src/ImageSharp.Formats.Gif/README.md similarity index 100% rename from src/ImageSharp/Formats/Gif/README.md rename to src/ImageSharp.Formats.Gif/README.md diff --git a/src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs b/src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs rename to src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs diff --git a/src/ImageSharp/Formats/Gif/Sections/GifImageDescriptor.cs b/src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/Sections/GifImageDescriptor.cs rename to src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs diff --git a/src/ImageSharp/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs b/src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs rename to src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs diff --git a/src/ImageSharp.Formats.Gif/project.json b/src/ImageSharp.Formats.Gif/project.json new file mode 100644 index 0000000000..af54c6e748 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/project.json @@ -0,0 +1,73 @@ +{ + "version": "1.0.0-*", + "title": "ImageSharp.Formats.Gif", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:stylecop.json", "/ruleset:../../ImageSharp.ruleset" ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": "1.0.0-*", + "StyleCop.Analyzers": { + "version": "1.1.0-beta001", + "type": "build" + }, + "System.Buffers": "4.0.0", + "System.Numerics.Vectors": "4.1.1", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + } + }, + "net45": { + "dependencies": { + "System.Runtime": "4.0.0" + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/BootstrapperExtensions.cs b/src/ImageSharp.Formats.Jpeg/BootstrapperExtensions.cs new file mode 100644 index 0000000000..b05a71e8b5 --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/BootstrapperExtensions.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class BootstrapperExtensions + { + /// + /// Adds the Jpeg format. + /// + /// The bootstrapper. + /// The Bootstrapper + public static Bootstrapper AddJpegFormat(this Bootstrapper bootstrapper) + { + bootstrapper.AddImageFormat(new JpegFormat()); + return bootstrapper; + } + } +} diff --git a/src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.cs b/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.cs rename to src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.tt b/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.tt rename to src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt diff --git a/src/ImageSharp/Formats/Jpg/Components/Block8x8F.cs b/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Block8x8F.cs rename to src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/BlockQuad.cs b/src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/BlockQuad.cs rename to src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/DCT.cs b/src/ImageSharp.Formats.Jpeg/Components/DCT.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/DCT.cs rename to src/ImageSharp.Formats.Jpeg/Components/DCT.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/Bytes.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/Bytes.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/Component.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/Component.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/HuffmanTree.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/HuffmanTree.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/JpegPixelArea.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/JpegPixelArea.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.md b/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.md rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/Scan.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/Scan.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/Scan.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/Scan.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Decoder/YCbCrImage.cs b/src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Decoder/YCbCrImage.cs rename to src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Encoder/HuffIndex.cs b/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Encoder/HuffIndex.cs rename to src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanLut.cs b/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanLut.cs rename to src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanSpec.cs b/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanSpec.cs rename to src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs diff --git a/src/ImageSharp/Formats/Jpg/Components/Encoder/QuantIndex.cs b/src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Components/Encoder/QuantIndex.cs rename to src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs diff --git a/src/ImageSharp.Formats.Jpeg/Helpers/ComparableExtensions.cs b/src/ImageSharp.Formats.Jpeg/Helpers/ComparableExtensions.cs new file mode 100644 index 0000000000..c6c937629a --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/Helpers/ComparableExtensions.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + + /// + /// Extension methods for classes that implement . + /// + internal static class ComparableExtensions + { + /// + /// Restricts a to be within a specified range. + /// + /// The The value to clamp. + /// The minimum value. If value is less than min, min will be returned. + /// The maximum value. If value is greater than max, max will be returned. + /// + /// The representing the clamped value. + /// + public static int Clamp(this int value, int min, int max) + { + if (value > max) + { + return max; + } + + if (value < min) + { + return min; + } + + return value; + } + + /// + /// Restricts a to be within a specified range. + /// + /// The The value to clamp. + /// The minimum value. If value is less than min, min will be returned. + /// The maximum value. If value is greater than max, max will be returned. + /// + /// The representing the clamped value. + /// + public static float Clamp(this float value, float min, float max) + { + if (value > max) + { + return max; + } + + if (value < min) + { + return min; + } + + return value; + } + } +} diff --git a/src/ImageSharp.Formats.Jpeg/ImageExtensions.cs b/src/ImageSharp.Formats.Jpeg/ImageExtensions.cs new file mode 100644 index 0000000000..c0cda4d46a --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/ImageExtensions.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// Saves the image to the given stream with the jpeg format. + /// + /// The pixel format. + /// The image this method extends. + /// The stream to save the image to. + /// The quality to save the image to. Between 1 and 100. + /// Thrown if the stream is null. + /// + /// The . + /// + public static Image SaveAsJpeg(this Image source, Stream stream, int quality = 75) + where TColor : struct, IPackedPixel, IEquatable + => source.Save(stream, new JpegEncoder { Quality = quality }); + } +} diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj new file mode 100644 index 0000000000..a22dc5ea34 --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 7213767c-0003-41ca-ab18-0223cfa7ce4b + ImageSharp.Formats + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpg/JpegConstants.cs b/src/ImageSharp.Formats.Jpeg/JpegConstants.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegConstants.cs rename to src/ImageSharp.Formats.Jpeg/JpegConstants.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegDecoder.cs b/src/ImageSharp.Formats.Jpeg/JpegDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegDecoder.cs rename to src/ImageSharp.Formats.Jpeg/JpegDecoder.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs rename to src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoder.cs b/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegEncoder.cs rename to src/ImageSharp.Formats.Jpeg/JpegEncoder.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs rename to src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegFormat.cs b/src/ImageSharp.Formats.Jpeg/JpegFormat.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegFormat.cs rename to src/ImageSharp.Formats.Jpeg/JpegFormat.cs diff --git a/src/ImageSharp/Formats/Jpg/JpegSubsample.cs b/src/ImageSharp.Formats.Jpeg/JpegSubsample.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/JpegSubsample.cs rename to src/ImageSharp.Formats.Jpeg/JpegSubsample.cs diff --git a/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4e0043fdd --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageSharp.Formats.Jpeg")] +[assembly: AssemblyDescription("A cross-platform library for processing of image files; written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James Jackson-South")] +[assembly: AssemblyProduct("ImageSharp")] +[assembly: AssemblyCopyright("Copyright (c) James Jackson-South and contributors.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + +// Ensure the internals can be tested. +[assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] +[assembly: InternalsVisibleTo("ImageSharp.Tests")] +[assembly: InternalsVisibleTo("ImageSharp.Tests46")] \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpg/README.md b/src/ImageSharp.Formats.Jpeg/README.md similarity index 100% rename from src/ImageSharp/Formats/Jpg/README.md rename to src/ImageSharp.Formats.Jpeg/README.md diff --git a/src/ImageSharp/Formats/Jpg/UnzigData.cs b/src/ImageSharp.Formats.Jpeg/UnzigData.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/UnzigData.cs rename to src/ImageSharp.Formats.Jpeg/UnzigData.cs diff --git a/src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs b/src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs rename to src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs diff --git a/src/ImageSharp/Formats/Jpg/Utils/MutableSpan.cs b/src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Utils/MutableSpan.cs rename to src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs diff --git a/src/ImageSharp/Formats/Jpg/Utils/MutableSpanExtensions.cs b/src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs similarity index 100% rename from src/ImageSharp/Formats/Jpg/Utils/MutableSpanExtensions.cs rename to src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs diff --git a/src/ImageSharp.Formats.Jpeg/project.json b/src/ImageSharp.Formats.Jpeg/project.json new file mode 100644 index 0000000000..685d009c3e --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/project.json @@ -0,0 +1,73 @@ +{ + "version": "1.0.0-*", + "title": "ImageSharp.Formats.Jpeg", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:stylecop.json", "/ruleset:../../ImageSharp.ruleset" ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": "1.0.0-*", + "StyleCop.Analyzers": { + "version": "1.1.0-beta001", + "type": "build" + }, + "System.Buffers": "4.0.0", + "System.Numerics.Vectors": "4.1.1", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + } + }, + "net45": { + "dependencies": { + "System.Runtime": "4.0.0" + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/BootstrapperExtensions.cs b/src/ImageSharp.Formats.Png/BootstrapperExtensions.cs new file mode 100644 index 0000000000..eeef291a15 --- /dev/null +++ b/src/ImageSharp.Formats.Png/BootstrapperExtensions.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class BootstrapperExtensions + { + /// + /// Adds the Png format. + /// + /// The bootstrapper. + /// The Bootstrapper + public static Bootstrapper AddPngFormat(this Bootstrapper bootstrapper) + { + bootstrapper.AddImageFormat(new PngFormat()); + return bootstrapper; + } + } +} diff --git a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs b/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/AverageFilter.cs rename to src/ImageSharp.Formats.Png/Filters/AverageFilter.cs diff --git a/src/ImageSharp/Formats/Png/Filters/FilterType.cs b/src/ImageSharp.Formats.Png/Filters/FilterType.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/FilterType.cs rename to src/ImageSharp.Formats.Png/Filters/FilterType.cs diff --git a/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs b/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/NoneFilter.cs rename to src/ImageSharp.Formats.Png/Filters/NoneFilter.cs diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/PaethFilter.cs rename to src/ImageSharp.Formats.Png/Filters/PaethFilter.cs diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp.Formats.Png/Filters/SubFilter.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/SubFilter.cs rename to src/ImageSharp.Formats.Png/Filters/SubFilter.cs diff --git a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs b/src/ImageSharp.Formats.Png/Filters/UpFilter.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Filters/UpFilter.cs rename to src/ImageSharp.Formats.Png/Filters/UpFilter.cs diff --git a/src/ImageSharp.Formats.Png/Helpers/ByteExtensions.cs b/src/ImageSharp.Formats.Png/Helpers/ByteExtensions.cs new file mode 100644 index 0000000000..fc9c29e625 --- /dev/null +++ b/src/ImageSharp.Formats.Png/Helpers/ByteExtensions.cs @@ -0,0 +1,45 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + /// + /// Extension methods for the struct. + /// + internal static class ByteExtensions + { + /// + /// Optimized reversal algorithm. + /// + /// The byte array. + public static void ReverseBytes(this byte[] source) + { + ReverseBytes(source, 0, source.Length); + } + + /// + /// Optimized reversal algorithm. + /// + /// The byte array. + /// The index. + /// The length. + /// is null. + public static void ReverseBytes(this byte[] source, int index, int length) + { + Guard.NotNull(source, nameof(source)); + + int i = index; + int j = index + length - 1; + while (i < j) + { + byte temp = source[i]; + source[i] = source[j]; + source[j] = temp; + i++; + j--; + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/Helpers/ComparableExtensions.cs b/src/ImageSharp.Formats.Png/Helpers/ComparableExtensions.cs new file mode 100644 index 0000000000..826f397ce3 --- /dev/null +++ b/src/ImageSharp.Formats.Png/Helpers/ComparableExtensions.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + + /// + /// Extension methods for classes that implement . + /// + internal static class ComparableExtensions + { + /// + /// Restricts a to be within a specified range. + /// + /// The The value to clamp. + /// The minimum value. If value is less than min, min will be returned. + /// The maximum value. If value is greater than max, max will be returned. + /// + /// The representing the clamped value. + /// + public static int Clamp(this int value, int min, int max) + { + if (value > max) + { + return max; + } + + if (value < min) + { + return min; + } + + return value; + } + + /// + /// Swaps the references to two objects in memory. + /// + /// The first reference. + /// The second reference. + /// The type of object. + public static void Swap(ref T first, ref T second) + { + T temp = second; + second = first; + first = temp; + } + } +} diff --git a/src/ImageSharp.Formats.Png/Helpers/ImageMaths.cs b/src/ImageSharp.Formats.Png/Helpers/ImageMaths.cs new file mode 100644 index 0000000000..8f377d3af0 --- /dev/null +++ b/src/ImageSharp.Formats.Png/Helpers/ImageMaths.cs @@ -0,0 +1,30 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.Linq; + using System.Numerics; + + /// + /// Provides common mathematical methods. + /// + internal static class ImageMaths + { + /// + /// Returns how many bits are required to store the specified number of colors. + /// Performs a Log2() on the value. + /// + /// The number of colors. + /// + /// The + /// + public static int GetBitsNeededForColorDepth(int colors) + { + return (int)Math.Ceiling(Math.Log(colors, 2)); + } + } +} diff --git a/src/ImageSharp.Formats.Png/Helpers/StreamExtensions.cs b/src/ImageSharp.Formats.Png/Helpers/StreamExtensions.cs new file mode 100644 index 0000000000..6de94dd229 --- /dev/null +++ b/src/ImageSharp.Formats.Png/Helpers/StreamExtensions.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System.Buffers; + using System.IO; + + /// + /// Extension methods for the type. + /// + internal static class StreamExtensions + { + /// + /// Skips the number of bytes in the given stream. + /// + /// The stream. + /// The count. + public static void Skip(this Stream stream, int count) + { + if (count < 1) + { + return; + } + + if (stream.CanSeek) + { + stream.Position += count; + } + else + { + byte[] foo = ArrayPool.Shared.Rent(count); + try + { + stream.Read(foo, 0, count); + } + finally + { + ArrayPool.Shared.Return(foo); + } + } + } + } +} diff --git a/src/ImageSharp.Formats.Png/ImageExtensions.cs b/src/ImageSharp.Formats.Png/ImageExtensions.cs new file mode 100644 index 0000000000..d46c46217e --- /dev/null +++ b/src/ImageSharp.Formats.Png/ImageExtensions.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// Saves the image to the given stream with the png format. + /// + /// The pixel format. + /// The image this method extends. + /// The stream to save the image to. + /// The quality to save the image to representing the number of colors. + /// Anything equal to 256 and below will cause the encoder to save the image in an indexed format. + /// + /// Thrown if the stream is null. + /// + /// The . + /// + public static Image SaveAsPng(this Image source, Stream stream, int quality = int.MaxValue) + where TColor : struct, IPackedPixel, IEquatable + => source.Save(stream, new PngEncoder { Quality = quality }); + } +} diff --git a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj new file mode 100644 index 0000000000..f12901d6bc --- /dev/null +++ b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 556abdcf-ed93-4327-be98-f6815f78b9b8 + ImageSharp.Formats.Png + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp/Formats/Png/PngChunk.cs b/src/ImageSharp.Formats.Png/PngChunk.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngChunk.cs rename to src/ImageSharp.Formats.Png/PngChunk.cs diff --git a/src/ImageSharp/Formats/Png/PngChunkTypes.cs b/src/ImageSharp.Formats.Png/PngChunkTypes.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngChunkTypes.cs rename to src/ImageSharp.Formats.Png/PngChunkTypes.cs diff --git a/src/ImageSharp/Formats/Png/PngColorType.cs b/src/ImageSharp.Formats.Png/PngColorType.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngColorType.cs rename to src/ImageSharp.Formats.Png/PngColorType.cs diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp.Formats.Png/PngDecoder.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngDecoder.cs rename to src/ImageSharp.Formats.Png/PngDecoder.cs diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp.Formats.Png/PngDecoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngDecoderCore.cs rename to src/ImageSharp.Formats.Png/PngDecoderCore.cs diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp.Formats.Png/PngEncoder.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngEncoder.cs rename to src/ImageSharp.Formats.Png/PngEncoder.cs diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp.Formats.Png/PngEncoderCore.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngEncoderCore.cs rename to src/ImageSharp.Formats.Png/PngEncoderCore.cs diff --git a/src/ImageSharp/Formats/Png/PngFormat.cs b/src/ImageSharp.Formats.Png/PngFormat.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngFormat.cs rename to src/ImageSharp.Formats.Png/PngFormat.cs diff --git a/src/ImageSharp/Formats/Png/PngHeader.cs b/src/ImageSharp.Formats.Png/PngHeader.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngHeader.cs rename to src/ImageSharp.Formats.Png/PngHeader.cs diff --git a/src/ImageSharp/Formats/Png/PngInterlaceMode.cs b/src/ImageSharp.Formats.Png/PngInterlaceMode.cs similarity index 100% rename from src/ImageSharp/Formats/Png/PngInterlaceMode.cs rename to src/ImageSharp.Formats.Png/PngInterlaceMode.cs diff --git a/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4e0043fdd --- /dev/null +++ b/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageSharp.Formats.Jpeg")] +[assembly: AssemblyDescription("A cross-platform library for processing of image files; written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James Jackson-South")] +[assembly: AssemblyProduct("ImageSharp")] +[assembly: AssemblyCopyright("Copyright (c) James Jackson-South and contributors.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + +// Ensure the internals can be tested. +[assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] +[assembly: InternalsVisibleTo("ImageSharp.Tests")] +[assembly: InternalsVisibleTo("ImageSharp.Tests46")] \ No newline at end of file diff --git a/src/ImageSharp/Formats/Png/README.md b/src/ImageSharp.Formats.Png/README.md similarity index 100% rename from src/ImageSharp/Formats/Png/README.md rename to src/ImageSharp.Formats.Png/README.md diff --git a/src/ImageSharp/Formats/Png/Zlib/Adler32.cs b/src/ImageSharp.Formats.Png/Zlib/Adler32.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/Adler32.cs rename to src/ImageSharp.Formats.Png/Zlib/Adler32.cs diff --git a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs b/src/ImageSharp.Formats.Png/Zlib/Crc32.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/Crc32.cs rename to src/ImageSharp.Formats.Png/Zlib/Crc32.cs diff --git a/src/ImageSharp/Formats/Png/Zlib/IChecksum.cs b/src/ImageSharp.Formats.Png/Zlib/IChecksum.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/IChecksum.cs rename to src/ImageSharp.Formats.Png/Zlib/IChecksum.cs diff --git a/src/ImageSharp/Formats/Png/Zlib/README.md b/src/ImageSharp.Formats.Png/Zlib/README.md similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/README.md rename to src/ImageSharp.Formats.Png/Zlib/README.md diff --git a/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs b/src/ImageSharp.Formats.Png/Zlib/ZlibDeflateStream.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs rename to src/ImageSharp.Formats.Png/Zlib/ZlibDeflateStream.cs diff --git a/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs b/src/ImageSharp.Formats.Png/Zlib/ZlibInflateStream.cs similarity index 100% rename from src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs rename to src/ImageSharp.Formats.Png/Zlib/ZlibInflateStream.cs diff --git a/src/ImageSharp.Formats.Png/project.json b/src/ImageSharp.Formats.Png/project.json new file mode 100644 index 0000000000..20998a2d43 --- /dev/null +++ b/src/ImageSharp.Formats.Png/project.json @@ -0,0 +1,73 @@ +{ + "version": "1.0.0-*", + "title": "ImageSharp.Formats", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:stylecop.json", "/ruleset:../../ImageSharp.ruleset" ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": "1.0.0-*", + "StyleCop.Analyzers": { + "version": "1.1.0-beta001", + "type": "build" + }, + "System.Buffers": "4.0.0", + "System.Numerics.Vectors": "4.1.1", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + } + }, + "net45": { + "dependencies": { + "System.Runtime": "4.0.0" + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Formats/BootstrapperExtensions.cs b/src/ImageSharp.Formats/BootstrapperExtensions.cs new file mode 100644 index 0000000000..90b3384a5e --- /dev/null +++ b/src/ImageSharp.Formats/BootstrapperExtensions.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + + using Formats; + + /// + /// Extension methods for the type. + /// + public static partial class BootstrapperExtensions + { + /// + /// Adds the common formats, PNG, JPEG, GIF and BMP. + /// + /// The bootstrapper. + /// The bootstrapper + public static Bootstrapper AddCommonFormats(this Bootstrapper bootstrapper) + { + return bootstrapper + .AddPngFormat() + .AddJpegFormat() + .AddGifFormat() + .AddBmpFormat(); + } + } +} diff --git a/src/ImageSharp.Formats/ImageSharp.Formats.xproj b/src/ImageSharp.Formats/ImageSharp.Formats.xproj new file mode 100644 index 0000000000..80a0b84a66 --- /dev/null +++ b/src/ImageSharp.Formats/ImageSharp.Formats.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c72b8906-260a-4688-9b7a-5cd4bdf419ec + ImageSharp.Formats + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c4e0043fdd --- /dev/null +++ b/src/ImageSharp.Formats/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageSharp.Formats.Jpeg")] +[assembly: AssemblyDescription("A cross-platform library for processing of image files; written in C#")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James Jackson-South")] +[assembly: AssemblyProduct("ImageSharp")] +[assembly: AssemblyCopyright("Copyright (c) James Jackson-South and contributors.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + +// Ensure the internals can be tested. +[assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] +[assembly: InternalsVisibleTo("ImageSharp.Tests")] +[assembly: InternalsVisibleTo("ImageSharp.Tests46")] \ No newline at end of file diff --git a/src/ImageSharp.Formats/project.json b/src/ImageSharp.Formats/project.json new file mode 100644 index 0000000000..37d1b25443 --- /dev/null +++ b/src/ImageSharp.Formats/project.json @@ -0,0 +1,58 @@ +{ + "version": "1.0.0-*", + "title": "ImageSharp.Formats", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:stylecop.json", "/ruleset:../../ImageSharp.ruleset" ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": "1.0.0-*", + "ImageSharp.Formats.Png": "1.0.0-*", + "ImageSharp.Formats.Bmp": "1.0.0-*", + "ImageSharp.Formats.Jpeg": "1.0.0-*", + "ImageSharp.Formats.Gif": "1.0.0-*", + "StyleCop.Analyzers": { + "version": "1.1.0-beta001", + "type": "build" + } + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + } + }, + "net45": { + "dependencies": { + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Common/Helpers/Guard.cs b/src/ImageSharp/Common/Helpers/Guard.cs index cf307e9365..cc05e18005 100644 --- a/src/ImageSharp/Common/Helpers/Guard.cs +++ b/src/ImageSharp/Common/Helpers/Guard.cs @@ -14,7 +14,7 @@ namespace ImageSharp /// Provides methods to protect against invalid parameters. /// [DebuggerStepThrough] - internal static class Guard + public static class Guard { /// /// Verifies, that the method parameter with specified object value is not null diff --git a/src/ImageSharp/IO/EndianBinaryReader.cs b/src/ImageSharp/IO/EndianBinaryReader.cs index ae780ba4c7..d12d0b9761 100644 --- a/src/ImageSharp/IO/EndianBinaryReader.cs +++ b/src/ImageSharp/IO/EndianBinaryReader.cs @@ -45,14 +45,14 @@ namespace ImageSharp.IO /// Equivalent of , but with either endianness, depending on /// the EndianBitConverter it is constructed with. /// - /// - /// Converter to use when reading data + /// + /// Endianness to use when reading data /// /// /// Stream to read data from /// - public EndianBinaryReader(EndianBitConverter bitConverter, Stream stream) - : this(bitConverter, stream, Encoding.UTF8) + public EndianBinaryReader(Endianness endianness, Stream stream) + : this(endianness, stream, Encoding.UTF8) { } @@ -61,18 +61,17 @@ namespace ImageSharp.IO /// Constructs a new binary reader with the given bit converter, reading /// to the given stream, using the given encoding. /// - /// Converter to use when reading data + /// Endianness to use when reading data /// Stream to read data from /// Encoding to use when reading character data - public EndianBinaryReader(EndianBitConverter bitConverter, Stream stream, Encoding encoding) + public EndianBinaryReader(Endianness endianness, Stream stream, Encoding encoding) { - Guard.NotNull(bitConverter, nameof(bitConverter)); Guard.NotNull(stream, nameof(stream)); Guard.NotNull(encoding, nameof(encoding)); Guard.IsTrue(stream.CanRead, nameof(stream), "Stream isn't readable."); this.BaseStream = stream; - this.BitConverter = bitConverter; + this.BitConverter = EndianBitConverter.GetConverter(endianness); this.Encoding = encoding; this.decoder = encoding.GetDecoder(); this.minBytesPerChar = 1; @@ -83,11 +82,6 @@ namespace ImageSharp.IO } } - /// - /// Gets the bit converter used to read values from the stream. - /// - public EndianBitConverter BitConverter { get; } - /// /// Gets the encoding used to read strings /// @@ -98,6 +92,11 @@ namespace ImageSharp.IO /// public Stream BaseStream { get; } + /// + /// Gets the bit converter used to read values from the stream. + /// + internal EndianBitConverter BitConverter { get; } + /// /// Closes the reader, including the underlying stream. /// diff --git a/src/ImageSharp/IO/EndianBinaryWriter.cs b/src/ImageSharp/IO/EndianBinaryWriter.cs index c10d118cf4..d3fc524746 100644 --- a/src/ImageSharp/IO/EndianBinaryWriter.cs +++ b/src/ImageSharp/IO/EndianBinaryWriter.cs @@ -13,7 +13,7 @@ namespace ImageSharp.IO /// Equivalent of , but with either endianness, depending on /// the it is constructed with. /// - internal class EndianBinaryWriter : IDisposable + public class EndianBinaryWriter : IDisposable { /// /// Buffer used for temporary storage during conversion from primitives @@ -34,10 +34,10 @@ namespace ImageSharp.IO /// Initializes a new instance of the class /// with the given bit converter, writing to the given stream, using UTF-8 encoding. /// - /// Converter to use when writing data + /// Endianness to use when writing data /// Stream to write data to - public EndianBinaryWriter(EndianBitConverter bitConverter, Stream stream) - : this(bitConverter, stream, Encoding.UTF8) + public EndianBinaryWriter(Endianness endianness, Stream stream) + : this(endianness, stream, Encoding.UTF8) { } @@ -45,13 +45,15 @@ namespace ImageSharp.IO /// Initializes a new instance of the class /// with the given bit converter, writing to the given stream, using the given encoding. /// - /// Converter to use when writing data + /// Endianness to use when writing data /// Stream to write data to /// /// Encoding to use when writing character data /// - public EndianBinaryWriter(EndianBitConverter bitConverter, Stream stream, Encoding encoding) + public EndianBinaryWriter(Endianness endianness, Stream stream, Encoding encoding) { + var bitConverter = EndianBitConverter.GetConverter(endianness); + // TODO: Use Guard if (bitConverter == null) { @@ -78,11 +80,6 @@ namespace ImageSharp.IO this.Encoding = encoding; } - /// - /// Gets the bit converter used to write values to the stream - /// - public EndianBitConverter BitConverter { get; } - /// /// Gets the encoding used to write strings /// @@ -93,6 +90,11 @@ namespace ImageSharp.IO /// public Stream BaseStream { get; } + /// + /// Gets the bit converter used to write values to the stream + /// + internal EndianBitConverter BitConverter { get; } + /// /// Closes the writer, including the underlying stream. /// diff --git a/src/ImageSharp/IO/EndianBitConverter.cs b/src/ImageSharp/IO/EndianBitConverter.cs index e99e38db28..812823e7a2 100644 --- a/src/ImageSharp/IO/EndianBitConverter.cs +++ b/src/ImageSharp/IO/EndianBitConverter.cs @@ -49,22 +49,29 @@ namespace ImageSharp.IO /// private static readonly LittleEndianBitConverter LittleConverter = new LittleEndianBitConverter(); - /// - /// Gets a little-endian bit converter instance. The same instance is - /// always returned. - /// - public static LittleEndianBitConverter Little => LittleConverter; - /// /// The big-endian bit converter. /// private static readonly BigEndianBitConverter BigConverter = new BigEndianBitConverter(); /// - /// Gets a big-endian bit converter instance. The same instance is - /// always returned. + /// Gets the converter. /// - public static BigEndianBitConverter Big => BigConverter; + /// The endianness. + /// an + /// Not a valid form of Endianness - endianness + internal static EndianBitConverter GetConverter(Endianness endianness) + { + switch (endianness) + { + case Endianness.LittleEndian: + return LittleConverter; + case Endianness.BigEndian: + return BigConverter; + default: + throw new ArgumentException("Not a valid form of Endianness", nameof(endianness)); + } + } #endregion #region Double/primitive conversions diff --git a/src/ImageSharp/IO/Endianness.cs b/src/ImageSharp/IO/Endianness.cs index aefda6dc4b..50bfec3465 100644 --- a/src/ImageSharp/IO/Endianness.cs +++ b/src/ImageSharp/IO/Endianness.cs @@ -8,7 +8,7 @@ namespace ImageSharp.IO /// /// Endianness of a converter /// - internal enum Endianness + public enum Endianness { /// /// Little endian - least significant byte first diff --git a/src/ImageSharp/Image/ImageIOExtensions.cs b/src/ImageSharp/Image/ImageIOExtensions.cs deleted file mode 100644 index fd76e91372..0000000000 --- a/src/ImageSharp/Image/ImageIOExtensions.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.IO; - - using Formats; - - /// - /// Extension methods for the type. - /// - public static partial class ImageExtensions - { - /// - /// Saves the image to the given stream with the bmp format. - /// - /// The pixel format. - /// The image this method extends. - /// The stream to save the image to. - /// Thrown if the stream is null. - /// - /// The . - /// - public static Image SaveAsBmp(this Image source, Stream stream) - where TColor : struct, IPackedPixel, IEquatable - => source.Save(stream, new BmpEncoder()); - - /// - /// Saves the image to the given stream with the png format. - /// - /// The pixel format. - /// The image this method extends. - /// The stream to save the image to. - /// The quality to save the image to representing the number of colors. - /// Anything equal to 256 and below will cause the encoder to save the image in an indexed format. - /// - /// Thrown if the stream is null. - /// - /// The . - /// - public static Image SaveAsPng(this Image source, Stream stream, int quality = int.MaxValue) - where TColor : struct, IPackedPixel, IEquatable - => source.Save(stream, new PngEncoder { Quality = quality }); - - /// - /// Saves the image to the given stream with the jpeg format. - /// - /// The pixel format. - /// The image this method extends. - /// The stream to save the image to. - /// The quality to save the image to. Between 1 and 100. - /// Thrown if the stream is null. - /// - /// The . - /// - public static Image SaveAsJpeg(this Image source, Stream stream, int quality = 75) - where TColor : struct, IPackedPixel, IEquatable - => source.Save(stream, new JpegEncoder { Quality = quality }); - - /// - /// Saves the image to the given stream with the gif format. - /// - /// The pixel format. - /// The image this method extends. - /// The stream to save the image to. - /// The quality to save the image to representing the number of colors. Between 1 and 256. - /// Thrown if the stream is null. - /// - /// The . - /// - public static Image SaveAsGif(this Image source, Stream stream, int quality = 256) - where TColor : struct, IPackedPixel, IEquatable - => source.Save(stream, new GifEncoder { Quality = quality }); - } -} diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index b4f02c7bec..162891442c 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -240,6 +240,14 @@ namespace ImageSharp GC.SuppressFinalize(this); } + /// + /// Resets all the pixels to it's initial value. + /// + public void Reset() + { + Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height)); + } + /// /// Copies the pixels to another of the same size. /// @@ -251,14 +259,6 @@ namespace ImageSharp Unsafe.CopyBlock(target.pixelsBase, this.pixelsBase, byteCount); } - /// - /// Resets all the pixels to it's initial value. - /// - internal void Reset() - { - Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height)); - } - /// /// Copies from an area in format. /// diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TColor}.cs index 40da75c829..99e9273751 100644 --- a/src/ImageSharp/Image/PixelArea{TColor}.cs +++ b/src/ImageSharp/Image/PixelArea{TColor}.cs @@ -231,7 +231,7 @@ namespace ImageSharp /// /// Resets the bytes of the array to it's initial value. /// - internal void Reset() + public void Reset() { Unsafe.InitBlock(this.PixelBase, 0, (uint)(this.RowStride * this.Height)); } diff --git a/src/ImageSharp/Numerics/Rectangle.cs b/src/ImageSharp/Numerics/Rectangle.cs index 3bd844bc89..b651eff71a 100644 --- a/src/ImageSharp/Numerics/Rectangle.cs +++ b/src/ImageSharp/Numerics/Rectangle.cs @@ -54,6 +54,20 @@ namespace ImageSharp this.backingVector = new Vector4(point.X, point.Y, size.Width, size.Height); } + /// + /// Initializes a new instance of the struct. + /// + /// + /// The which specifies the rectangles top left point in a two-dimensional plane. + /// + /// + /// The which specifies the rectangles bottom right point in a two-dimensional plane. + /// + public Rectangle(Point topLeft, Point bottomRight) + { + this.backingVector = new Vector4(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y); + } + /// /// Initializes a new instance of the struct. /// diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json index 9cf5cac39b..3160268d73 100644 --- a/tests/ImageSharp.Benchmarks/project.json +++ b/tests/ImageSharp.Benchmarks/project.json @@ -16,7 +16,8 @@ "dependencies": { "BenchmarkDotNet.Diagnostics.Windows": "0.10.1", "ImageSharp": "1.0.0-*", - "ImageSharp.Drawing": "1.0.0-*" + "ImageSharp.Drawing": "1.0.0-*", + "ImageSharp.Formats": "1.0.0-*" }, "commands": { "ImageSharp.Benchmarks": "ImageSharp.Benchmarks" diff --git a/tests/ImageSharp.Tests/FileTestBase.cs b/tests/ImageSharp.Tests/FileTestBase.cs index 0dbf132990..72a681a559 100644 --- a/tests/ImageSharp.Tests/FileTestBase.cs +++ b/tests/ImageSharp.Tests/FileTestBase.cs @@ -6,6 +6,7 @@ namespace ImageSharp.Tests { using System.Collections.Generic; + using ImageSharp.Formats; /// /// The test base class for reading and writing to files. diff --git a/tests/ImageSharp.Tests/IO/BigEndianBitConverterTests.cs b/tests/ImageSharp.Tests/IO/BigEndianBitConverterTests.cs index 0bcd675704..2030c3dcad 100644 --- a/tests/ImageSharp.Tests/IO/BigEndianBitConverterTests.cs +++ b/tests/ImageSharp.Tests/IO/BigEndianBitConverterTests.cs @@ -20,11 +20,11 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesShort() { - this.CheckBytes(new byte[] { 0, 0 }, EndianBitConverter.Big.GetBytes((short)0)); - this.CheckBytes(new byte[] { 0, 1 }, EndianBitConverter.Big.GetBytes((short)1)); - this.CheckBytes(new byte[] { 1, 0 }, EndianBitConverter.Big.GetBytes((short)256)); - this.CheckBytes(new byte[] { 255, 255 }, EndianBitConverter.Big.GetBytes((short)-1)); - this.CheckBytes(new byte[] { 1, 1 }, EndianBitConverter.Big.GetBytes((short)257)); + this.CheckBytes(new byte[] { 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((short)0)); + this.CheckBytes(new byte[] { 0, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((short)1)); + this.CheckBytes(new byte[] { 1, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((short)256)); + this.CheckBytes(new byte[] { 255, 255 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((short)-1)); + this.CheckBytes(new byte[] { 1, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((short)257)); } /// @@ -33,13 +33,13 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesInt() { - this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes((int)0)); - this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.Big.GetBytes((int)1)); - this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.Big.GetBytes((int)256)); - this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.Big.GetBytes((int)65536)); - this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.Big.GetBytes((int)16777216)); - this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.Big.GetBytes((int)-1)); - this.CheckBytes(new byte[] { 0, 0, 1, 1 }, EndianBitConverter.Big.GetBytes((int)257)); + this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)0)); + this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)1)); + this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)256)); + this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)65536)); + this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)16777216)); + this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)-1)); + this.CheckBytes(new byte[] { 0, 0, 1, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((int)257)); } /// @@ -48,13 +48,13 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesUInt() { - this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes((uint)0)); - this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.Big.GetBytes((uint)1)); - this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.Big.GetBytes((uint)256)); - this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.Big.GetBytes((uint)65536)); - this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.Big.GetBytes((uint)16777216)); - this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.Big.GetBytes((uint)uint.MaxValue)); - this.CheckBytes(new byte[] { 0, 0, 1, 1 }, EndianBitConverter.Big.GetBytes((uint)257)); + this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)0)); + this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)1)); + this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)256)); + this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)65536)); + this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)16777216)); + this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)uint.MaxValue)); + this.CheckBytes(new byte[] { 0, 0, 1, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes((uint)257)); } /// @@ -63,17 +63,17 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesLong() { - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(0L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.Big.GetBytes(1L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.Big.GetBytes(256L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.Big.GetBytes(65536L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(16777216L)); - this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(4294967296L)); - this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776L)); - this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776L * 256)); - this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776L * 256 * 256)); - this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.Big.GetBytes(-1L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1 }, EndianBitConverter.Big.GetBytes(257L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(0L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(256L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(65536L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(16777216L)); + this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(4294967296L)); + this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776L)); + this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776L * 256)); + this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776L * 256 * 256)); + this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(-1L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(257L)); } /// @@ -82,17 +82,17 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesULong() { - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(0UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.Big.GetBytes(1UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.Big.GetBytes(256UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.Big.GetBytes(65536UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(16777216UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(4294967296UL)); - this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776UL)); - this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776UL * 256)); - this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Big.GetBytes(1099511627776UL * 256 * 256)); - this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.Big.GetBytes(ulong.MaxValue)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1 }, EndianBitConverter.Big.GetBytes(257UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(0UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(256UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(65536UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(16777216UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(4294967296UL)); + this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776UL)); + this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776UL * 256)); + this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(1099511627776UL * 256 * 256)); + this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(ulong.MaxValue)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1 }, EndianBitConverter.GetConverter(Endianness.BigEndian).GetBytes(257UL)); } /// diff --git a/tests/ImageSharp.Tests/IO/EndianBinaryReaderTests.cs b/tests/ImageSharp.Tests/IO/EndianBinaryReaderTests.cs index 3eed88c87a..ffd9cdedcc 100644 --- a/tests/ImageSharp.Tests/IO/EndianBinaryReaderTests.cs +++ b/tests/ImageSharp.Tests/IO/EndianBinaryReaderTests.cs @@ -35,7 +35,7 @@ namespace ImageSharp.Tests.IO public void ReadCharsBeyondInternalBufferSize() { MemoryStream stream = new MemoryStream(TestBytes); - using (EndianBinaryReader subject = new EndianBinaryReader(EndianBitConverter.Little, stream)) + using (EndianBinaryReader subject = new EndianBinaryReader(Endianness.LittleEndian, stream)) { char[] chars = new char[TestString.Length]; subject.Read(chars, 0, chars.Length); @@ -54,7 +54,7 @@ namespace ImageSharp.Tests.IO () => { MemoryStream stream = new MemoryStream(TestBytes); - using (EndianBinaryReader subject = new EndianBinaryReader(EndianBitConverter.Little, stream)) + using (EndianBinaryReader subject = new EndianBinaryReader(Endianness.LittleEndian, stream)) { char[] chars = new char[TestString.Length - 1]; diff --git a/tests/ImageSharp.Tests/IO/LittleEndianBitConverterTests.cs b/tests/ImageSharp.Tests/IO/LittleEndianBitConverterTests.cs index ebad96e062..fe76623063 100644 --- a/tests/ImageSharp.Tests/IO/LittleEndianBitConverterTests.cs +++ b/tests/ImageSharp.Tests/IO/LittleEndianBitConverterTests.cs @@ -20,11 +20,11 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesShort() { - this.CheckBytes(new byte[] { 0, 0 }, EndianBitConverter.Little.GetBytes((short)0)); - this.CheckBytes(new byte[] { 1, 0 }, EndianBitConverter.Little.GetBytes((short)1)); - this.CheckBytes(new byte[] { 0, 1 }, EndianBitConverter.Little.GetBytes((short)256)); - this.CheckBytes(new byte[] { 255, 255 }, EndianBitConverter.Little.GetBytes((short)-1)); - this.CheckBytes(new byte[] { 1, 1 }, EndianBitConverter.Little.GetBytes((short)257)); + this.CheckBytes(new byte[] { 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((short)0)); + this.CheckBytes(new byte[] { 1, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((short)1)); + this.CheckBytes(new byte[] { 0, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((short)256)); + this.CheckBytes(new byte[] { 255, 255 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((short)-1)); + this.CheckBytes(new byte[] { 1, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((short)257)); } /// @@ -33,13 +33,13 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesInt() { - this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes((int)0)); - this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.Little.GetBytes((int)1)); - this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.Little.GetBytes((int)256)); - this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.Little.GetBytes((int)65536)); - this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.Little.GetBytes((int)16777216)); - this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.Little.GetBytes((int)-1)); - this.CheckBytes(new byte[] { 1, 1, 0, 0 }, EndianBitConverter.Little.GetBytes((int)257)); + this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)0)); + this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)1)); + this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)256)); + this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)65536)); + this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)16777216)); + this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)-1)); + this.CheckBytes(new byte[] { 1, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((int)257)); } /// @@ -48,13 +48,13 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesUInt() { - this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes((uint)0)); - this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.Little.GetBytes((uint)1)); - this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.Little.GetBytes((uint)256)); - this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.Little.GetBytes((uint)65536)); - this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.Little.GetBytes((uint)16777216)); - this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.Little.GetBytes((uint)uint.MaxValue)); - this.CheckBytes(new byte[] { 1, 1, 0, 0 }, EndianBitConverter.Little.GetBytes((uint)257)); + this.CheckBytes(new byte[] { 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)0)); + this.CheckBytes(new byte[] { 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)1)); + this.CheckBytes(new byte[] { 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)256)); + this.CheckBytes(new byte[] { 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)65536)); + this.CheckBytes(new byte[] { 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)16777216)); + this.CheckBytes(new byte[] { 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)uint.MaxValue)); + this.CheckBytes(new byte[] { 1, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes((uint)257)); } /// @@ -63,17 +63,17 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesLong() { - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(0L)); - this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(1L)); - this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(256L)); - this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(65536L)); - this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(16777216L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(4294967296L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.Little.GetBytes(1099511627776L)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.Little.GetBytes(1099511627776L * 256)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.Little.GetBytes(1099511627776L * 256 * 256)); - this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.Little.GetBytes(-1L)); - this.CheckBytes(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(257L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(0L)); + this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1L)); + this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(256L)); + this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(65536L)); + this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(16777216L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(4294967296L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776L)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776L * 256)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776L * 256 * 256)); + this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(-1L)); + this.CheckBytes(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(257L)); } /// @@ -82,17 +82,17 @@ namespace ImageSharp.Tests.IO [Fact] public void GetBytesULong() { - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(0UL)); - this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(1UL)); - this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(256UL)); - this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(65536UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(16777216UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(4294967296UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.Little.GetBytes(1099511627776UL)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.Little.GetBytes(1099511627776UL * 256)); - this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.Little.GetBytes(1099511627776UL * 256 * 256)); - this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.Little.GetBytes(ulong.MaxValue)); - this.CheckBytes(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.Little.GetBytes(257UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(0UL)); + this.CheckBytes(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1UL)); + this.CheckBytes(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(256UL)); + this.CheckBytes(new byte[] { 0, 0, 1, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(65536UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 1, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(16777216UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 1, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(4294967296UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 1, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776UL)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 1, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776UL * 256)); + this.CheckBytes(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(1099511627776UL * 256 * 256)); + this.CheckBytes(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(ulong.MaxValue)); + this.CheckBytes(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0 }, EndianBitConverter.GetConverter(Endianness.LittleEndian).GetBytes(257UL)); } /// diff --git a/tests/ImageSharp.Tests/TestBase.cs b/tests/ImageSharp.Tests/TestBase.cs index 175bf215c4..391ed89ac4 100644 --- a/tests/ImageSharp.Tests/TestBase.cs +++ b/tests/ImageSharp.Tests/TestBase.cs @@ -6,12 +6,18 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.Formats; /// /// The test base class. Inherit from this class for any image manipulation tests. /// public abstract class TestBase { + protected TestBase() + { + Bootstrapper.Default.AddCommonFormats(); + } + /// /// Creates the image output directory. /// diff --git a/tests/ImageSharp.Tests/project.json b/tests/ImageSharp.Tests/project.json index d6bdcb7d6d..40ff653bf1 100644 --- a/tests/ImageSharp.Tests/project.json +++ b/tests/ImageSharp.Tests/project.json @@ -23,7 +23,8 @@ "ImageSharp": "1.0.0-*", "xunit": "2.2.0-*", "dotnet-test-xunit": "2.2.0-*", - "ImageSharp.Drawing": "1.0.0-*" + "ImageSharp.Drawing": "1.0.0-*", + "ImageSharp.Formats": "1.0.0-*" }, "frameworks": { "netcoreapp1.1": {