mirror of https://github.com/SixLabors/ImageSharp
15 changed files with 258 additions and 326 deletions
@ -1,120 +1,120 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Description>A cross-platform library for the processing of image files; written in C#</Description> |
|||
<AssemblyTitle>SixLabors.ImageSharp</AssemblyTitle> |
|||
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> |
|||
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> |
|||
<Authors>Six Labors and contributors</Authors> |
|||
<TargetFrameworks>netstandard1.1;netstandard1.3;netstandard2.0</TargetFrameworks> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|||
<AssemblyName>SixLabors.ImageSharp</AssemblyName> |
|||
<PackageId>SixLabors.ImageSharp</PackageId> |
|||
<PackageTags>Image Resize Crop Gif Jpg Jpeg Bitmap Png Core</PackageTags> |
|||
<PackageIconUrl>https://raw.githubusercontent.com/SixLabors/ImageSharp/master/build/icons/imagesharp-logo-128.png</PackageIconUrl> |
|||
<PackageProjectUrl>https://github.com/SixLabors/ImageSharp</PackageProjectUrl> |
|||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl> |
|||
<RepositoryType>git</RepositoryType> |
|||
<RepositoryUrl>https://github.com/SixLabors/ImageSharp</RepositoryUrl> |
|||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute> |
|||
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute> |
|||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> |
|||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> |
|||
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute> |
|||
<DebugType Condition="$(codecov) != ''">full</DebugType> |
|||
<DebugType Condition="$(codecov) == ''">portable</DebugType> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<Features>IOperation</Features> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0004" /> |
|||
<AdditionalFiles Include="..\..\stylecop.json" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004"> |
|||
<PrivateAssets>All</PrivateAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="System.Buffers" Version="4.4.0" /> |
|||
<PackageReference Include="System.Memory" Version="4.4.0-preview2-25405-01" /> |
|||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' OR '$(TargetFramework)' == 'netstandard1.3'"> |
|||
<PackageReference Include="System.IO.Compression" Version="4.3.0" /> |
|||
<PackageReference Include="System.Numerics.Vectors" Version="4.4.0" /> |
|||
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" /> |
|||
<PackageReference Include="System.ValueTuple" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> |
|||
<RootNamespace>SixLabors.ImageSharp</RootNamespace> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<None Update="Formats\Jpeg\Common\Block8x8F.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Block8x8F.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="Formats\Jpeg\Components\Block8x8F.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Block8x8F.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\Generated\PixelOperations{TPixel}.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>PixelOperations{TPixel}.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\Generated\Rgba32.PixelOperations.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Rgba32.PixelOperations.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\PixelBlenders\PorterDuffFunctions.Generated.tt"> |
|||
<LastGenOutput>PorterDuffFunctions.Generated.cs</LastGenOutput> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
</None> |
|||
<None Update="PixelFormats\PixelBlenders\DefaultPixelBlenders.Generated.tt"> |
|||
<LastGenOutput>DefaultPixelBlenders.Generated.cs</LastGenOutput> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
</None> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Update="Formats\Jpeg\Common\Block8x8F.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Block8x8F.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="Formats\Jpeg\Components\Block8x8F.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Block8x8F.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\Generated\PixelOperations{TPixel}.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>PixelOperations{TPixel}.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\Generated\Rgba32.PixelOperations.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Rgba32.PixelOperations.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\PixelBlenders\DefaultPixelBlenders.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>DefaultPixelBlenders.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\PixelBlenders\PorterDuffFunctions.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>PorterDuffFunctions.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<Description>A cross-platform library for the processing of image files; written in C#</Description> |
|||
<AssemblyTitle>SixLabors.ImageSharp</AssemblyTitle> |
|||
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> |
|||
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> |
|||
<Authors>Six Labors and contributors</Authors> |
|||
<TargetFrameworks>netstandard1.1;netstandard1.3;netstandard2.0</TargetFrameworks> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|||
<AssemblyName>SixLabors.ImageSharp</AssemblyName> |
|||
<PackageId>SixLabors.ImageSharp</PackageId> |
|||
<PackageTags>Image Resize Crop Gif Jpg Jpeg Bitmap Png Core</PackageTags> |
|||
<PackageIconUrl>https://raw.githubusercontent.com/SixLabors/ImageSharp/master/build/icons/imagesharp-logo-128.png</PackageIconUrl> |
|||
<PackageProjectUrl>https://github.com/SixLabors/ImageSharp</PackageProjectUrl> |
|||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl> |
|||
<RepositoryType>git</RepositoryType> |
|||
<RepositoryUrl>https://github.com/SixLabors/ImageSharp</RepositoryUrl> |
|||
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute> |
|||
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute> |
|||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> |
|||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> |
|||
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute> |
|||
<DebugType Condition="$(codecov) != ''">full</DebugType> |
|||
<DebugType Condition="$(codecov) == ''">portable</DebugType> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<Features>IOperation</Features> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0004" /> |
|||
<AdditionalFiles Include="..\..\stylecop.json" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004"> |
|||
<PrivateAssets>All</PrivateAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="System.Buffers" Version="4.4.0" /> |
|||
<PackageReference Include="System.Memory" Version="4.4.0-preview2-25405-01" /> |
|||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' OR '$(TargetFramework)' == 'netstandard1.3'"> |
|||
<PackageReference Include="System.IO.Compression" Version="4.3.0" /> |
|||
<PackageReference Include="System.Numerics.Vectors" Version="4.4.0" /> |
|||
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" /> |
|||
<PackageReference Include="System.ValueTuple" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> |
|||
<RootNamespace>SixLabors.ImageSharp</RootNamespace> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<None Update="Formats\Jpeg\Common\Block8x8F.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Block8x8F.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="Formats\Jpeg\Components\Block8x8F.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Block8x8F.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\Generated\PixelOperations{TPixel}.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>PixelOperations{TPixel}.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\Generated\Rgba32.PixelOperations.Generated.tt"> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
<LastGenOutput>Rgba32.PixelOperations.Generated.cs</LastGenOutput> |
|||
</None> |
|||
<None Update="PixelFormats\PixelBlenders\PorterDuffFunctions.Generated.tt"> |
|||
<LastGenOutput>PorterDuffFunctions.Generated.cs</LastGenOutput> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
</None> |
|||
<None Update="PixelFormats\PixelBlenders\DefaultPixelBlenders.Generated.tt"> |
|||
<LastGenOutput>DefaultPixelBlenders.Generated.cs</LastGenOutput> |
|||
<Generator>TextTemplatingFileGenerator</Generator> |
|||
</None> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Update="Formats\Jpeg\Common\Block8x8F.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Block8x8F.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="Formats\Jpeg\Components\Block8x8F.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Block8x8F.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\Generated\PixelOperations{TPixel}.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>PixelOperations{TPixel}.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\Generated\Rgba32.PixelOperations.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Rgba32.PixelOperations.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\PixelBlenders\DefaultPixelBlenders.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>DefaultPixelBlenders.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
<Compile Update="PixelFormats\PixelBlenders\PorterDuffFunctions.Generated.cs"> |
|||
<DesignTime>True</DesignTime> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>PorterDuffFunctions.Generated.tt</DependentUpon> |
|||
</Compile> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,59 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Buffers; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Memory |
|||
{ |
|||
/// <summary>
|
|||
/// Provides a resource pool that enables reusing instances of value type arrays for image data <see cref="T:T[]"/>.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The value type.</typeparam>
|
|||
internal class PixelDataPool<T> |
|||
where T : struct |
|||
{ |
|||
/// <summary>
|
|||
/// The <see cref="ArrayPool{T}"/> which is not kept clean.
|
|||
/// </summary>
|
|||
private static readonly ArrayPool<T> ArrayPool = ArrayPool<T>.Create(CalculateMaxArrayLength(), 50); |
|||
|
|||
/// <summary>
|
|||
/// Rents the pixel array from the pool.
|
|||
/// </summary>
|
|||
/// <param name="minimumLength">The minimum length of the array to return.</param>
|
|||
/// <returns>The <see cref="T:TPixel[]"/></returns>
|
|||
public static T[] Rent(int minimumLength) |
|||
{ |
|||
return ArrayPool.Rent(minimumLength); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the rented pixel array back to the pool.
|
|||
/// </summary>
|
|||
/// <param name="array">The array to return to the buffer pool.</param>
|
|||
public static void Return(T[] array) |
|||
{ |
|||
ArrayPool.Return(array); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Heuristically calculates a reasonable maxArrayLength value for the backing <see cref="ArrayPool{T}"/>.
|
|||
/// </summary>
|
|||
/// <returns>The maxArrayLength value</returns>
|
|||
internal static int CalculateMaxArrayLength() |
|||
{ |
|||
// ReSharper disable once SuspiciousTypeConversion.Global
|
|||
if (default(T) is IPixel) |
|||
{ |
|||
const int MaximumExpectedImageSize = 16384 * 16384; |
|||
return MaximumExpectedImageSize; |
|||
} |
|||
else |
|||
{ |
|||
const int MaxArrayLength = 1024 * 1024; // Match default pool.
|
|||
return MaxArrayLength; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue