mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
122 changed files with 6995 additions and 9390 deletions
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Argb32 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Argb32> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromArgb32(ReadOnlySpan<Argb32> source, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Argb32> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Argb32> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Argb32> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromArgb32(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Argb32 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Argb32> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromArgb32(ReadOnlySpan<Argb32> source, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToArgb32(ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Bgr24 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Bgr24> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromBgr24(ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Bgr24> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Bgr24> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Bgr24> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgr24(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Bgr24 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Bgr24> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromBgr24(ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToBgr24(ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Bgra32 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Bgra32> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromBgra32(ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Bgra32> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Bgra32> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Bgra32> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromBgra32(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Bgra32 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Bgra32> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromBgra32(ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToBgra32(ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Gray16 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Gray16> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromGray16(ReadOnlySpan<Gray16> source, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Gray16> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Gray16> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Gray16> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Gray16> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Gray16> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Gray16> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Gray16> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Gray16> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray16(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Gray16 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Gray16> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromGray16(ReadOnlySpan<Gray16> source, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToGray16(ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Gray8 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Gray8> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromGray8(ReadOnlySpan<Gray8> source, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Gray8> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Gray8> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Gray8> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Gray8> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Gray8> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Gray8> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Gray8> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Gray8> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Gray8> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromGray8(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Gray8 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Gray8> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromGray8(ReadOnlySpan<Gray8> source, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToGray8(ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Rgb24 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Rgb24> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromRgb24(ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Rgb24> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Rgb24> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Rgb24> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb24(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Rgb24 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Rgb24> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromRgb24(ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToRgb24(ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Rgb48 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Rgb48> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromRgb48(ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Rgb48> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Rgb48> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Rgb48> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgb48(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Rgb48 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Rgb48> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromRgb48(ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToRgb48(ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgba64"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// <auto-generated />
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </content>
|
|||
public partial struct Rgba64 |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Provides optimized overrides for bulk operations.
|
|||
/// </summary>
|
|||
internal class PixelOperations : PixelOperations<Rgba64> |
|||
{ |
|||
/// <inheritdoc />
|
|||
internal override void PackFromRgba64(ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba64(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToArgb32(ReadOnlySpan<Rgba64> sourcePixels, Span<Argb32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgr24(ReadOnlySpan<Rgba64> sourcePixels, Span<Bgr24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToBgra32(ReadOnlySpan<Rgba64> sourcePixels, Span<Bgra32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray8(ReadOnlySpan<Rgba64> sourcePixels, Span<Gray8> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToGray16(ReadOnlySpan<Rgba64> sourcePixels, Span<Gray16> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb24(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb24> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgba32(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba32> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
internal override void ToRgb48(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgb48> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<# |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
#> |
|||
<#@ template debug="false" hostspecific="false" language="C#" #> |
|||
<#@ assembly name="System.Core" #> |
|||
<#@ import namespace="System.Linq" #> |
|||
<#@ import namespace="System.Text" #> |
|||
<#@ import namespace="System.Collections.Generic" #> |
|||
<#@ output extension=".cs" #> |
|||
<# |
|||
void GenerateConvertToMethod(string pixelType) |
|||
{ |
|||
#> |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void To<#=pixelType#>(ReadOnlySpan<Rgba64> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); |
|||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|||
|
|||
dp.PackFromRgba64(sp); |
|||
} |
|||
} |
|||
<# |
|||
} |
|||
#> |
|||
// Copyright (c) Six Labors and contributors. |
|||
// Licensed under the Apache License, Version 2.0. |
|||
|
|||
// <auto-generated /> |
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
/// <content> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </content> |
|||
public partial struct Rgba64 |
|||
{ |
|||
|
|||
/// <summary> |
|||
/// Provides optimized overrides for bulk operations. |
|||
/// </summary> |
|||
internal class PixelOperations : PixelOperations<Rgba64> |
|||
{ |
|||
/// <inheritdoc /> |
|||
internal override void PackFromRgba64(ReadOnlySpan<Rgba64> source, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|||
|
|||
source.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
/// <inheritdoc /> |
|||
internal override void ToRgba64(ReadOnlySpan<Rgba64> sourcePixels, Span<Rgba64> destPixels, int count) |
|||
{ |
|||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|||
|
|||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|||
} |
|||
|
|||
<# |
|||
GenerateConvertToMethod("Argb32"); |
|||
GenerateConvertToMethod("Bgr24"); |
|||
GenerateConvertToMethod("Bgra32"); |
|||
GenerateConvertToMethod("Gray8"); |
|||
GenerateConvertToMethod("Gray16"); |
|||
GenerateConvertToMethod("Rgb24"); |
|||
GenerateConvertToMethod("Rgba32"); |
|||
GenerateConvertToMethod("Rgb48"); |
|||
#> |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
/// <summary>
|
|||
/// Packed pixel type containing a single 16 bit normalized gray values.
|
|||
/// <para>
|
|||
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
|
|||
/// </para>
|
|||
/// </summary>
|
|||
public partial struct Gray16 : IPixel<Gray16>, IPackedVector<ushort> |
|||
{ |
|||
private const float Max = ushort.MaxValue; |
|||
private const float Average = 1 / 3F; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="Gray16"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="luminance">The luminance component</param>
|
|||
public Gray16(ushort luminance) => this.PackedValue = luminance; |
|||
|
|||
/// <inheritdoc />
|
|||
public ushort PackedValue { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="Gray16"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The <see cref="Gray16"/> on the left side of the operand.</param>
|
|||
/// <param name="right">The <see cref="Gray16"/> on the right side of the operand.</param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public static bool operator ==(Gray16 left, Gray16 right) => left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="Gray16"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The <see cref="Gray16"/> on the left side of the operand.</param>
|
|||
/// <param name="right">The <see cref="Gray16"/> on the right side of the operand.</param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public static bool operator !=(Gray16 left, Gray16 right) => !left.Equals(right); |
|||
|
|||
/// <inheritdoc />
|
|||
public PixelOperations<Gray16> CreatePixelOperations() => new PixelOperations(); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromScaledVector4(Vector4 vector) => this.PackFromVector4(vector); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Vector4 ToScaledVector4() => this.ToVector4(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromVector4(Vector4 vector) |
|||
{ |
|||
vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * Max * Average; |
|||
this.PackedValue = (ushort)MathF.Round(vector.X + vector.Y + vector.Z); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Vector4 ToVector4() |
|||
{ |
|||
float scaled = this.PackedValue / Max; |
|||
return new Vector4(scaled, scaled, scaled, 1F); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromArgb32(Argb32 source) |
|||
{ |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.R), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.G), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromBgr24(Bgr24 source) |
|||
{ |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.R), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.G), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromBgra32(Bgra32 source) |
|||
{ |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.R), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.G), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromGray8(Gray8 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromGray16(Gray16 source) => this.PackedValue = source.PackedValue; |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgb24(Rgb24 source) |
|||
{ |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.R), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.G), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgba32(Rgba32 source) |
|||
{ |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.R), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.G), |
|||
ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Rgba32 ToRgba32() |
|||
{ |
|||
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(this.PackedValue); |
|||
return new Rgba32(rgb, rgb, rgb, byte.MaxValue); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgb48(Rgb48 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgba64(Rgba64 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(object obj) => obj is Gray16 other && this.Equals(other); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public bool Equals(Gray16 other) => this.PackedValue.Equals(other.PackedValue); |
|||
|
|||
/// <inheritdoc />
|
|||
public override string ToString() => $"Gray16({this.PackedValue})"; |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public override int GetHashCode() => this.PackedValue.GetHashCode(); |
|||
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
internal void ConvertFromRgbaScaledVector4(Vector4 vector) |
|||
{ |
|||
vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * Max; |
|||
this.PackedValue = ImageMaths.Get16BitBT709Luminance( |
|||
(ushort)MathF.Round(vector.X), |
|||
(ushort)MathF.Round(vector.Y), |
|||
(ushort)MathF.Round(vector.Z)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,152 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
/// <summary>
|
|||
/// Packed pixel type containing a single 8 bit normalized gray values.
|
|||
/// <para>
|
|||
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
|
|||
/// </para>
|
|||
/// </summary>
|
|||
public partial struct Gray8 : IPixel<Gray8>, IPackedVector<byte> |
|||
{ |
|||
private static readonly Vector4 MaxBytes = new Vector4(255F); |
|||
private static readonly Vector4 Half = new Vector4(0.5F); |
|||
private const float Average = 1 / 3F; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="Gray8"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="luminance">The luminance component.</param>
|
|||
public Gray8(byte luminance) => this.PackedValue = luminance; |
|||
|
|||
/// <inheritdoc />
|
|||
public byte PackedValue { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="Gray8"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The <see cref="Gray8"/> on the left side of the operand.</param>
|
|||
/// <param name="right">The <see cref="Gray8"/> on the right side of the operand.</param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public static bool operator ==(Gray8 left, Gray8 right) => left.Equals(right); |
|||
|
|||
/// <summary>
|
|||
/// Compares two <see cref="Gray8"/> objects for equality.
|
|||
/// </summary>
|
|||
/// <param name="left">The <see cref="Gray8"/> on the left side of the operand.</param>
|
|||
/// <param name="right">The <see cref="Gray8"/> on the right side of the operand.</param>
|
|||
/// <returns>
|
|||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|||
/// </returns>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public static bool operator !=(Gray8 left, Gray8 right) => !left.Equals(right); |
|||
|
|||
/// <inheritdoc />
|
|||
public PixelOperations<Gray8> CreatePixelOperations() => new PixelOperations(); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromScaledVector4(Vector4 vector) => this.PackFromVector4(vector); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Vector4 ToScaledVector4() => this.ToVector4(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromVector4(Vector4 vector) |
|||
{ |
|||
vector *= MaxBytes; |
|||
vector += Half; |
|||
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes) * Average; |
|||
this.PackedValue = (byte)(vector.X + vector.Y + vector.Z); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Vector4 ToVector4() |
|||
{ |
|||
float rgb = this.PackedValue / 255F; |
|||
return new Vector4(rgb, rgb, rgb, 1F); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromArgb32(Argb32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromBgr24(Bgr24 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromBgra32(Bgra32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromGray8(Gray8 source) => this.PackedValue = source.PackedValue; |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromGray16(Gray16 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgb24(Rgb24 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgba32(Rgba32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public Rgba32 ToRgba32() => new Rgba32(this.PackedValue, this.PackedValue, this.PackedValue, byte.MaxValue); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgb48(Rgb48 source) |
|||
=> this.PackedValue = ImageMaths.Get8BitBT709Luminance( |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.R), |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.G), |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); |
|||
|
|||
/// <inheritdoc/>
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public void PackFromRgba64(Rgba64 source) |
|||
=> this.PackedValue = ImageMaths.Get8BitBT709Luminance( |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.R), |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.G), |
|||
ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(object obj) => obj is Gray8 other && this.Equals(other); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public bool Equals(Gray8 other) => this.PackedValue.Equals(other.PackedValue); |
|||
|
|||
/// <inheritdoc />
|
|||
public override string ToString() => $"Gray8({this.PackedValue}"; |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
public override int GetHashCode() => this.PackedValue.GetHashCode(); |
|||
|
|||
[MethodImpl(InliningOptions.ShortMethod)] |
|||
internal void ConvertFromRgbaScaledVector4(Vector4 vector) |
|||
{ |
|||
vector *= MaxBytes; |
|||
vector += Half; |
|||
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes); |
|||
this.PackedValue = ImageMaths.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); |
|||
} |
|||
} |
|||
} |
|||
@ -1,721 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.PixelFormats |
|||
{ |
|||
/// <content>
|
|||
/// Provides operators and composition algorithms.
|
|||
/// </content>
|
|||
public partial struct RgbaVector |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F0F8FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector AliceBlue = NamedColors<RgbaVector>.AliceBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FAEBD7.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector AntiqueWhite = NamedColors<RgbaVector>.AntiqueWhite; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00FFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Aqua = NamedColors<RgbaVector>.Aqua; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #7FFFD4.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Aquamarine = NamedColors<RgbaVector>.Aquamarine; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F0FFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Azure = NamedColors<RgbaVector>.Azure; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F5F5DC.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Beige = NamedColors<RgbaVector>.Beige; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFE4C4.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Bisque = NamedColors<RgbaVector>.Bisque; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #000000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Black = NamedColors<RgbaVector>.Black; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFEBCD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector BlanchedAlmond = NamedColors<RgbaVector>.BlanchedAlmond; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #0000FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Blue = NamedColors<RgbaVector>.Blue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #8A2BE2.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector BlueViolet = NamedColors<RgbaVector>.BlueViolet; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #A52A2A.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Brown = NamedColors<RgbaVector>.Brown; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DEB887.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector BurlyWood = NamedColors<RgbaVector>.BurlyWood; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #5F9EA0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector CadetBlue = NamedColors<RgbaVector>.CadetBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #7FFF00.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Chartreuse = NamedColors<RgbaVector>.Chartreuse; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #D2691E.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Chocolate = NamedColors<RgbaVector>.Chocolate; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF7F50.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Coral = NamedColors<RgbaVector>.Coral; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #6495ED.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector CornflowerBlue = NamedColors<RgbaVector>.CornflowerBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFF8DC.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Cornsilk = NamedColors<RgbaVector>.Cornsilk; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DC143C.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Crimson = NamedColors<RgbaVector>.Crimson; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00FFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Cyan = NamedColors<RgbaVector>.Cyan; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00008B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkBlue = NamedColors<RgbaVector>.DarkBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #008B8B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkCyan = NamedColors<RgbaVector>.DarkCyan; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #B8860B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkGoldenrod = NamedColors<RgbaVector>.DarkGoldenrod; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #A9A9A9.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkGray = NamedColors<RgbaVector>.DarkGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #006400.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkGreen = NamedColors<RgbaVector>.DarkGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #BDB76B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkKhaki = NamedColors<RgbaVector>.DarkKhaki; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #8B008B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkMagenta = NamedColors<RgbaVector>.DarkMagenta; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #556B2F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkOliveGreen = NamedColors<RgbaVector>.DarkOliveGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF8C00.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkOrange = NamedColors<RgbaVector>.DarkOrange; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #9932CC.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkOrchid = NamedColors<RgbaVector>.DarkOrchid; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #8B0000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkRed = NamedColors<RgbaVector>.DarkRed; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #E9967A.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkSalmon = NamedColors<RgbaVector>.DarkSalmon; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #8FBC8B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkSeaGreen = NamedColors<RgbaVector>.DarkSeaGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #483D8B.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkSlateBlue = NamedColors<RgbaVector>.DarkSlateBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #2F4F4F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkSlateGray = NamedColors<RgbaVector>.DarkSlateGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00CED1.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkTurquoise = NamedColors<RgbaVector>.DarkTurquoise; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #9400D3.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DarkViolet = NamedColors<RgbaVector>.DarkViolet; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF1493.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DeepPink = NamedColors<RgbaVector>.DeepPink; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00BFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DeepSkyBlue = NamedColors<RgbaVector>.DeepSkyBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #696969.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DimGray = NamedColors<RgbaVector>.DimGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #1E90FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector DodgerBlue = NamedColors<RgbaVector>.DodgerBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #B22222.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Firebrick = NamedColors<RgbaVector>.Firebrick; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFAF0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector FloralWhite = NamedColors<RgbaVector>.FloralWhite; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #228B22.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector ForestGreen = NamedColors<RgbaVector>.ForestGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF00FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Fuchsia = NamedColors<RgbaVector>.Fuchsia; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DCDCDC.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Gainsboro = NamedColors<RgbaVector>.Gainsboro; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F8F8FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector GhostWhite = NamedColors<RgbaVector>.GhostWhite; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFD700.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Gold = NamedColors<RgbaVector>.Gold; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DAA520.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Goldenrod = NamedColors<RgbaVector>.Goldenrod; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #808080.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Gray = NamedColors<RgbaVector>.Gray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #008000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Green = NamedColors<RgbaVector>.Green; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #ADFF2F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector GreenYellow = NamedColors<RgbaVector>.GreenYellow; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F0FFF0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Honeydew = NamedColors<RgbaVector>.Honeydew; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF69B4.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector HotPink = NamedColors<RgbaVector>.HotPink; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #CD5C5C.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector IndianRed = NamedColors<RgbaVector>.IndianRed; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #4B0082.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Indigo = NamedColors<RgbaVector>.Indigo; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFFF0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Ivory = NamedColors<RgbaVector>.Ivory; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F0E68C.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Khaki = NamedColors<RgbaVector>.Khaki; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #E6E6FA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Lavender = NamedColors<RgbaVector>.Lavender; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFF0F5.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LavenderBlush = NamedColors<RgbaVector>.LavenderBlush; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #7CFC00.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LawnGreen = NamedColors<RgbaVector>.LawnGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFACD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LemonChiffon = NamedColors<RgbaVector>.LemonChiffon; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #ADD8E6.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightBlue = NamedColors<RgbaVector>.LightBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F08080.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightCoral = NamedColors<RgbaVector>.LightCoral; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #E0FFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightCyan = NamedColors<RgbaVector>.LightCyan; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FAFAD2.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightGoldenrodYellow = NamedColors<RgbaVector>.LightGoldenrodYellow; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #D3D3D3.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightGray = NamedColors<RgbaVector>.LightGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #90EE90.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightGreen = NamedColors<RgbaVector>.LightGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFB6C1.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightPink = NamedColors<RgbaVector>.LightPink; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFA07A.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightSalmon = NamedColors<RgbaVector>.LightSalmon; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #20B2AA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightSeaGreen = NamedColors<RgbaVector>.LightSeaGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #87CEFA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightSkyBlue = NamedColors<RgbaVector>.LightSkyBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #778899.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightSlateGray = NamedColors<RgbaVector>.LightSlateGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #B0C4DE.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightSteelBlue = NamedColors<RgbaVector>.LightSteelBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFFE0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LightYellow = NamedColors<RgbaVector>.LightYellow; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00FF00.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Lime = NamedColors<RgbaVector>.Lime; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #32CD32.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector LimeGreen = NamedColors<RgbaVector>.LimeGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FAF0E6.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Linen = NamedColors<RgbaVector>.Linen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF00FF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Magenta = NamedColors<RgbaVector>.Magenta; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #800000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Maroon = NamedColors<RgbaVector>.Maroon; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #66CDAA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumAquamarine = NamedColors<RgbaVector>.MediumAquamarine; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #0000CD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumBlue = NamedColors<RgbaVector>.MediumBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #BA55D3.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumOrchid = NamedColors<RgbaVector>.MediumOrchid; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #9370DB.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumPurple = NamedColors<RgbaVector>.MediumPurple; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #3CB371.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumSeaGreen = NamedColors<RgbaVector>.MediumSeaGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #7B68EE.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumSlateBlue = NamedColors<RgbaVector>.MediumSlateBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00FA9A.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumSpringGreen = NamedColors<RgbaVector>.MediumSpringGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #48D1CC.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumTurquoise = NamedColors<RgbaVector>.MediumTurquoise; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #C71585.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MediumVioletRed = NamedColors<RgbaVector>.MediumVioletRed; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #191970.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MidnightBlue = NamedColors<RgbaVector>.MidnightBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F5FFFA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MintCream = NamedColors<RgbaVector>.MintCream; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFE4E1.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector MistyRose = NamedColors<RgbaVector>.MistyRose; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFE4B5.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Moccasin = NamedColors<RgbaVector>.Moccasin; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFDEAD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector NavajoWhite = NamedColors<RgbaVector>.NavajoWhite; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #000080.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Navy = NamedColors<RgbaVector>.Navy; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FDF5E6.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector OldLace = NamedColors<RgbaVector>.OldLace; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #808000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Olive = NamedColors<RgbaVector>.Olive; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #6B8E23.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector OliveDrab = NamedColors<RgbaVector>.OliveDrab; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFA500.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Orange = NamedColors<RgbaVector>.Orange; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF4500.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector OrangeRed = NamedColors<RgbaVector>.OrangeRed; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DA70D6.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Orchid = NamedColors<RgbaVector>.Orchid; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #EEE8AA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PaleGoldenrod = NamedColors<RgbaVector>.PaleGoldenrod; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #98FB98.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PaleGreen = NamedColors<RgbaVector>.PaleGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #AFEEEE.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PaleTurquoise = NamedColors<RgbaVector>.PaleTurquoise; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DB7093.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PaleVioletRed = NamedColors<RgbaVector>.PaleVioletRed; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFEFD5.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PapayaWhip = NamedColors<RgbaVector>.PapayaWhip; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFDAB9.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PeachPuff = NamedColors<RgbaVector>.PeachPuff; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #CD853F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Peru = NamedColors<RgbaVector>.Peru; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFC0CB.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Pink = NamedColors<RgbaVector>.Pink; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #DDA0DD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Plum = NamedColors<RgbaVector>.Plum; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #B0E0E6.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector PowderBlue = NamedColors<RgbaVector>.PowderBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #800080.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Purple = NamedColors<RgbaVector>.Purple; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #663399.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector RebeccaPurple = NamedColors<RgbaVector>.RebeccaPurple; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF0000.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Red = NamedColors<RgbaVector>.Red; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #BC8F8F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector RosyBrown = NamedColors<RgbaVector>.RosyBrown; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #4169E1.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector RoyalBlue = NamedColors<RgbaVector>.RoyalBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #8B4513.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SaddleBrown = NamedColors<RgbaVector>.SaddleBrown; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FA8072.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Salmon = NamedColors<RgbaVector>.Salmon; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F4A460.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SandyBrown = NamedColors<RgbaVector>.SandyBrown; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #2E8B57.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SeaGreen = NamedColors<RgbaVector>.SeaGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFF5EE.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SeaShell = NamedColors<RgbaVector>.SeaShell; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #A0522D.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Sienna = NamedColors<RgbaVector>.Sienna; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #C0C0C0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Silver = NamedColors<RgbaVector>.Silver; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #87CEEB.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SkyBlue = NamedColors<RgbaVector>.SkyBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #6A5ACD.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SlateBlue = NamedColors<RgbaVector>.SlateBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #708090.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SlateGray = NamedColors<RgbaVector>.SlateGray; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFAFA.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Snow = NamedColors<RgbaVector>.Snow; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #00FF7F.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SpringGreen = NamedColors<RgbaVector>.SpringGreen; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #4682B4.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector SteelBlue = NamedColors<RgbaVector>.SteelBlue; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #D2B48C.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Tan = NamedColors<RgbaVector>.Tan; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #008080.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Teal = NamedColors<RgbaVector>.Teal; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #D8BFD8.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Thistle = NamedColors<RgbaVector>.Thistle; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FF6347.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Tomato = NamedColors<RgbaVector>.Tomato; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Transparent = NamedColors<RgbaVector>.Transparent; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #40E0D0.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Turquoise = NamedColors<RgbaVector>.Turquoise; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #EE82EE.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Violet = NamedColors<RgbaVector>.Violet; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F5DEB3.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Wheat = NamedColors<RgbaVector>.Wheat; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFFFF.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector White = NamedColors<RgbaVector>.White; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #F5F5F5.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector WhiteSmoke = NamedColors<RgbaVector>.WhiteSmoke; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #FFFF00.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector Yellow = NamedColors<RgbaVector>.Yellow; |
|||
|
|||
/// <summary>
|
|||
/// Represents a <see cref="RgbaVector"/> matching the W3C definition that has an hex value of #9ACD32.
|
|||
/// </summary>
|
|||
public static readonly RgbaVector YellowGreen = NamedColors<RgbaVector>.YellowGreen; |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Numerics; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
interface ITestPixel<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
void FromRgba32(Rgba32 source); |
|||
|
|||
void FromRgba32(ref Rgba32 source); |
|||
|
|||
void FromBytes(byte r, byte g, byte b, byte a); |
|||
|
|||
void FromVector4(Vector4 source); |
|||
|
|||
void FromVector4(ref Vector4 source); |
|||
|
|||
Rgba32 ToRgba32(); |
|||
|
|||
void CopyToRgba32(ref Rgba32 dest); |
|||
|
|||
Vector4 ToVector4(); |
|||
|
|||
void CopyToVector4(ref Vector4 dest); |
|||
} |
|||
} |
|||
@ -1,86 +1,15 @@ |
|||
// ReSharper disable InconsistentNaming
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General |
|||
{ |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
public class PixelConversion_ConvertFromRgba32 |
|||
{ |
|||
interface ITestPixel<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
void FromRgba32(Rgba32 source); |
|||
|
|||
void FromRgba32(ref Rgba32 source); |
|||
|
|||
void FromBytes(byte r, byte g, byte b, byte a); |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestArgb : ITestPixel<TestArgb> |
|||
{ |
|||
private byte a, r, g, b; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(Rgba32 p) |
|||
{ |
|||
this.r = p.R; |
|||
this.g = p.G; |
|||
this.b = p.B; |
|||
this.a = p.A; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(ref Rgba32 p) |
|||
{ |
|||
this.r = p.R; |
|||
this.g = p.G; |
|||
this.b = p.B; |
|||
this.a = p.A; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromBytes(byte r, byte g, byte b, byte a) |
|||
{ |
|||
this.r = r; |
|||
this.g = g; |
|||
this.b = b; |
|||
this.a = a; |
|||
} |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestRgba : ITestPixel<TestRgba> |
|||
{ |
|||
private byte r, g, b, a; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(Rgba32 source) |
|||
{ |
|||
this = Unsafe.As<Rgba32, TestRgba>(ref source); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(ref Rgba32 source) |
|||
{ |
|||
this = Unsafe.As<Rgba32, TestRgba>(ref source); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromBytes(byte r, byte g, byte b, byte a) |
|||
{ |
|||
this.r = r; |
|||
this.g = g; |
|||
this.b = b; |
|||
this.a = a; |
|||
} |
|||
} |
|||
|
|||
struct ConversionRunner<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
@ -1,62 +1,48 @@ |
|||
// ReSharper disable InconsistentNaming
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General |
|||
{ |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
public class PixelConversion_ConvertFromVector4 |
|||
{ |
|||
interface ITestPixel<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
void FromVector4(Vector4 source); |
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
void FromVector4(ref Vector4 source); |
|||
} |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
public class PixelConversion_ConvertFromVector4 |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestArgb : ITestPixel<TestArgb> |
|||
struct TestRgbaVector : ITestPixel<TestRgbaVector> |
|||
{ |
|||
private byte a, r, g, b; |
|||
private Vector4 v; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(Vector4 p) |
|||
{ |
|||
this.r = (byte)p.X; |
|||
this.g = (byte)p.Y; |
|||
this.b = (byte)p.Z; |
|||
this.a = (byte)p.W; |
|||
this.v = p; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(ref Vector4 p) |
|||
{ |
|||
this.r = (byte)p.X; |
|||
this.g = (byte)p.Y; |
|||
this.b = (byte)p.Z; |
|||
this.a = (byte)p.W; |
|||
this.v = p; |
|||
} |
|||
} |
|||
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestRgbaVector : ITestPixel<TestRgbaVector> |
|||
{ |
|||
private Vector4 v; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(Vector4 p) |
|||
{ |
|||
this.v = p; |
|||
} |
|||
public Vector4 ToVector4() => this.v; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(ref Vector4 p) |
|||
public void CopyToVector4(ref Vector4 dest) |
|||
{ |
|||
this.v = p; |
|||
dest = this.v; |
|||
} |
|||
|
|||
public void FromRgba32(Rgba32 source) => throw new System.NotImplementedException(); |
|||
public void FromRgba32(ref Rgba32 source) => throw new System.NotImplementedException(); |
|||
public void FromBytes(byte r, byte g, byte b, byte a) => throw new System.NotImplementedException(); |
|||
public Rgba32 ToRgba32() => throw new System.NotImplementedException(); |
|||
public void CopyToRgba32(ref Rgba32 dest) => throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
struct ConversionRunner<T> |
|||
@ -0,0 +1,113 @@ |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation |
|||
{ |
|||
struct ConversionRunner<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
private T[] source; |
|||
|
|||
private Rgba32[] dest; |
|||
|
|||
public ConversionRunner(int count) |
|||
{ |
|||
this.source = new T[count]; |
|||
this.dest = new Rgba32[count]; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunRetvalConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Rgba32 destBaseRef = ref this.dest[0]; |
|||
|
|||
Rgba32 temp; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
temp = Unsafe.Add(ref sourceBaseRef, i).ToRgba32(); |
|||
|
|||
// manipulate pixel before saving to dest buffer:
|
|||
temp.A = 0; |
|||
|
|||
Unsafe.Add(ref destBaseRef, i) = temp; |
|||
} |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunCopyToConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Rgba32 destBaseRef = ref this.dest[0]; |
|||
|
|||
Rgba32 temp = default; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
Unsafe.Add(ref sourceBaseRef, i).CopyToRgba32(ref temp); |
|||
|
|||
// manipulate pixel before saving to dest buffer:
|
|||
temp.A = 0; |
|||
|
|||
Unsafe.Add(ref destBaseRef, i) = temp; |
|||
} |
|||
} |
|||
} |
|||
|
|||
private ConversionRunner<TestRgba> compatibleMemoryLayoutRunner; |
|||
|
|||
private ConversionRunner<TestArgb> permutedRunner; |
|||
|
|||
[Params(32)] |
|||
public int Count { get; set; } |
|||
|
|||
[GlobalSetup] |
|||
public void Setup() |
|||
{ |
|||
this.compatibleMemoryLayoutRunner = new ConversionRunner<TestRgba>(this.Count); |
|||
this.permutedRunner = new ConversionRunner<TestArgb>(this.Count); |
|||
} |
|||
|
|||
[Benchmark(Baseline = true)] |
|||
public void CompatibleRetval() |
|||
{ |
|||
this.compatibleMemoryLayoutRunner.RunRetvalConversion(); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void CompatibleCopyTo() |
|||
{ |
|||
this.compatibleMemoryLayoutRunner.RunCopyToConversion(); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void PermutedRetval() |
|||
{ |
|||
this.permutedRunner.RunRetvalConversion(); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void PermutedCopyTo() |
|||
{ |
|||
this.permutedRunner.RunCopyToConversion(); |
|||
} |
|||
} |
|||
|
|||
// RESULTS:
|
|||
// Method | Count | Mean | Error | StdDev | Scaled | ScaledSD |
|
|||
// ----------------- |------ |----------:|----------:|----------:|-------:|---------:|
|
|||
// CompatibleRetval | 32 | 53.05 ns | 0.1865 ns | 0.1557 ns | 1.00 | 0.00 |
|
|||
// CompatibleCopyTo | 32 | 36.12 ns | 0.3596 ns | 0.3003 ns | 0.68 | 0.01 |
|
|||
// PermutedRetval | 32 | 303.61 ns | 5.1697 ns | 4.8358 ns | 5.72 | 0.09 |
|
|||
// PermutedCopyTo | 32 | 38.05 ns | 0.8053 ns | 1.2297 ns | 0.72 | 0.02 |
|
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
public class PixelConversion_ConvertToVector4 |
|||
{ |
|||
struct ConversionRunner<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
private T[] source; |
|||
|
|||
private Vector4[] dest; |
|||
|
|||
public ConversionRunner(int count) |
|||
{ |
|||
this.source = new T[count]; |
|||
this.dest = new Vector4[count]; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunRetvalConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Vector4 destBaseRef = ref this.dest[0]; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
Unsafe.Add(ref destBaseRef, i) = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); |
|||
} |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunCopyToConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Vector4 destBaseRef = ref this.dest[0]; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref Unsafe.Add(ref destBaseRef, i)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private ConversionRunner<TestRgba> runner; |
|||
|
|||
[Params(32)] |
|||
public int Count { get; set; } |
|||
|
|||
[GlobalSetup] |
|||
public void Setup() |
|||
{ |
|||
this.runner = new ConversionRunner<TestRgba>(this.Count); |
|||
} |
|||
|
|||
[Benchmark(Baseline = true)] |
|||
public void UseRetval() |
|||
{ |
|||
this.runner.RunRetvalConversion(); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void UseCopyTo() |
|||
{ |
|||
this.runner.RunCopyToConversion(); |
|||
} |
|||
|
|||
// RESULTS:
|
|||
// Method | Count | Mean | Error | StdDev | Scaled |
|
|||
// ---------- |------ |---------:|----------:|----------:|-------:|
|
|||
// UseRetval | 32 | 94.99 ns | 1.1199 ns | 0.9352 ns | 1.00 |
|
|||
// UseCopyTo | 32 | 59.47 ns | 0.6104 ns | 0.5710 ns | 0.63 |
|
|||
} |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation |
|||
{ |
|||
struct ConversionRunner<T> |
|||
where T : struct, ITestPixel<T> |
|||
{ |
|||
private T[] source; |
|||
|
|||
private Vector4[] dest; |
|||
|
|||
public ConversionRunner(int count) |
|||
{ |
|||
this.source = new T[count]; |
|||
this.dest = new Vector4[count]; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunRetvalConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Vector4 destBaseRef = ref this.dest[0]; |
|||
|
|||
Vector4 temp; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
temp = Unsafe.Add(ref sourceBaseRef, i).ToVector4(); |
|||
|
|||
// manipulate pixel before saving to dest buffer:
|
|||
temp.W = 0; |
|||
|
|||
Unsafe.Add(ref destBaseRef, i) = temp; |
|||
} |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void RunCopyToConversion() |
|||
{ |
|||
int count = this.source.Length; |
|||
|
|||
ref T sourceBaseRef = ref this.source[0]; |
|||
ref Vector4 destBaseRef = ref this.dest[0]; |
|||
|
|||
Vector4 temp = default; |
|||
|
|||
for (int i = 0; i < count; i++) |
|||
{ |
|||
Unsafe.Add(ref sourceBaseRef, i).CopyToVector4(ref temp); |
|||
|
|||
// manipulate pixel before saving to dest buffer:
|
|||
temp.W = 0; |
|||
|
|||
Unsafe.Add(ref destBaseRef, i) = temp; |
|||
} |
|||
} |
|||
} |
|||
|
|||
private ConversionRunner<TestRgba> runner; |
|||
|
|||
[Params(32)] |
|||
public int Count { get; set; } |
|||
|
|||
[GlobalSetup] |
|||
public void Setup() |
|||
{ |
|||
this.runner = new ConversionRunner<TestRgba>(this.Count); |
|||
} |
|||
|
|||
[Benchmark(Baseline = true)] |
|||
public void UseRetval() |
|||
{ |
|||
this.runner.RunRetvalConversion(); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void UseCopyTo() |
|||
{ |
|||
this.runner.RunCopyToConversion(); |
|||
} |
|||
|
|||
// RESULTS:
|
|||
// Method | Count | Mean | Error | StdDev | Scaled |
|
|||
// ---------- |------ |----------:|----------:|----------:|-------:|
|
|||
// UseRetval | 32 | 100.35 ns | 0.4844 ns | 0.4532 ns | 1.00 |
|
|||
// UseCopyTo | 32 | 53.95 ns | 0.1269 ns | 0.1125 ns | 0.54 |
|
|||
} |
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestArgb : ITestPixel<TestArgb> |
|||
{ |
|||
private byte a, r, g, b; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(Rgba32 p) |
|||
{ |
|||
this.r = p.R; |
|||
this.g = p.G; |
|||
this.b = p.B; |
|||
this.a = p.A; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(ref Rgba32 p) |
|||
{ |
|||
this.r = p.R; |
|||
this.g = p.G; |
|||
this.b = p.B; |
|||
this.a = p.A; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromBytes(byte r, byte g, byte b, byte a) |
|||
{ |
|||
this.r = r; |
|||
this.g = g; |
|||
this.b = b; |
|||
this.a = a; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(Vector4 p) |
|||
{ |
|||
this.r = (byte)p.X; |
|||
this.g = (byte)p.Y; |
|||
this.b = (byte)p.Z; |
|||
this.a = (byte)p.W; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromVector4(ref Vector4 p) |
|||
{ |
|||
this.r = (byte)p.X; |
|||
this.g = (byte)p.Y; |
|||
this.b = (byte)p.Z; |
|||
this.a = (byte)p.W; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Rgba32 ToRgba32() |
|||
{ |
|||
return new Rgba32(this.r, this.g, this.b, this.a); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void CopyToRgba32(ref Rgba32 dest) |
|||
{ |
|||
dest.R = this.r; |
|||
dest.G = this.g; |
|||
dest.B = this.b; |
|||
dest.A = this.a; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector4 ToVector4() |
|||
{ |
|||
return new Vector4(this.r, this.g, this.b, this.a); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void CopyToVector4(ref Vector4 dest) |
|||
{ |
|||
dest.X = this.r; |
|||
dest.Y = this.g; |
|||
dest.Z = this.b; |
|||
dest.W = this.a; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct TestRgba : ITestPixel<TestRgba> |
|||
{ |
|||
private byte r, g, b, a; |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(Rgba32 source) |
|||
{ |
|||
this = Unsafe.As<Rgba32, TestRgba>(ref source); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromRgba32(ref Rgba32 source) |
|||
{ |
|||
this = Unsafe.As<Rgba32, TestRgba>(ref source); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void FromBytes(byte r, byte g, byte b, byte a) |
|||
{ |
|||
this.r = r; |
|||
this.g = g; |
|||
this.b = b; |
|||
this.a = a; |
|||
} |
|||
|
|||
public void FromVector4(Vector4 source) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
public void FromVector4(ref Vector4 source) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Rgba32 ToRgba32() |
|||
{ |
|||
return Unsafe.As<TestRgba, Rgba32>(ref this); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void CopyToRgba32(ref Rgba32 dest) |
|||
{ |
|||
dest = Unsafe.As<TestRgba, Rgba32>(ref this); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector4 ToVector4() |
|||
{ |
|||
return new Vector4(this.r, this.g, this.b, this.a); |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public void CopyToVector4(ref Vector4 dest) |
|||
{ |
|||
dest.X = this.r; |
|||
dest.Y = this.g; |
|||
dest.Z = this.b; |
|||
dest.W = this.a; |
|||
} |
|||
} |
|||
} |
|||
@ -1,151 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Colors |
|||
{ |
|||
public class ColorConstructorTests |
|||
{ |
|||
public static IEnumerable<object[]> Vector4Data |
|||
{ |
|||
get |
|||
{ |
|||
Vector4[] vector4Values = new Vector4[] |
|||
{ |
|||
Vector4.Zero, |
|||
Vector4.One, |
|||
Vector4.UnitX, |
|||
Vector4.UnitY, |
|||
Vector4.UnitZ, |
|||
Vector4.UnitW, |
|||
}; |
|||
|
|||
foreach (Vector4 vector4 in vector4Values) |
|||
{ |
|||
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
|
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { new Argb32(vector4), vector4Components }; |
|||
yield return new object[] { new Bgra4444(vector4), vector4Components }; |
|||
yield return new object[] { new Bgra5551(vector4), vector4Components }; |
|||
yield return new object[] { new Byte4(vector4), vector4Components }; |
|||
yield return new object[] { new HalfVector4(vector4), vector4Components }; |
|||
yield return new object[] { new NormalizedByte4(vector4), vector4Components }; |
|||
yield return new object[] { new NormalizedShort4(vector4), vector4Components }; |
|||
yield return new object[] { new Rgba1010102(vector4), vector4Components }; |
|||
yield return new object[] { new Rgba64(vector4), vector4Components }; |
|||
yield return new object[] { new Short4(vector4), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IEnumerable<object[]> Vector3Data |
|||
{ |
|||
get |
|||
{ |
|||
Dictionary<Vector3, Vector4> vector3Values = new Dictionary<Vector3, Vector4>() |
|||
{ |
|||
{ Vector3.One, Vector4.One }, |
|||
{ Vector3.Zero, new Vector4(0, 0, 0, 1) }, |
|||
{ Vector3.UnitX, new Vector4(1, 0, 0, 1) }, |
|||
{ Vector3.UnitY, new Vector4(0, 1, 0, 1) }, |
|||
{ Vector3.UnitZ, new Vector4(0, 0, 1, 1) }, |
|||
}; |
|||
|
|||
foreach (Vector3 vector3 in vector3Values.Keys) |
|||
{ |
|||
Vector4 vector4 = vector3Values[vector3]; |
|||
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
|
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { new Argb32(vector3), vector4Components }; |
|||
yield return new object[] { new Bgr565(vector3), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IEnumerable<object[]> Float4Data |
|||
{ |
|||
get |
|||
{ |
|||
Vector4[] vector4Values = new Vector4[] |
|||
{ |
|||
Vector4.Zero, |
|||
Vector4.One, |
|||
Vector4.UnitX, |
|||
Vector4.UnitY, |
|||
Vector4.UnitZ, |
|||
Vector4.UnitW, |
|||
}; |
|||
|
|||
foreach (Vector4 vector4 in vector4Values) |
|||
{ |
|||
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
|
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { new Argb32(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Bgra4444(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Bgra5551(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Byte4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new HalfVector4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new NormalizedByte4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new NormalizedShort4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Rgba1010102(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Rgba64(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
yield return new object[] { new Short4(vector4.X, vector4.Y, vector4.Z, vector4.W), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IEnumerable<object[]> Float3Data |
|||
{ |
|||
get |
|||
{ |
|||
Dictionary<Vector3, Vector4> vector3Values = new Dictionary<Vector3, Vector4>() |
|||
{ |
|||
{ Vector3.One, Vector4.One }, |
|||
{ Vector3.Zero, new Vector4(0, 0, 0, 1) }, |
|||
{ Vector3.UnitX, new Vector4(1, 0, 0, 1) }, |
|||
{ Vector3.UnitY, new Vector4(0, 1, 0, 1) }, |
|||
{ Vector3.UnitZ, new Vector4(0, 0, 1, 1) }, |
|||
}; |
|||
|
|||
foreach (Vector3 vector3 in vector3Values.Keys) |
|||
{ |
|||
Vector4 vector4 = vector3Values[vector3]; |
|||
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
|
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { new Argb32(vector3.X, vector3.Y, vector3.Z), vector4Components }; |
|||
yield return new object[] { new Bgr565(vector3.X, vector3.Y, vector3.Z), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(Vector4Data))] |
|||
[MemberData(nameof(Vector3Data))] |
|||
[MemberData(nameof(Float4Data))] |
|||
[MemberData(nameof(Float3Data))] |
|||
public void ConstructorToVector4(IPixel packedVector, float[] expectedVector4Components) |
|||
{ |
|||
// Arrange
|
|||
int precision = 2; |
|||
// using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
|
|||
Vector4 expectedVector4 = new Vector4(expectedVector4Components[0], expectedVector4Components[1], expectedVector4Components[2], expectedVector4Components[3]); |
|||
|
|||
// Act
|
|||
Vector4 vector4 = packedVector.ToVector4(); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expectedVector4.X, vector4.X, precision); |
|||
Assert.Equal(expectedVector4.Y, vector4.Y, precision); |
|||
Assert.Equal(expectedVector4.Z, vector4.Z, precision); |
|||
Assert.Equal(expectedVector4.W, vector4.W, precision); |
|||
} |
|||
} |
|||
} |
|||
@ -1,216 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Colors |
|||
{ |
|||
/// <summary>
|
|||
/// Test implementations of IEquatable
|
|||
/// </summary>
|
|||
public class ColorEqualityTests |
|||
{ |
|||
public static readonly TheoryData<object, object, Type> EqualityData = |
|||
new TheoryData<object, object, Type>() |
|||
{ |
|||
{ new Alpha8(.5F), new Alpha8(.5F), typeof(Alpha8) }, |
|||
{ new Argb32(Vector4.One), new Argb32(Vector4.One), typeof(Argb32) }, |
|||
{ new Bgr565(Vector3.One), new Bgr565(Vector3.One), typeof(Bgr565) }, |
|||
{ new Bgra4444(Vector4.One), new Bgra4444(Vector4.One), typeof(Bgra4444) }, |
|||
{ new Bgra5551(Vector4.One), new Bgra5551(Vector4.One), typeof(Bgra5551) }, |
|||
{ new Byte4(Vector4.One * 255), new Byte4(Vector4.One * 255), typeof(Byte4) }, |
|||
{ new HalfSingle(-1F), new HalfSingle(-1F), typeof(HalfSingle) }, |
|||
{ new HalfVector2(0.1f, -0.3f), new HalfVector2(0.1f, -0.3f), typeof(HalfVector2) }, |
|||
{ new HalfVector4(Vector4.One), new HalfVector4(Vector4.One), typeof(HalfVector4) }, |
|||
{ new NormalizedByte2(-Vector2.One), new NormalizedByte2(-Vector2.One), typeof(NormalizedByte2) }, |
|||
{ new NormalizedByte4(Vector4.One), new NormalizedByte4(Vector4.One), typeof(NormalizedByte4) }, |
|||
{ new NormalizedShort2(Vector2.One), new NormalizedShort2(Vector2.One), typeof(NormalizedShort2) }, |
|||
{ new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.One), typeof(NormalizedShort4) }, |
|||
{ new Rg32(Vector2.One), new Rg32(Vector2.One), typeof(Rg32) }, |
|||
{ new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.One), typeof(Rgba1010102) }, |
|||
{ new Rgba32(Vector4.One), new Rgba32(Vector4.One), typeof(Rgba32) }, |
|||
{ new Rgba64(Vector4.One), new Rgba64(Vector4.One), typeof(Rgba64) }, |
|||
{ new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.One * 0x7FFF), typeof(Short2) }, |
|||
{ new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.One * 0x7FFF), typeof(Short4) }, |
|||
}; |
|||
|
|||
public static readonly TheoryData<object, object, Type> NotEqualityDataNulls = |
|||
new TheoryData<object, object, Type>() |
|||
{ |
|||
// Valid object against null
|
|||
{ new Alpha8(.5F), null, typeof(Alpha8) }, |
|||
{ new Argb32(Vector4.One), null, typeof(Argb32) }, |
|||
{ new Bgr565(Vector3.One), null, typeof(Bgr565) }, |
|||
{ new Bgra4444(Vector4.One), null, typeof(Bgra4444) }, |
|||
{ new Bgra5551(Vector4.One), null, typeof(Bgra5551) }, |
|||
{ new Byte4(Vector4.One * 255), null, typeof(Byte4) }, |
|||
{ new HalfSingle(-1F), null, typeof(HalfSingle) }, |
|||
{ new HalfVector2(0.1f, -0.3f), null, typeof(HalfVector2) }, |
|||
{ new HalfVector4(Vector4.One), null, typeof(HalfVector4) }, |
|||
{ new NormalizedByte2(-Vector2.One), null, typeof(NormalizedByte2) }, |
|||
{ new NormalizedByte4(Vector4.One), null, typeof(NormalizedByte4) }, |
|||
{ new NormalizedShort2(Vector2.One), null, typeof(NormalizedShort2) }, |
|||
{ new NormalizedShort4(Vector4.One), null, typeof(NormalizedShort4) }, |
|||
{ new Rg32(Vector2.One), null, typeof(Rg32) }, |
|||
{ new Rgba1010102(Vector4.One), null, typeof(Rgba1010102) }, |
|||
{ new Rgba64(Vector4.One), null, typeof(Rgba64) }, |
|||
{ new Short2(Vector2.One * 0x7FFF), null, typeof(Short2) }, |
|||
{ new Short4(Vector4.One * 0x7FFF), null, typeof(Short4) }, |
|||
}; |
|||
|
|||
public static readonly TheoryData<object, object, Type> NotEqualityDataDifferentObjects = |
|||
new TheoryData<object, object, Type>() |
|||
{ |
|||
// Valid objects of different types but not equal
|
|||
{ new Alpha8(.5F), new Argb32(Vector4.Zero), null }, |
|||
{ new HalfSingle(-1F), new NormalizedShort2(Vector2.Zero), null }, |
|||
{ new Rgba1010102(Vector4.One), new Bgra5551(Vector4.Zero), null }, |
|||
}; |
|||
|
|||
public static readonly TheoryData<object, object, Type> NotEqualityData = |
|||
new TheoryData<object, object, Type>() |
|||
{ |
|||
// Valid objects of the same type but not equal
|
|||
{ new Alpha8(.5F), new Alpha8(.8F), typeof(Alpha8) }, |
|||
{ new Argb32(Vector4.One), new Argb32(Vector4.Zero), typeof(Argb32) }, |
|||
{ new Bgr565(Vector3.One), new Bgr565(Vector3.Zero), typeof(Bgr565) }, |
|||
{ new Bgra4444(Vector4.One), new Bgra4444(Vector4.Zero), typeof(Bgra4444) }, |
|||
{ new Bgra5551(Vector4.One), new Bgra5551(Vector4.Zero), typeof(Bgra5551) }, |
|||
{ new Byte4(Vector4.One * 255), new Byte4(Vector4.Zero), typeof(Byte4) }, |
|||
{ new HalfSingle(-1F), new HalfSingle(1F), typeof(HalfSingle) }, |
|||
{ new HalfVector2(0.1f, -0.3f), new HalfVector2(0.1f, 0.3f), typeof(HalfVector2) }, |
|||
{ new HalfVector4(Vector4.One), new HalfVector4(Vector4.Zero), typeof(HalfVector4) }, |
|||
{ new NormalizedByte2(-Vector2.One), new NormalizedByte2(-Vector2.Zero), typeof(NormalizedByte2) }, |
|||
{ new NormalizedByte4(Vector4.One), new NormalizedByte4(Vector4.Zero), typeof(NormalizedByte4) }, |
|||
{ new NormalizedShort2(Vector2.One), new NormalizedShort2(Vector2.Zero), typeof(NormalizedShort2) }, |
|||
{ new NormalizedShort4(Vector4.One), new NormalizedShort4(Vector4.Zero), typeof(NormalizedShort4) }, |
|||
{ new Rg32(Vector2.One), new Rg32(Vector2.Zero), typeof(Rg32) }, |
|||
{ new Rgba1010102(Vector4.One), new Rgba1010102(Vector4.Zero), typeof(Rgba1010102) }, |
|||
{ new Rgba32(Vector4.One), new Rgba32(Vector4.Zero), typeof(Rgba32) }, |
|||
{ new Rgba64(Vector4.One), new Rgba64(Vector4.Zero), typeof(Rgba64) }, |
|||
{ new Short2(Vector2.One * 0x7FFF), new Short2(Vector2.Zero), typeof(Short2) }, |
|||
{ new Short4(Vector4.One * 0x7FFF), new Short4(Vector4.Zero), typeof(Short4) }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(EqualityData))] |
|||
public void Equality(object first, object second, Type type) |
|||
{ |
|||
// Act
|
|||
bool equal = first.Equals(second); |
|||
|
|||
// Assert
|
|||
Assert.True(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(NotEqualityDataNulls))] |
|||
[MemberData(nameof(NotEqualityDataDifferentObjects))] |
|||
[MemberData(nameof(NotEqualityData))] |
|||
public void NotEquality(object first, object second, Type type) |
|||
{ |
|||
// Act
|
|||
bool equal = first.Equals(second); |
|||
|
|||
// Assert
|
|||
Assert.False(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(EqualityData))] |
|||
public void HashCodeEqual(object first, object second, Type type) |
|||
{ |
|||
// Act
|
|||
bool equal = first.GetHashCode() == second.GetHashCode(); |
|||
|
|||
// Assert
|
|||
Assert.True(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(NotEqualityDataDifferentObjects))] |
|||
public void HashCodeNotEqual(object first, object second, Type type) |
|||
{ |
|||
// Act
|
|||
bool equal = first.GetHashCode() == second.GetHashCode(); |
|||
|
|||
// Assert
|
|||
Assert.False(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(EqualityData))] |
|||
public void EqualityObject(object first, object second, Type type) |
|||
{ |
|||
// Arrange
|
|||
// Cast to the known object types, this is so that we can hit the
|
|||
// equality operator on the concrete type, otherwise it goes to the
|
|||
// default "object" one :)
|
|||
dynamic firstObject = Convert.ChangeType(first, type); |
|||
dynamic secondObject = Convert.ChangeType(second, type); |
|||
|
|||
// Act
|
|||
dynamic equal = firstObject.Equals(secondObject); |
|||
|
|||
// Assert
|
|||
Assert.True(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(NotEqualityData))] |
|||
public void NotEqualityObject(object first, object second, Type type) |
|||
{ |
|||
// Arrange
|
|||
// Cast to the known object types, this is so that we can hit the
|
|||
// equality operator on the concrete type, otherwise it goes to the
|
|||
// default "object" one :)
|
|||
dynamic firstObject = Convert.ChangeType(first, type); |
|||
dynamic secondObject = Convert.ChangeType(second, type); |
|||
|
|||
// Act
|
|||
dynamic equal = firstObject.Equals(secondObject); |
|||
|
|||
// Assert
|
|||
Assert.False(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(EqualityData))] |
|||
public void EqualityOperator(object first, object second, Type type) |
|||
{ |
|||
// Arrange
|
|||
// Cast to the known object types, this is so that we can hit the
|
|||
// equality operator on the concrete type, otherwise it goes to the
|
|||
// default "object" one :)
|
|||
dynamic firstObject = Convert.ChangeType(first, type); |
|||
dynamic secondObject = Convert.ChangeType(second, type); |
|||
|
|||
// Act
|
|||
dynamic equal = firstObject == secondObject; |
|||
|
|||
// Assert
|
|||
Assert.True(equal); |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(NotEqualityData))] |
|||
public void NotEqualityOperator(object first, object second, Type type) |
|||
{ |
|||
// Arrange
|
|||
// Cast to the known object types, this is so that we can hit the
|
|||
// equality operator on the concrete type, otherwise it goes to the
|
|||
// default "object" one :)
|
|||
dynamic firstObject = Convert.ChangeType(first, type); |
|||
dynamic secondObject = Convert.ChangeType(second, type); |
|||
|
|||
// Act
|
|||
dynamic notEqual = firstObject != secondObject; |
|||
|
|||
// Assert
|
|||
Assert.True(notEqual); |
|||
} |
|||
} |
|||
} |
|||
@ -1,88 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Colors |
|||
{ |
|||
public class ColorPackingTests |
|||
{ |
|||
public static IEnumerable<object[]> Vector4PackData |
|||
{ |
|||
get |
|||
{ |
|||
Vector4[] vector4Values = new Vector4[] |
|||
{ |
|||
Vector4.Zero, |
|||
Vector4.One, |
|||
Vector4.UnitX, |
|||
Vector4.UnitY, |
|||
Vector4.UnitZ, |
|||
Vector4.UnitW, |
|||
}; |
|||
|
|||
foreach (Vector4 vector4 in vector4Values) |
|||
{ |
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { default(Argb32), vector4Components }; |
|||
yield return new object[] { default(Bgra4444), vector4Components }; |
|||
yield return new object[] { default(Bgra5551), vector4Components }; |
|||
yield return new object[] { default(Byte4), vector4Components }; |
|||
yield return new object[] { default(HalfVector4), vector4Components }; |
|||
yield return new object[] { default(NormalizedByte4), vector4Components }; |
|||
yield return new object[] { default(NormalizedShort4), vector4Components }; |
|||
yield return new object[] { default(Rgba1010102), vector4Components }; |
|||
yield return new object[] { default(Rgba64), vector4Components }; |
|||
yield return new object[] { default(Short4), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IEnumerable<object[]> Vector3PackData |
|||
{ |
|||
get |
|||
{ |
|||
Vector4[] vector4Values = new Vector4[] |
|||
{ |
|||
Vector4.One, |
|||
new Vector4(0, 0, 0, 1), |
|||
new Vector4(1, 0, 0, 1), |
|||
new Vector4(0, 1, 0, 1), |
|||
new Vector4(0, 0, 1, 1), |
|||
}; |
|||
|
|||
foreach (Vector4 vector4 in vector4Values) |
|||
{ |
|||
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W }; |
|||
|
|||
yield return new object[] { default(Argb32), vector4Components }; |
|||
yield return new object[] { new Bgr565(), vector4Components }; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(Vector4PackData))] |
|||
[MemberData(nameof(Vector3PackData))] |
|||
public void FromVector4ToVector4(IPixel packedVector, float[] vector4ComponentsToPack) |
|||
{ |
|||
// Arrange
|
|||
int precision = 2; |
|||
Vector4 vector4ToPack = new Vector4(vector4ComponentsToPack[0], vector4ComponentsToPack[1], vector4ComponentsToPack[2], vector4ComponentsToPack[3]); |
|||
packedVector.PackFromVector4(vector4ToPack); |
|||
|
|||
// Act
|
|||
Vector4 vector4 = packedVector.ToVector4(); |
|||
|
|||
// Assert
|
|||
Assert.Equal(vector4ToPack.X, vector4.X, precision); |
|||
Assert.Equal(vector4ToPack.Y, vector4.Y, precision); |
|||
Assert.Equal(vector4ToPack.Z, vector4.Z, precision); |
|||
Assert.Equal(vector4ToPack.W, vector4.W, precision); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,129 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.PixelFormats |
|||
{ |
|||
public class Gray16Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(65535)] |
|||
[InlineData(32767)] |
|||
[InlineData(42)] |
|||
public void Gray16_PackedValue_EqualsInput(ushort input) |
|||
=> Assert.Equal(input, new Gray16(input).PackedValue); |
|||
|
|||
[Fact] |
|||
public void Gray16_PackFromScaledVector4() |
|||
{ |
|||
// Arrange
|
|||
Gray16 gray = default; |
|||
const ushort expected = 32767; |
|||
Vector4 scaled = new Gray16(expected).ToScaledVector4(); |
|||
|
|||
// Act
|
|||
gray.PackFromScaledVector4(scaled); |
|||
ushort actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(65535)] |
|||
[InlineData(32767)] |
|||
public void Gray16_ToScaledVector4(ushort input) |
|||
{ |
|||
// Arrange
|
|||
var gray = new Gray16(input); |
|||
|
|||
// Act
|
|||
Vector4 actual = gray.ToScaledVector4(); |
|||
|
|||
// Assert
|
|||
float vectorInput = input / 65535F; |
|||
Assert.Equal(vectorInput, actual.X); |
|||
Assert.Equal(vectorInput, actual.Y); |
|||
Assert.Equal(vectorInput, actual.Z); |
|||
Assert.Equal(1F, actual.W); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Gray16_PackFromVector4() |
|||
{ |
|||
// Arrange
|
|||
Gray16 gray = default; |
|||
const ushort expected = 32767; |
|||
var vector = new Gray16(expected).ToVector4(); |
|||
|
|||
// Act
|
|||
gray.PackFromVector4(vector); |
|||
ushort actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(65535)] |
|||
[InlineData(32767)] |
|||
public void Gray16_ToVector4(ushort input) |
|||
{ |
|||
// Arrange
|
|||
var gray = new Gray16(input); |
|||
|
|||
// Act
|
|||
var actual = gray.ToVector4(); |
|||
|
|||
// Assert
|
|||
float vectorInput = input / 65535F; |
|||
Assert.Equal(vectorInput, actual.X); |
|||
Assert.Equal(vectorInput, actual.Y); |
|||
Assert.Equal(vectorInput, actual.Z); |
|||
Assert.Equal(1F, actual.W); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Gray16_PackFromRgba32() |
|||
{ |
|||
// Arrange
|
|||
Gray16 gray = default; |
|||
const byte rgb = 128; |
|||
ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb); |
|||
ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); |
|||
|
|||
// Act
|
|||
gray.PackFromRgba32(new Rgba32(rgb, rgb, rgb)); |
|||
ushort actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(65535)] |
|||
[InlineData(8100)] |
|||
public void Gray16_ToRgba32(ushort input) |
|||
{ |
|||
// Arrange
|
|||
ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input); |
|||
var gray = new Gray16(input); |
|||
|
|||
// Act
|
|||
var actual = gray.ToRgba32(); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual.R); |
|||
Assert.Equal(expected, actual.G); |
|||
Assert.Equal(expected, actual.B); |
|||
Assert.Equal(byte.MaxValue, actual.A); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,127 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.PixelFormats |
|||
{ |
|||
public class Gray8Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(255)] |
|||
[InlineData(10)] |
|||
[InlineData(42)] |
|||
public void Gray8_PackedValue_EqualsInput(byte input) |
|||
=> Assert.Equal(input, new Gray8(input).PackedValue); |
|||
|
|||
[Fact] |
|||
public void Gray8_PackFromScaledVector4() |
|||
{ |
|||
// Arrange
|
|||
Gray8 gray = default; |
|||
const byte expected = 128; |
|||
Vector4 scaled = new Gray8(expected).ToScaledVector4(); |
|||
|
|||
// Act
|
|||
gray.PackFromScaledVector4(scaled); |
|||
byte actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(255)] |
|||
[InlineData(30)] |
|||
public void Gray8_ToScaledVector4(byte input) |
|||
{ |
|||
// Arrange
|
|||
var gray = new Gray8(input); |
|||
|
|||
// Act
|
|||
Vector4 actual = gray.ToScaledVector4(); |
|||
|
|||
// Assert
|
|||
float scaledInput = input / 255F; |
|||
Assert.Equal(scaledInput, actual.X); |
|||
Assert.Equal(scaledInput, actual.Y); |
|||
Assert.Equal(scaledInput, actual.Z); |
|||
Assert.Equal(1, actual.W); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Gray8_PackFromVector4() |
|||
{ |
|||
// Arrange
|
|||
Gray8 gray = default; |
|||
const int expected = 128; |
|||
var vector = new Gray8(expected).ToVector4(); |
|||
|
|||
// Act
|
|||
gray.PackFromVector4(vector); |
|||
byte actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(255)] |
|||
[InlineData(30)] |
|||
public void Gray8_ToVector4(byte input) |
|||
{ |
|||
// Arrange
|
|||
var gray = new Gray8(input); |
|||
|
|||
// Act
|
|||
var actual = gray.ToVector4(); |
|||
|
|||
// Assert
|
|||
float scaledInput = input / 255F; |
|||
Assert.Equal(scaledInput, actual.X); |
|||
Assert.Equal(scaledInput, actual.Y); |
|||
Assert.Equal(scaledInput, actual.Z); |
|||
Assert.Equal(1, actual.W); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Gray8_PackFromRgba32() |
|||
{ |
|||
// Arrange
|
|||
Gray8 gray = default; |
|||
const byte rgb = 128; |
|||
byte expected = ImageMaths.Get8BitBT709Luminance(rgb, rgb, rgb); |
|||
|
|||
// Act
|
|||
gray.PackFromRgba32(new Rgba32(rgb, rgb, rgb)); |
|||
byte actual = gray.PackedValue; |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0)] |
|||
[InlineData(255)] |
|||
[InlineData(30)] |
|||
public void Gray8_ToRgba32(byte input) |
|||
{ |
|||
// Arrange
|
|||
var gray = new Gray8(input); |
|||
|
|||
// Act
|
|||
var actual = gray.ToRgba32(); |
|||
|
|||
// Assert
|
|||
Assert.Equal(input, actual.R); |
|||
Assert.Equal(input, actual.G); |
|||
Assert.Equal(input, actual.B); |
|||
Assert.Equal(byte.MaxValue, actual.A); |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue