Browse Source

split formats into there own projects/packages

af/merge-core
Scott Williams 9 years ago
committed by Scott Williams
parent
commit
de9c49b122
  1. 35
      ImageSharp.sln
  2. 29
      build/Program.cs
  3. 3
      src/ImageSharp.Drawing/project.json
  4. 0
      src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs
  5. 0
      src/ImageSharp.Formats.Bmp/BmpCompression.cs
  6. 0
      src/ImageSharp.Formats.Bmp/BmpDecoder.cs
  7. 0
      src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs
  8. 0
      src/ImageSharp.Formats.Bmp/BmpEncoder.cs
  9. 2
      src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs
  10. 0
      src/ImageSharp.Formats.Bmp/BmpFileHeader.cs
  11. 0
      src/ImageSharp.Formats.Bmp/BmpFormat.cs
  12. 0
      src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs
  13. 29
      src/ImageSharp.Formats.Bmp/BootstrapperExtensions.cs
  14. 32
      src/ImageSharp.Formats.Bmp/ImageExtensions.cs
  15. 25
      src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj
  16. 40
      src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs
  17. 0
      src/ImageSharp.Formats.Bmp/README.md
  18. 73
      src/ImageSharp.Formats.Bmp/project.json
  19. 29
      src/ImageSharp.Formats.Gif/BootstrapperExtensions.cs
  20. 0
      src/ImageSharp.Formats.Gif/DisposalMethod.cs
  21. 0
      src/ImageSharp.Formats.Gif/GifConstants.cs
  22. 0
      src/ImageSharp.Formats.Gif/GifDecoder.cs
  23. 0
      src/ImageSharp.Formats.Gif/GifDecoderCore.cs
  24. 0
      src/ImageSharp.Formats.Gif/GifEncoder.cs
  25. 2
      src/ImageSharp.Formats.Gif/GifEncoderCore.cs
  26. 0
      src/ImageSharp.Formats.Gif/GifFormat.cs
  27. 39
      src/ImageSharp.Formats.Gif/Helpers/ComparableExtensions.cs
  28. 30
      src/ImageSharp.Formats.Gif/Helpers/ImageMaths.cs
  29. 46
      src/ImageSharp.Formats.Gif/Helpers/StreamExtensions.cs
  30. 53
      src/ImageSharp.Formats.Gif/ImageExtensions.cs
  31. 25
      src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj
  32. 0
      src/ImageSharp.Formats.Gif/LzwDecoder.cs
  33. 0
      src/ImageSharp.Formats.Gif/LzwEncoder.cs
  34. 0
      src/ImageSharp.Formats.Gif/PackedField.cs
  35. 40
      src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs
  36. 0
      src/ImageSharp.Formats.Gif/README.md
  37. 0
      src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs
  38. 0
      src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs
  39. 0
      src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs
  40. 73
      src/ImageSharp.Formats.Gif/project.json
  41. 29
      src/ImageSharp.Formats.Jpeg/BootstrapperExtensions.cs
  42. 0
      src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs
  43. 0
      src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt
  44. 0
      src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs
  45. 0
      src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs
  46. 0
      src/ImageSharp.Formats.Jpeg/Components/DCT.cs
  47. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs
  48. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs
  49. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs
  50. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs
  51. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs
  52. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs
  53. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md
  54. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/Scan.cs
  55. 0
      src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs
  56. 0
      src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs
  57. 0
      src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs
  58. 0
      src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs
  59. 0
      src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs
  60. 63
      src/ImageSharp.Formats.Jpeg/Helpers/ComparableExtensions.cs
  61. 33
      src/ImageSharp.Formats.Jpeg/ImageExtensions.cs
  62. 25
      src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj
  63. 0
      src/ImageSharp.Formats.Jpeg/JpegConstants.cs
  64. 0
      src/ImageSharp.Formats.Jpeg/JpegDecoder.cs
  65. 0
      src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs
  66. 0
      src/ImageSharp.Formats.Jpeg/JpegEncoder.cs
  67. 0
      src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs
  68. 0
      src/ImageSharp.Formats.Jpeg/JpegFormat.cs
  69. 0
      src/ImageSharp.Formats.Jpeg/JpegSubsample.cs
  70. 40
      src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs
  71. 0
      src/ImageSharp.Formats.Jpeg/README.md
  72. 0
      src/ImageSharp.Formats.Jpeg/UnzigData.cs
  73. 0
      src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs
  74. 0
      src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs
  75. 0
      src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs
  76. 73
      src/ImageSharp.Formats.Jpeg/project.json
  77. 29
      src/ImageSharp.Formats.Png/BootstrapperExtensions.cs
  78. 0
      src/ImageSharp.Formats.Png/Filters/AverageFilter.cs
  79. 0
      src/ImageSharp.Formats.Png/Filters/FilterType.cs
  80. 0
      src/ImageSharp.Formats.Png/Filters/NoneFilter.cs
  81. 0
      src/ImageSharp.Formats.Png/Filters/PaethFilter.cs
  82. 0
      src/ImageSharp.Formats.Png/Filters/SubFilter.cs
  83. 0
      src/ImageSharp.Formats.Png/Filters/UpFilter.cs
  84. 45
      src/ImageSharp.Formats.Png/Helpers/ByteExtensions.cs
  85. 52
      src/ImageSharp.Formats.Png/Helpers/ComparableExtensions.cs
  86. 30
      src/ImageSharp.Formats.Png/Helpers/ImageMaths.cs
  87. 46
      src/ImageSharp.Formats.Png/Helpers/StreamExtensions.cs
  88. 35
      src/ImageSharp.Formats.Png/ImageExtensions.cs
  89. 25
      src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj
  90. 0
      src/ImageSharp.Formats.Png/PngChunk.cs
  91. 0
      src/ImageSharp.Formats.Png/PngChunkTypes.cs
  92. 0
      src/ImageSharp.Formats.Png/PngColorType.cs
  93. 0
      src/ImageSharp.Formats.Png/PngDecoder.cs
  94. 0
      src/ImageSharp.Formats.Png/PngDecoderCore.cs
  95. 0
      src/ImageSharp.Formats.Png/PngEncoder.cs
  96. 0
      src/ImageSharp.Formats.Png/PngEncoderCore.cs
  97. 0
      src/ImageSharp.Formats.Png/PngFormat.cs
  98. 0
      src/ImageSharp.Formats.Png/PngHeader.cs
  99. 0
      src/ImageSharp.Formats.Png/PngInterlaceMode.cs
  100. 40
      src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs

35
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

29
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}";
}
}
}

3
src/ImageSharp.Drawing/project.json

@ -71,8 +71,5 @@
"System.Runtime": "4.0.0"
}
}
},
"tools": {
"dotnet-version": "1.1.0"
}
}

0
src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs → src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs

0
src/ImageSharp/Formats/Bmp/BmpCompression.cs → src/ImageSharp.Formats.Bmp/BmpCompression.cs

0
src/ImageSharp/Formats/Bmp/BmpDecoder.cs → src/ImageSharp.Formats.Bmp/BmpDecoder.cs

0
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs → src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs

0
src/ImageSharp/Formats/Bmp/BmpEncoder.cs → src/ImageSharp.Formats.Bmp/BmpEncoder.cs

2
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs → 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
{

0
src/ImageSharp/Formats/Bmp/BmpFileHeader.cs → src/ImageSharp.Formats.Bmp/BmpFileHeader.cs

0
src/ImageSharp/Formats/Bmp/BmpFormat.cs → src/ImageSharp.Formats.Bmp/BmpFormat.cs

0
src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs → src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs

29
src/ImageSharp.Formats.Bmp/BootstrapperExtensions.cs

@ -0,0 +1,29 @@
// <copyright file="BootstrapperExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class BootstrapperExtensions
{
/// <summary>
/// Adds the BMP format.
/// </summary>
/// <param name="bootstrapper">The bootstrapper.</param>
/// <returns>The bootstraper</returns>
public static Bootstrapper AddBmpFormat(this Bootstrapper bootstrapper)
{
bootstrapper.AddImageFormat(new BmpFormat());
return bootstrapper;
}
}
}

32
src/ImageSharp.Formats.Bmp/ImageExtensions.cs

@ -0,0 +1,32 @@
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the bmp format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColoR}"/>.
/// </returns>
public static Image<TColor> SaveAsBmp<TColor>(this Image<TColor> source, Stream stream)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> source.Save(stream, new BmpEncoder());
}
}

25
src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>c77661b9-f793-422e-8e27-ac60ecc5f215</ProjectGuid>
<RootNamespace>ImageSharp.Formats.Bmp</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

40
src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs

@ -0,0 +1,40 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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")]

0
src/ImageSharp/Formats/Bmp/README.md → src/ImageSharp.Formats.Bmp/README.md

