mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
91 changed files with 1132 additions and 1353 deletions
@ -0,0 +1,113 @@ |
|||
|
|||
# lets calulat the correct version here |
|||
$fallbackVersion = "1.0.0"; |
|||
$version = '' |
|||
|
|||
$tagRegex = '^v?(\d+\.\d+\.\d+)(-([a-zA-Z]+)\.?(\d*))?$' |
|||
|
|||
# we are running on the build server |
|||
$isVersionTag = $env:APPVEYOR_REPO_TAG_NAME -match $tagRegex |
|||
|
|||
if($isVersionTag){ |
|||
|
|||
Write-Debug "Building commit tagged with a compatable version number" |
|||
|
|||
$version = $matches[1] |
|||
$postTag = $matches[3] |
|||
$count = $matches[4] |
|||
Write-Debug "version number: ${version} post tag: ${postTag} count: ${count}" |
|||
if("$postTag" -ne ""){ |
|||
$version = "${version}-${postTag}" |
|||
} |
|||
if("$count" -ne ""){ |
|||
# for consistancy with previous releases we pad the counter to only 4 places |
|||
$padded = $count.Trim().Trim('0').PadLeft(4,"0"); |
|||
Write-Debug "count '$count', padded '${padded}'" |
|||
|
|||
$version = "${version}${padded}" |
|||
} |
|||
}else { |
|||
|
|||
Write-Debug "Untagged" |
|||
$lastTag = (git tag --list --sort=-taggerdate) | Out-String |
|||
$list = $lastTag.Split("`n") |
|||
foreach ($tag in $list) { |
|||
|
|||
Write-Debug "testing ${tag}" |
|||
$tag = $tag.Trim(); |
|||
if($tag -match $tagRegex){ |
|||
Write-Debug "matched ${tag}" |
|||
$version = $matches[1]; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if("$version" -eq ""){ |
|||
$version = $fallbackVersion |
|||
Write-Debug "Failed to discover base version Fallback to '${version}'" |
|||
}else{ |
|||
|
|||
Write-Debug "Discovered base version from tags '${version}'" |
|||
} |
|||
|
|||
$buildNumber = $env:APPVEYOR_BUILD_NUMBER |
|||
|
|||
# build number replacement is padded to 6 places |
|||
$buildNumber = "$buildNumber".Trim().Trim('0').PadLeft(6,"0"); |
|||
if("$env:APPVEYOR_PULL_REQUEST_NUMBER" -ne ""){ |
|||
Write-Debug "building a PR" |
|||
|
|||
$prNumber = "$env:APPVEYOR_PULL_REQUEST_NUMBER".Trim().Trim('0').PadLeft(5,"0"); |
|||
# this is a PR |
|||
$version = "${version}-PullRequest${prNumber}${buildNumber}"; |
|||
}else{ |
|||
Write-Debug "building a branch commit" |
|||
|
|||
# this is a general branch commit |
|||
$branch = $env:APPVEYOR_REPO_BRANCH |
|||
|
|||
if("$branch" -eq ""){ |
|||
$branch = ((git rev-parse --abbrev-ref HEAD) | Out-String).Trim() |
|||
|
|||
if("$branch" -eq ""){ |
|||
$branch = "unknown" |
|||
} |
|||
} |
|||
|
|||
$branch = $branch.Replace("/","-").ToLower() |
|||
|
|||
if($branch.ToLower() -eq "master"){ |
|||
$branch = "dev" |
|||
} |
|||
|
|||
$version = "${version}-${branch}${buildNumber}"; |
|||
} |
|||
} |
|||
|
|||
if("$env:APPVEYOR_API_URL" -ne ""){ |
|||
# update appveyor build number for this build |
|||
Invoke-RestMethod -Method "PUT" ` |
|||
-Uri "${env:APPVEYOR_API_URL}api/build" ` |
|||
-Body "{version:'${version}'}" ` |
|||
-ContentType "application/json" |
|||
} |
|||
|
|||
Write-Host "Building version '${version}'" |
|||
dotnet restore /p:packageversion=$version |
|||
|
|||
Write-Host "Building projects" |
|||
dotnet build -c Release /p:packageversion=$version |
|||
|
|||
if ($LASTEXITCODE ){ Exit $LASTEXITCODE } |
|||
|
|||
if ( $env:CI -ne "True") { |
|||
dotnet test ./tests/ImageSharp.Tests/ImageSharp.Tests.csproj --no-build -c Release |
|||
} |
|||
if ($LASTEXITCODE ){ Exit $LASTEXITCODE } |
|||
|
|||
Write-Host "Packaging projects" |
|||
dotnet pack ./src/ImageSharp/ -c Release --output ../../artifacts --no-build /p:packageversion=$version |
|||
if ($LASTEXITCODE ){ Exit $LASTEXITCODE } |
|||
|
|||
dotnet pack ./src/ImageSharp.Drawing/ -c Release --output ../../artifacts --no-build /p:packageversion=$version |
|||
if ($LASTEXITCODE ){ Exit $LASTEXITCODE } |
|||
@ -1,31 +0,0 @@ |
|||
# to create a new package you create a new release/tag |
|||
# in github appveyor will build it without the -cixxx tag |
|||
# it will then be deployable cleanly to nuget.org |
|||
|
|||
branches: |
|||
master: |
|||
tag: ci |
|||
mode: ContinuousDeployment |
|||
increment: Minor |
|||
prevent-increment-of-merged-branch-version: false |
|||
track-merge-target: true |
|||
pull-request: |
|||
regex: (pull|pull\-requests|pr)[/-] |
|||
mode: ContinuousDelivery |
|||
tag: PullRequest |
|||
increment: Inherit |
|||
prevent-increment-of-merged-branch-version: false |
|||
tag-number-pattern: '[/-](?<number>\d+)[-/]' |
|||
track-merge-target: false |
|||
tracks-release-branches: false |
|||
is-release-branch: false |
|||
otherbranches: |
|||
regex: '.*' |
|||
mode: ContinuousDeployment |
|||
tag: ci |
|||
increment: Patch |
|||
prevent-increment-of-merged-branch-version: false |
|||
track-merge-target: true |
|||
is-release-branch: false |
|||
ignore: |
|||
sha: [] |
|||
@ -1,54 +1,54 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> |
|||
<AssemblyTitle>SixLabors.ImageSharp.Drawing</AssemblyTitle> |
|||
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> |
|||
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> |
|||
<Authors>Six Labor and contributors</Authors> |
|||
<TargetFramework>netstandard1.1</TargetFramework> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|||
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName> |
|||
<PackageId>SixLabors.ImageSharp.Drawing</PackageId> |
|||
<PackageTags>Image Draw Shape Path Font</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> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> |
|||
<AdditionalFiles Include="..\..\stylecop.json" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\ImageSharp\ImageSharp.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0003" /> |
|||
<PackageReference Include="SixLabors.Shapes.Text" Version="1.0.0-beta0002" /> |
|||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0002" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004"> |
|||
<PrivateAssets>All</PrivateAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> |
|||
<RootNamespace>SixLabors.ImageSharp.Drawing</RootNamespace> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> |
|||
<AssemblyTitle>SixLabors.ImageSharp.Drawing</AssemblyTitle> |
|||
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> |
|||
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> |
|||
<Authors>SixLabors and contributors</Authors> |
|||
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|||
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName> |
|||
<PackageId>SixLabors.ImageSharp.Drawing</PackageId> |
|||
<PackageTags>Image Draw Shape Path Font</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> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\ImageSharp\ImageSharp.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0004" /> |
|||
<PackageReference Include="SixLabors.Shapes.Text" Version="1.0.0-beta0003" /> |
|||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0003" /> |
|||
<AdditionalFiles Include="..\..\stylecop.json" /> |
|||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004"> |
|||
<PrivateAssets>All</PrivateAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
<PropertyGroup> |
|||
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> |
|||
<RootNamespace>SixLabors.ImageSharp.Drawing</RootNamespace> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -1,291 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp |
|||
{ |
|||
/// <summary>
|
|||
/// Provides single-precision floating point constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
|
|||
/// </summary>
|
|||
// ReSharper disable InconsistentNaming
|
|||
internal static class MathF |
|||
{ |
|||
/// <summary>
|
|||
/// Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.
|
|||
/// </summary>
|
|||
public const float PI = (float)Math.PI; |
|||
|
|||
/// <summary>
|
|||
/// Returns the absolute value of a single-precision floating-point number.
|
|||
/// </summary>
|
|||
/// <param name="f">
|
|||
/// A number that is greater than or equal to <see cref="F:System.Single.MinValue" />, but less than or equal to <see cref="F:System.Single.MaxValue" />.
|
|||
/// </param>
|
|||
/// <returns>
|
|||
/// A single-precision floating-point number, x, such that 0 ≤ x ≤<see cref="F:System.Single.MaxValue" />.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Abs(float f) |
|||
{ |
|||
return Math.Abs(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the angle whose tangent is the quotient of two specified numbers.
|
|||
/// </summary>
|
|||
/// <param name="y">The y coordinate of a point.</param>
|
|||
/// <param name="x">The x coordinate of a point.</param>
|
|||
/// <returns>
|
|||
/// An angle, θ, measured in radians, such that -π≤θ≤π, and tan(θ) = y / x, where
|
|||
/// (x, y) is a point in the Cartesian plane. Observe the following: For (x, y) in
|
|||
/// quadrant 1, 0 < θ < π/2.For (x, y) in quadrant 2, π/2 < θ≤π.For (x, y) in quadrant
|
|||
/// 3, -π < θ < -π/2.For (x, y) in quadrant 4, -π/2 < θ < 0.For points on the boundaries
|
|||
/// of the quadrants, the return value is the following:If y is 0 and x is not negative,
|
|||
/// θ = 0.If y is 0 and x is negative, θ = π.If y is positive and x is 0, θ = π/2.If
|
|||
/// y is negative and x is 0, θ = -π/2.If y is 0 and x is 0, θ = 0. If x or y is
|
|||
/// <see cref="F:System.Single.NaN"/>, or if x and y are either <see cref="F:System.Single.PositiveInfinity"/> or
|
|||
/// <see cref="F:System.Single.NegativeInfinity"/>, the method returns <see cref="F:System.Single.NaN"/>.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Atan2(float y, float x) |
|||
{ |
|||
return (float)Math.Atan2(y, x); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the smallest integral value that is greater than or equal to the specified single-precision floating-point number.
|
|||
/// </summary>
|
|||
/// <param name="f">A single-precision floating-point number.</param>
|
|||
/// <returns>
|
|||
/// The smallest integral value that is greater than or equal to <paramref name="f" />.
|
|||
/// If <paramref name="f" /> is equal to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NegativeInfinity" />,
|
|||
/// or <see cref="F:System.Single.PositiveInfinity" />, that value is returned.
|
|||
/// Note that this method returns a <see cref="T:System.Single" /> instead of an integral type.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Ceiling(float f) |
|||
{ |
|||
return (float)Math.Ceiling(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the cosine of the specified angle.
|
|||
/// </summary>
|
|||
/// <param name="f">An angle, measured in radians.</param>
|
|||
/// <returns>
|
|||
/// The cosine of <paramref name="f"/>. If <paramref name="f"/> is equal to <see cref="F:System.Float.NaN"/>, <see cref="F:System.Float.NegativeInfinity"/>,
|
|||
/// or <see cref="F:System.Float.PositiveInfinity"/>, this method returns <see cref="F:System.Float.NaN"/>.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Cos(float f) |
|||
{ |
|||
return (float)Math.Cos(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Converts a degree (360-periodic) angle to a radian (2*Pi-periodic) angle.
|
|||
/// </summary>
|
|||
/// <param name="degree">The angle in degrees.</param>
|
|||
/// <returns>
|
|||
/// The <see cref="float"/> representing the degree as radians.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float DegreeToRadian(float degree) |
|||
{ |
|||
return degree * (PI / 180F); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns e raised to the specified power.
|
|||
/// </summary>
|
|||
/// <param name="f">A number specifying a power.</param>
|
|||
/// <returns>
|
|||
/// The number e raised to the power <paramref name="f" />.
|
|||
/// If <paramref name="f" /> equals <see cref="F:System.Single.NaN" /> or <see cref="F:System.Single.PositiveInfinity" />, that value is returned.
|
|||
/// If <paramref name="f" /> equals <see cref="F:System.Single.NegativeInfinity" />, 0 is returned.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Exp(float f) |
|||
{ |
|||
return (float)Math.Exp(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the largest integer less than or equal to the specified single-precision floating-point number.
|
|||
/// </summary>
|
|||
/// <param name="f">A single-precision floating-point number. </param>
|
|||
/// <returns>
|
|||
/// The largest integer less than or equal to <paramref name="f" />.
|
|||
/// If <paramref name="f" /> is equal to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NegativeInfinity" />,
|
|||
/// or <see cref="F:System.Single.PositiveInfinity" />, that value is returned.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Floor(float f) |
|||
{ |
|||
return (float)Math.Floor(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the larger of two single-precision floating-point numbers.
|
|||
/// </summary>
|
|||
/// <param name="val1">The first of two single-precision floating-point numbers to compare. </param>
|
|||
/// <param name="val2">The second of two single-precision floating-point numbers to compare. </param>
|
|||
/// <returns>
|
|||
/// Parameter <paramref name="val1" /> or <paramref name="val2" />, whichever is larger.
|
|||
/// If <paramref name="val1" />, or <paramref name="val2" />, or both <paramref name="val1" /> and <paramref name="val2" /> are
|
|||
/// equal to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NaN" /> is returned.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Max(float val1, float val2) |
|||
{ |
|||
return Math.Max(val1, val2); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the smaller of two single-precision floating-point numbers.
|
|||
/// </summary>
|
|||
/// <param name="val1">The first of two single-precision floating-point numbers to compare. </param>
|
|||
/// <param name="val2">The second of two single-precision floating-point numbers to compare. </param>
|
|||
/// <returns>
|
|||
/// Parameter <paramref name="val1" /> or <paramref name="val2" />, whichever is smaller.
|
|||
/// If <paramref name="val1" />, <paramref name="val2" />, or both <paramref name="val1" /> and <paramref name="val2" /> are equal
|
|||
/// to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NaN" /> is returned.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Min(float val1, float val2) |
|||
{ |
|||
return Math.Min(val1, val2); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns a specified number raised to the specified power.
|
|||
/// </summary>
|
|||
/// <param name="x">A single-precision floating-point number to be raised to a power. </param>
|
|||
/// <param name="y">A single-precision floating-point number that specifies a power. </param>
|
|||
/// <returns>The number <paramref name="x" /> raised to the power <paramref name="y" />.</returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Pow(float x, float y) |
|||
{ |
|||
return (float)Math.Pow(x, y); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Converts a radian (2*Pi-periodic) angle to a degree (360-periodic) angle.
|
|||
/// </summary>
|
|||
/// <param name="radian">The angle in radians.</param>
|
|||
/// <returns>
|
|||
/// The <see cref="float"/> representing the degree as radians.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float RadianToDegree(float radian) |
|||
{ |
|||
return radian / (PI / 180F); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Rounds a single-precision floating-point value to the nearest integral value.
|
|||
/// </summary>
|
|||
/// <param name="f">A single-precision floating-point number to be rounded.</param>
|
|||
/// <returns>
|
|||
/// The integer nearest <paramref name="f" />.
|
|||
/// If the fractional component of <paramref name="f" /> is halfway between two integers, one of which is even and the other odd, then the even number is returned.
|
|||
/// Note that this method returns a <see cref="T:System.Single" /> instead of an integral type.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Round(float f) |
|||
{ |
|||
return (float)Math.Round(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Rounds a single-precision floating-point value to the nearest integer.
|
|||
/// A parameter specifies how to round the value if it is midway between two numbers.
|
|||
/// </summary>
|
|||
/// <param name="f">A single-precision floating-point number to be rounded. </param>
|
|||
/// <param name="mode">Specification for how to round <paramref name="f" /> if it is midway between two other numbers.</param>
|
|||
/// <returns>
|
|||
/// The integer nearest <paramref name="f" />. If <paramref name="f" /> is halfway between two integers, one of which is even
|
|||
/// and the other odd, then <paramref name="mode" /> determines which of the two is returned.
|
|||
/// Note that this method returns a <see cref="T:System.Single" /> instead of an integral type.
|
|||
/// </returns>
|
|||
/// <exception cref="T:System.ArgumentException">
|
|||
/// <paramref name="mode" /> is not a valid value of <see cref="T:System.MidpointRounding" />.</exception>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Round(float f, MidpointRounding mode) |
|||
{ |
|||
return (float)Math.Round(f, mode); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the sine of the specified angle.
|
|||
/// </summary>
|
|||
/// <param name="f">An angle, measured in radians.</param>
|
|||
/// <returns>
|
|||
/// The sine of <paramref name="f" />.
|
|||
/// If <paramref name="f" /> is equal to <see cref="F:System.Single.NaN" />, <see cref="F:System.Single.NegativeInfinity" />,
|
|||
/// or <see cref="F:System.Single.PositiveInfinity" />, this method returns <see cref="F:System.Single.NaN" />.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Sin(float f) |
|||
{ |
|||
return (float)Math.Sin(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the result of a normalized sine cardinal function for the given value.
|
|||
/// SinC(x) = sin(pi*x)/(pi*x).
|
|||
/// </summary>
|
|||
/// <param name="f">A single-precision floating-point number to calculate the result for.</param>
|
|||
/// <returns>
|
|||
/// The sine cardinal of <paramref name="f" />.
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float SinC(float f) |
|||
{ |
|||
if (Abs(f) > Constants.Epsilon) |
|||
{ |
|||
f *= PI; |
|||
return Clean(Sin(f) / f); |
|||
} |
|||
|
|||
return 1F; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the square root of a specified number.
|
|||
/// </summary>
|
|||
/// <param name="f">The number whose square root is to be found.</param>
|
|||
/// <returns>
|
|||
/// One of the values in the following table.
|
|||
/// <paramref name="f" /> parameter Return value Zero or positive The positive square root of <paramref name="f" />.
|
|||
/// Negative <see cref="F:System.Single.NaN" />Equals <see cref="F:System.Single.NaN" />
|
|||
/// <see cref="F:System.Single.NaN" />Equals <see cref="F:System.Single.PositiveInfinity" />
|
|||
/// <see cref="F:System.Single.PositiveInfinity" />
|
|||
/// </returns>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static float Sqrt(float f) |
|||
{ |
|||
return (float)Math.Sqrt(f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Ensures that any passed float is correctly rounded to zero
|
|||
/// </summary>
|
|||
/// <param name="x">The value to clean.</param>
|
|||
/// <returns>
|
|||
/// The <see cref="float"/>
|
|||
/// </returns>.
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
private static float Clean(float x) |
|||
{ |
|||
if (Abs(x) < Constants.Epsilon) |
|||
{ |
|||
return 0F; |
|||
} |
|||
|
|||
return x; |
|||
} |
|||
} |
|||
} |
|||
@ -1,118 +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</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-beta0003" /> |
|||
<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.Threading.Tasks.Parallel" Version="4.3.0" /> |
|||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.4.0" /> |
|||
<PackageReference Include="System.Numerics.Vectors" Version="4.4.0" /> |
|||
<PackageReference Include="System.IO.Compression" 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,79 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
/// <summary>
|
|||
/// Extension methods for copying single pixel data into byte Spans.
|
|||
/// TODO: This utility class exists for legacy reasons. Need to do a lot of chore work to remove it (mostly in test classes).
|
|||
/// </summary>
|
|||
internal static class PixelConversionExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Expands the packed representation into a given byte array.
|
|||
/// Output is expanded to X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Rgb24"/>
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The pixel type.</typeparam>
|
|||
/// <param name="pixel">The pixel to copy the data from.</param>
|
|||
/// <param name="bytes">The bytes to set the color in.</param>
|
|||
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static void ToXyzBytes<TPixel>(this TPixel pixel, Span<byte> bytes, int startIndex) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
ref Rgb24 dest = ref bytes.GetRgb24(startIndex); |
|||
pixel.ToRgb24(ref dest); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Expands the packed representation into a given byte array.
|
|||
/// Output is expanded to X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Rgba32"/>
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The pixel type.</typeparam>
|
|||
/// <param name="pixel">The pixel to copy the data from.</param>
|
|||
/// <param name="bytes">The bytes to set the color in.</param>
|
|||
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static void ToXyzwBytes<TPixel>(this TPixel pixel, Span<byte> bytes, int startIndex) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
ref Rgba32 dest = ref Unsafe.As<byte, Rgba32>(ref bytes[startIndex]); |
|||
pixel.ToRgba32(ref dest); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Expands the packed representation into a given byte array.
|
|||
/// Output is expanded to Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Bgr24"/>
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The pixel type.</typeparam>
|
|||
/// <param name="pixel">The pixel to copy the data from.</param>
|
|||
/// <param name="bytes">The bytes to set the color in.</param>
|
|||
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static void ToZyxBytes<TPixel>(this TPixel pixel, Span<byte> bytes, int startIndex) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
ref Bgr24 dest = ref Unsafe.As<byte, Bgr24>(ref bytes[startIndex]); |
|||
pixel.ToBgr24(ref dest); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Expands the packed representation into a given byte array.
|
|||
/// Output is expanded to Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Bgra32"/>
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The pixel type.</typeparam>
|
|||
/// <param name="pixel">The pixel to copy the data from.</param>
|
|||
/// <param name="bytes">The bytes to set the color in.</param>
|
|||
/// <param name="startIndex">The starting index of the <paramref name="bytes"/>.</param>
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static void ToZyxwBytes<TPixel>(this TPixel pixel, Span<byte> bytes, int startIndex) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
ref Bgra32 dest = ref Unsafe.As<byte, Bgra32>(ref bytes[startIndex]); |
|||
pixel.ToBgra32(ref dest); |
|||
} |
|||
} |
|||
} |
|||
@ -1,123 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Helpers |
|||
{ |
|||
public class MathFTests |
|||
{ |
|||
[Fact] |
|||
public void MathF_PI_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.PI, (float)Math.PI); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Ceililng_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Ceiling(0.3333F), (float)Math.Ceiling(0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Cos_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Cos(0.3333F), (float)Math.Cos(0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Abs_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Abs(-0.3333F), (float)Math.Abs(-0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Atan2_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Atan2(1.2345F, 1.2345F), (float)Math.Atan2(1.2345F, 1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Exp_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Exp(1.2345F), (float)Math.Exp(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Floor_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Floor(1.2345F), (float)Math.Floor(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Min_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Min(1.2345F, 5.4321F), (float)Math.Min(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Max_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Max(1.2345F, 5.4321F), (float)Math.Max(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Pow_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Pow(1.2345F, 5.4321F), (float)Math.Pow(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Round_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Round(1.2345F), (float)Math.Round(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Round_With_Midpoint_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Round(1.2345F, MidpointRounding.AwayFromZero), (float)Math.Round(1.2345F, MidpointRounding.AwayFromZero)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Sin_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Sin(1.2345F), (float)Math.Sin(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_SinC_Is_Equal() |
|||
{ |
|||
float f = 1.2345F; |
|||
float expected = 1F; |
|||
if (Math.Abs(f) > Constants.Epsilon) |
|||
{ |
|||
f *= (float)Math.PI; |
|||
float sinC = (float)Math.Sin(f) / f; |
|||
|
|||
expected = Math.Abs(sinC) < Constants.Epsilon ? 0F : sinC; |
|||
} |
|||
|
|||
Assert.Equal(MathF.SinC(1.2345F), expected); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Sqrt_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Sqrt(2F), (float)Math.Sqrt(2F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Convert_Degree_To_Radian() |
|||
{ |
|||
Assert.Equal((float)(Math.PI / 2D), MathF.DegreeToRadian(90F), new FloatRoundingComparer(6)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Convert_Radian_To_Degree() |
|||
{ |
|||
Assert.Equal(60F, MathF.RadianToDegree((float)(Math.PI / 3D)), new FloatRoundingComparer(5)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using SixLabors.Primitives; |
|||
using SixLabors.ImageSharp.Advanced; |
|||
using Xunit; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Issues |
|||
{ |
|||
public class Issue412 |
|||
{ |
|||
[Theory] |
|||
[WithBlankImages(40, 30, PixelTypes.Rgba32)] |
|||
public void AllPixelsExpectedToBeRedWhenAntialisedDisabled<TPixel>(TestImageProvider<TPixel> provider) where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
using (var image = provider.GetImage()) |
|||
{ |
|||
image.Mutate( |
|||
context => |
|||
{ |
|||
for (var i = 0; i < 40; ++i) |
|||
{ |
|||
context.DrawLines( |
|||
NamedColors<TPixel>.Black, |
|||
1, |
|||
new[] |
|||
{ |
|||
new PointF(i, 0.1066f), |
|||
new PointF(i, 10.1066f) |
|||
}, |
|||
new GraphicsOptions(true)); |
|||
|
|||
context.DrawLines( |
|||
NamedColors<TPixel>.Red, |
|||
1, |
|||
new[] |
|||
{ |
|||
new PointF(i, 15.1066f), |
|||
new PointF(i, 25.1066f) |
|||
}, |
|||
new GraphicsOptions(false)); |
|||
} |
|||
}); |
|||
|
|||
image.DebugSave(provider); |
|||
for (var y = 15; y < 25; y++) |
|||
{ |
|||
for (var x = 0; x < 40; x++) |
|||
{ |
|||
|
|||
Assert.True(NamedColors<TPixel>.Red.Equals(image[x, y]), $"expected {NamedColors<TPixel>.Red} but found {image[x, y]} at [{x}, {y}]"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1 +1 @@ |
|||
Subproject commit f99c2ea41419cb3b3e80e5beeab611682252df78 |
|||
Subproject commit dc5479d00b2312f691e6249b9f7765e2316d4a30 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:c108091ffddd87178378656e37a7e975aa69be56376b9105adbbc14fe8d9a010 |
|||
size 707660 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:151d394c7c57a1696fedc32116514b667ad70c4a2c7d34db7c489c17d5755eed |
|||
size 24724 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:0549f4500693cdf7eac8351d8cd64d1093da9e9eaaed923e8c6f00476e350f43 |
|||
size 41721 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:345556b9a0e064412acc3b2ee87a9226113eb65c0a1791c2f855ac3fa1e6b7ad |
|||
size 868269 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:1052660c765aaad52f7bbad779778b5d15fdc3c92ff4b114c89e579c749c7f6b |
|||
size 388517 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:8e90cf157d8e2599598c1bea1b8e2bf262651b004cc6261d87bbb49bd6131034 |
|||
size 257401 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:18f1eb7c5019153f4a0b2de90e7e0f0521193f003fabd6ac31c2f58c2562ae42 |
|||
size 4040 |
|||
Loading…
Reference in new issue