73
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"
}
}
}
}

29
src/ImageSharp.Formats.Gif/BootstrapperExtensions.cs

@ -0,0 +1,29 @@
// <copyright file="BootstrapperExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class BootstrapperExtensions
{
/// <summary>
/// Adds the Gif format.
/// </summary>
/// <param name="bootstrapper">The bootstrapper.</param>
/// <returns>The Bootstrapper</returns>
public static Bootstrapper AddGifFormat(this Bootstrapper bootstrapper)
{
bootstrapper.AddImageFormat(new GifFormat());
return bootstrapper;
}
}
}

0
src/ImageSharp/Formats/Gif/DisposalMethod.cs → src/ImageSharp.Formats.Gif/DisposalMethod.cs

0
src/ImageSharp/Formats/Gif/GifConstants.cs → src/ImageSharp.Formats.Gif/GifConstants.cs

0
src/ImageSharp/Formats/Gif/GifDecoder.cs → src/ImageSharp.Formats.Gif/GifDecoder.cs

0
src/ImageSharp/Formats/Gif/GifDecoderCore.cs → src/ImageSharp.Formats.Gif/GifDecoderCore.cs

0
src/ImageSharp/Formats/Gif/GifEncoder.cs → src/ImageSharp.Formats.Gif/GifEncoder.cs

2
src/ImageSharp/Formats/Gif/GifEncoderCore.cs → 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;

0
src/ImageSharp/Formats/Gif/GifFormat.cs → src/ImageSharp.Formats.Gif/GifFormat.cs

39
src/ImageSharp.Formats.Gif/Helpers/ComparableExtensions.cs

@ -0,0 +1,39 @@
// <copyright file="ComparableExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
/// <summary>
/// Extension methods for classes that implement <see cref="IComparable{T}"/>.
/// </summary>
internal static class ComparableExtensions
{
/// <summary>
/// Restricts a <see cref="int"/> to be within a specified range.
/// </summary>
/// <param name="value">The The value to clamp.</param>
/// <param name="min">The minimum value. If value is less than min, min will be returned.</param>
/// <param name="max">The maximum value. If value is greater than max, max will be returned.</param>
/// <returns>
/// The <see cref="int"/> representing the clamped value.
/// </returns>
public static int Clamp(this int value, int min, int max)
{
if (value > max)
{
return max;
}
if (value < min)
{
return min;
}
return value;
}
}
}

30
src/ImageSharp.Formats.Gif/Helpers/ImageMaths.cs

@ -0,0 +1,30 @@
// <copyright file="ImageMaths.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Linq;
using System.Numerics;
/// <summary>
/// Provides common mathematical methods.
/// </summary>
internal static class ImageMaths
{
/// <summary>
/// Returns how many bits are required to store the specified number of colors.
/// Performs a Log2() on the value.
/// </summary>
/// <param name="colors">The number of colors.</param>
/// <returns>
/// The <see cref="int"/>
/// </returns>
public static int GetBitsNeededForColorDepth(int colors)
{
return (int)Math.Ceiling(Math.Log(colors, 2));
}
}
}

46
src/ImageSharp.Formats.Gif/Helpers/StreamExtensions.cs

@ -0,0 +1,46 @@
// <copyright file="StreamExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.Buffers;
using System.IO;
/// <summary>
/// Extension methods for the <see cref="Stream"/> type.
/// </summary>
internal static class StreamExtensions
{
/// <summary>
/// Skips the number of bytes in the given stream.
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="count">The count.</param>
public static void Skip(this Stream stream, int count)
{
if (count < 1)
{
return;
}
if (stream.CanSeek)
{
stream.Position += count;
}
else
{
byte[] foo = ArrayPool<byte>.Shared.Rent(count);
try
{
stream.Read(foo, 0, count);
}
finally
{
ArrayPool<byte>.Shared.Return(foo);
}
}
}
}
}

53
src/ImageSharp.Formats.Gif/ImageExtensions.cs

@ -0,0 +1,53 @@
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the gif format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to representing the number of colors. Between 1 and 256.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// </returns>
public static Image<TColor> SaveAsGif<TColor>(this Image<TColor> source, Stream stream, int quality = 256)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> source.Save(stream, new GifEncoder { Quality = quality });
/// <summary>
/// To the frame.
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The frame</returns>
internal static ImageFrame<TColor> ToFrame<TColor>(this ImageBase<TColor> source)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> new ImageFrame<TColor>(source);
/// <summary>
/// Clones the specified source.
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The frame</returns>
internal static ImageFrame<TColor> Clone<TColor>(this ImageFrame<TColor> source)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> new ImageFrame<TColor>(source);
}
}

25
src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f</ProjectGuid>
<RootNamespace>ImageSharp.Formats.Gif</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

0
src/ImageSharp/Formats/Gif/LzwDecoder.cs → src/ImageSharp.Formats.Gif/LzwDecoder.cs

0
src/ImageSharp/Formats/Gif/LzwEncoder.cs → src/ImageSharp.Formats.Gif/LzwEncoder.cs

0
src/ImageSharp/Formats/Gif/PackedField.cs → src/ImageSharp.Formats.Gif/PackedField.cs

40
src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs

@ -0,0 +1,40 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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")]

0
src/ImageSharp/Formats/Gif/README.md → src/ImageSharp.Formats.Gif/README.md

0
src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs → src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs

0
src/ImageSharp/Formats/Gif/Sections/GifImageDescriptor.cs → src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs

0
src/ImageSharp/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs → src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs

73
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"
}
}
}
}

29
src/ImageSharp.Formats.Jpeg/BootstrapperExtensions.cs

@ -0,0 +1,29 @@
// <copyright file="BootstrapperExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class BootstrapperExtensions
{
/// <summary>
/// Adds the Jpeg format.
/// </summary>
/// <param name="bootstrapper">The bootstrapper.</param>
/// <returns>The Bootstrapper</returns>
public static Bootstrapper AddJpegFormat(this Bootstrapper bootstrapper)
{
bootstrapper.AddImageFormat(new JpegFormat());
return bootstrapper;
}
}
}

0
src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.cs → src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs

0
src/ImageSharp/Formats/Jpg/Components/Block8x8F.Generated.tt → src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt

0
src/ImageSharp/Formats/Jpg/Components/Block8x8F.cs → src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs

0
src/ImageSharp/Formats/Jpg/Components/BlockQuad.cs → src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs

0
src/ImageSharp/Formats/Jpg/Components/DCT.cs → src/ImageSharp.Formats.Jpeg/Components/DCT.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/Bits.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/Bytes.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/Component.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/HuffmanTree.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/JpegPixelArea.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/JpegScanDecoder.md → src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md

0
src/ImageSharp/Formats/Jpg/Components/Decoder/Scan.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/Scan.cs

0
src/ImageSharp/Formats/Jpg/Components/Decoder/YCbCrImage.cs → src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs

0
src/ImageSharp/Formats/Jpg/Components/Encoder/HuffIndex.cs → src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs

0
src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanLut.cs → src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs

0
src/ImageSharp/Formats/Jpg/Components/Encoder/HuffmanSpec.cs → src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs

0
src/ImageSharp/Formats/Jpg/Components/Encoder/QuantIndex.cs → src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs

63
src/ImageSharp.Formats.Jpeg/Helpers/ComparableExtensions.cs

@ -0,0 +1,63 @@
// <copyright file="ComparableExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
/// <summary>
/// Extension methods for classes that implement <see cref="IComparable{T}"/>.
/// </summary>
internal static class ComparableExtensions
{
/// <summary>
/// Restricts a <see cref="int"/> to be within a specified range.
/// </summary>
/// <param name="value">The The value to clamp.</param>
/// <param name="min">The minimum value. If value is less than min, min will be returned.</param>
/// <param name="max">The maximum value. If value is greater than max, max will be returned.</param>
/// <returns>
/// The <see cref="int"/> representing the clamped value.
/// </returns>
public static int Clamp(this int value, int min, int max)
{
if (value > max)
{
return max;
}
if (value < min)
{
return min;
}
return value;
}
/// <summary>
/// Restricts a <see cref="float"/> to be within a specified range.
/// </summary>
/// <param name="value">The The value to clamp.</param>
/// <param name="min">The minimum value. If value is less than min, min will be returned.</param>
/// <param name="max">The maximum value. If value is greater than max, max will be returned.</param>
/// <returns>
/// The <see cref="float"/> representing the clamped value.
/// </returns>
public static float Clamp(this float value, float min, float max)
{
if (value > max)
{
return max;
}
if (value < min)
{
return min;
}
return value;
}
}
}

33
src/ImageSharp.Formats.Jpeg/ImageExtensions.cs

@ -0,0 +1,33 @@
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the jpeg format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to. Between 1 and 100.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// </returns>
public static Image<TColor> SaveAsJpeg<TColor>(this Image<TColor> source, Stream stream, int quality = 75)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> source.Save(stream, new JpegEncoder { Quality = quality });
}
}

25
src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>7213767c-0003-41ca-ab18-0223cfa7ce4b</ProjectGuid>
<RootNamespace>ImageSharp.Formats</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

0
src/ImageSharp/Formats/Jpg/JpegConstants.cs → src/ImageSharp.Formats.Jpeg/JpegConstants.cs

0
src/ImageSharp/Formats/Jpg/JpegDecoder.cs → src/ImageSharp.Formats.Jpeg/JpegDecoder.cs

0
src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs → src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs

0
src/ImageSharp/Formats/Jpg/JpegEncoder.cs → src/ImageSharp.Formats.Jpeg/JpegEncoder.cs

0
src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs → src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs

0
src/ImageSharp/Formats/Jpg/JpegFormat.cs → src/ImageSharp.Formats.Jpeg/JpegFormat.cs

0
src/ImageSharp/Formats/Jpg/JpegSubsample.cs → src/ImageSharp.Formats.Jpeg/JpegSubsample.cs

40
src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs

@ -0,0 +1,40 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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")]

0
src/ImageSharp/Formats/Jpg/README.md → src/ImageSharp.Formats.Jpeg/README.md

0
src/ImageSharp/Formats/Jpg/UnzigData.cs → src/ImageSharp.Formats.Jpeg/UnzigData.cs

0
src/ImageSharp/Formats/Jpg/Utils/JpegUtils.cs → src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs

0
src/ImageSharp/Formats/Jpg/Utils/MutableSpan.cs → src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs

0
src/ImageSharp/Formats/Jpg/Utils/MutableSpanExtensions.cs → src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs

73
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"
}
}
}
}

29
src/ImageSharp.Formats.Png/BootstrapperExtensions.cs

@ -0,0 +1,29 @@
// <copyright file="BootstrapperExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class BootstrapperExtensions
{
/// <summary>
/// Adds the Png format.
/// </summary>
/// <param name="bootstrapper">The bootstrapper.</param>
/// <returns>The Bootstrapper</returns>
public static Bootstrapper AddPngFormat(this Bootstrapper bootstrapper)
{
bootstrapper.AddImageFormat(new PngFormat());
return bootstrapper;
}
}
}

0
src/ImageSharp/Formats/Png/Filters/AverageFilter.cs → src/ImageSharp.Formats.Png/Filters/AverageFilter.cs

0
src/ImageSharp/Formats/Png/Filters/FilterType.cs → src/ImageSharp.Formats.Png/Filters/FilterType.cs

0
src/ImageSharp/Formats/Png/Filters/NoneFilter.cs → src/ImageSharp.Formats.Png/Filters/NoneFilter.cs

0
src/ImageSharp/Formats/Png/Filters/PaethFilter.cs → src/ImageSharp.Formats.Png/Filters/PaethFilter.cs

0
src/ImageSharp/Formats/Png/Filters/SubFilter.cs → src/ImageSharp.Formats.Png/Filters/SubFilter.cs

0
src/ImageSharp/Formats/Png/Filters/UpFilter.cs → src/ImageSharp.Formats.Png/Filters/UpFilter.cs

45
src/ImageSharp.Formats.Png/Helpers/ByteExtensions.cs

@ -0,0 +1,45 @@
// <copyright file="ByteExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="byte"/> struct.
/// </summary>
internal static class ByteExtensions
{
/// <summary>
/// Optimized <see cref="T:byte[]"/> reversal algorithm.
/// </summary>
/// <param name="source">The byte array.</param>
public static void ReverseBytes(this byte[] source)
{
ReverseBytes(source, 0, source.Length);
}
/// <summary>
/// Optimized <see cref="T:byte[]"/> reversal algorithm.
/// </summary>
/// <param name="source">The byte array.</param>
/// <param name="index">The index.</param>
/// <param name="length">The length.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="source"/> is null.</exception>
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--;
}
}
}
}

52
src/ImageSharp.Formats.Png/Helpers/ComparableExtensions.cs

@ -0,0 +1,52 @@
// <copyright file="ComparableExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
/// <summary>
/// Extension methods for classes that implement <see cref="IComparable{T}"/>.
/// </summary>
internal static class ComparableExtensions
{
/// <summary>
/// Restricts a <see cref="int"/> to be within a specified range.
/// </summary>
/// <param name="value">The The value to clamp.</param>
/// <param name="min">The minimum value. If value is less than min, min will be returned.</param>
/// <param name="max">The maximum value. If value is greater than max, max will be returned.</param>
/// <returns>
/// The <see cref="int"/> representing the clamped value.
/// </returns>
public static int Clamp(this int value, int min, int max)
{
if (value > max)
{
return max;
}
if (value < min)
{
return min;
}
return value;
}
/// <summary>
/// Swaps the references to two objects in memory.
/// </summary>
/// <param name="first">The first reference.</param>
/// <param name="second">The second reference.</param>
/// <typeparam name="T">The type of object.</typeparam>
public static void Swap<T>(ref T first, ref T second)
{
T temp = second;
second = first;
first = temp;
}
}
}

30
src/ImageSharp.Formats.Png/Helpers/ImageMaths.cs

@ -0,0 +1,30 @@
// <copyright file="ImageMaths.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.Linq;
using System.Numerics;
/// <summary>
/// Provides common mathematical methods.
/// </summary>
internal static class ImageMaths
{
/// <summary>
/// Returns how many bits are required to store the specified number of colors.
/// Performs a Log2() on the value.
/// </summary>
/// <param name="colors">The number of colors.</param>
/// <returns>
/// The <see cref="int"/>
/// </returns>
public static int GetBitsNeededForColorDepth(int colors)
{
return (int)Math.Ceiling(Math.Log(colors, 2));
}
}
}

46
src/ImageSharp.Formats.Png/Helpers/StreamExtensions.cs

@ -0,0 +1,46 @@
// <copyright file="StreamExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.Buffers;
using System.IO;
/// <summary>
/// Extension methods for the <see cref="Stream"/> type.
/// </summary>
internal static class StreamExtensions
{
/// <summary>
/// Skips the number of bytes in the given stream.
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="count">The count.</param>
public static void Skip(this Stream stream, int count)
{
if (count < 1)
{
return;
}
if (stream.CanSeek)
{
stream.Position += count;
}
else
{
byte[] foo = ArrayPool<byte>.Shared.Rent(count);
try
{
stream.Read(foo, 0, count);
}
finally
{
ArrayPool<byte>.Shared.Return(foo);
}
}
}
}
}

35
src/ImageSharp.Formats.Png/ImageExtensions.cs

@ -0,0 +1,35 @@
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the png format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">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.
/// </param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// </returns>
public static Image<TColor> SaveAsPng<TColor>(this Image<TColor> source, Stream stream, int quality = int.MaxValue)
where TColor : struct, IPackedPixel, IEquatable<TColor>
=> source.Save(stream, new PngEncoder { Quality = quality });
}
}

25
src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>556abdcf-ed93-4327-be98-f6815f78b9b8</ProjectGuid>
<RootNamespace>ImageSharp.Formats.Png</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

0
src/ImageSharp/Formats/Png/PngChunk.cs → src/ImageSharp.Formats.Png/PngChunk.cs

0
src/ImageSharp/Formats/Png/PngChunkTypes.cs → src/ImageSharp.Formats.Png/PngChunkTypes.cs

0
src/ImageSharp/Formats/Png/PngColorType.cs → src/ImageSharp.Formats.Png/PngColorType.cs

0
src/ImageSharp/Formats/Png/PngDecoder.cs → src/ImageSharp.Formats.Png/PngDecoder.cs

0
src/ImageSharp/Formats/Png/PngDecoderCore.cs → src/ImageSharp.Formats.Png/PngDecoderCore.cs

0
src/ImageSharp/Formats/Png/PngEncoder.cs → src/ImageSharp.Formats.Png/PngEncoder.cs

0
src/ImageSharp/Formats/Png/PngEncoderCore.cs → src/ImageSharp.Formats.Png/PngEncoderCore.cs

0
src/ImageSharp/Formats/Png/PngFormat.cs → src/ImageSharp.Formats.Png/PngFormat.cs

0
src/ImageSharp/Formats/Png/PngHeader.cs → src/ImageSharp.Formats.Png/PngHeader.cs

0
src/ImageSharp/Formats/Png/PngInterlaceMode.cs → src/ImageSharp.Formats.Png/PngInterlaceMode.cs

40
src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs

@ -0,0 +1,40 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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")]

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save