mirror of https://github.com/SixLabors/ImageSharp
322 changed files with 7947 additions and 6298 deletions
@ -1,3 +1,8 @@ |
|||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common/@EntryIndexedValue">True</s:Boolean> |
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common/@EntryIndexedValue">True</s:Boolean> |
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cexceptions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cexceptions/@EntryIndexedValue">True</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pixelformats_005Cgenerated/@EntryIndexedValue">True</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pixelformats_005Cpackedpixels/@EntryIndexedValue">True</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pixelformats_005Cpixelimplementations/@EntryIndexedValue">True</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pixelformats_005Cpixeltypes/@EntryIndexedValue">True</s:Boolean> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=pixelformats_005Cutils/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
||||
@ -1,31 +0,0 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
|
|
||||
namespace SixLabors.ImageSharp.PixelFormats |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Enumerates the various component orders.
|
|
||||
/// </summary>
|
|
||||
internal enum ComponentOrder |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Z-> Y-> X order. Equivalent to B-> G-> R in <see cref="Rgba32"/>
|
|
||||
/// </summary>
|
|
||||
Zyx, |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Z-> Y-> X-> W order. Equivalent to B-> G-> R-> A in <see cref="Rgba32"/>
|
|
||||
/// </summary>
|
|
||||
Zyxw, |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// X-> Y-> Z order. Equivalent to R-> G-> B in <see cref="Rgba32"/>
|
|
||||
/// </summary>
|
|
||||
Xyz, |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// X-> Y-> Z-> W order. Equivalent to R-> G-> B-> A in <see cref="Rgba32"/>
|
|
||||
/// </summary>
|
|
||||
Xyzw, |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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 Rgba32 |
|
||||
{ |
|
||||
|
|
||||
/// <content>
|
|
||||
/// Provides optimized overrides for bulk operations.
|
|
||||
/// </content>
|
|
||||
internal partial class PixelOperations |
|
||||
{ |
|
||||
/// <inheritdoc />
|
|
||||
internal override void PackFromRgba32(ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
source.Slice(0, count).CopyTo(destPixels); |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToRgba32(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
sourcePixels.Slice(0, count).CopyTo(destPixels); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToArgb32(ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToBgr24(ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToBgra32(ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToGray8(ReadOnlySpan<Rgba32> sourcePixels, Span<Gray8> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToGray16(ReadOnlySpan<Rgba32> sourcePixels, Span<Gray16> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToRgb24(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToRgb48(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
internal override void ToRgba64(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(sp); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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<Rgba32> sourcePixels, Span<<#=pixelType#>> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(sourcePixels, nameof(sourcePixels), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
||||
ref <#=pixelType#> destRef = ref MemoryMarshal.GetReference(destPixels); |
|
||||
|
|
||||
for (int i = 0; i < count; i++) |
|
||||
{ |
|
||||
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
|
||||
ref <#=pixelType#> dp = ref Unsafe.Add(ref destRef, i); |
|
||||
|
|
||||
dp.PackFromRgba32(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 Rgba32 |
|
||||
{ |
|
||||
|
|
||||
/// <content> |
|
||||
/// Provides optimized overrides for bulk operations. |
|
||||
/// </content> |
|
||||
internal partial class PixelOperations |
|
||||
{ |
|
||||
/// <inheritdoc /> |
|
||||
internal override void PackFromRgba32(ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels, int count) |
|
||||
{ |
|
||||
GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count); |
|
||||
|
|
||||
source.Slice(0, count).CopyTo(destPixels); |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc /> |
|
||||
internal override void ToRgba32(ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> 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("Rgb48"); |
|
||||
GenerateConvertToMethod("Rgba64"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,177 +0,0 @@ |
|||||
// 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); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,85 +0,0 @@ |
|||||
<# |
|
||||
// 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"); |
|
||||
#> |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
File diff suppressed because it is too large
@ -1,114 +1,114 @@ |
|||||
<# |
<# |
||||
// Copyright (c) Six Labors and contributors. |
// Copyright (c) Six Labors and contributors. |
||||
// Licensed under the Apache License, Version 2.0. |
// Licensed under the Apache License, Version 2.0. |
||||
#> |
#> |
||||
<#@ template debug="false" hostspecific="false" language="C#" #> |
<#@ template debug="false" hostspecific="false" language="C#" #> |
||||
<#@ assembly name="System.Core" #> |
<#@ assembly name="System.Core" #> |
||||
<#@ import namespace="System.Linq" #> |
<#@ import namespace="System.Linq" #> |
||||
<#@ import namespace="System.Text" #> |
<#@ import namespace="System.Text" #> |
||||
<#@ import namespace="System.Collections.Generic" #> |
<#@ import namespace="System.Collections.Generic" #> |
||||
<#@ output extension=".cs" #> |
<#@ output extension=".cs" #> |
||||
// Copyright (c) Six Labors and contributors. |
// Copyright (c) Six Labors and contributors. |
||||
// Licensed under the Apache License, Version 2.0. |
// Licensed under the Apache License, Version 2.0. |
||||
|
|
||||
// <auto-generated /> |
// <auto-generated /> |
||||
using System; |
using System; |
||||
using System.Numerics; |
using System.Numerics; |
||||
using System.Buffers; |
using System.Buffers; |
||||
|
|
||||
using SixLabors.ImageSharp.Memory; |
using SixLabors.ImageSharp.Memory; |
||||
using SixLabors.Memory; |
using SixLabors.Memory; |
||||
|
|
||||
namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders |
namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders |
||||
{ |
{ |
||||
/// <summary> |
/// <summary> |
||||
/// Collection of Porter Duff alpha blending functions applying different composition models. |
/// Collection of Porter Duff alpha blending functions applying different composition models. |
||||
/// </summary> |
/// </summary> |
||||
/// <remarks> |
/// <remarks> |
||||
/// These functions are designed to be a general solution for all color cases, |
/// These functions are designed to be a general solution for all color cases, |
||||
/// that is, they take in account the alpha value of both the backdrop |
/// that is, they take in account the alpha value of both the backdrop |
||||
/// and source, and there's no need to alpha-premultiply neither the backdrop |
/// and source, and there's no need to alpha-premultiply neither the backdrop |
||||
/// nor the source. |
/// nor the source. |
||||
/// Note there are faster functions for when the backdrop color is known |
/// Note there are faster functions for when the backdrop color is known |
||||
/// to be opaque |
/// to be opaque |
||||
/// </remarks> |
/// </remarks> |
||||
internal static class DefaultPixelBlenders<TPixel> |
internal static class DefaultPixelBlenders<TPixel> |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
|
|
||||
<# |
<# |
||||
string[] composers = new []{ |
string[] composers = new []{ |
||||
"Src", |
"Src", |
||||
"SrcAtop", |
"SrcAtop", |
||||
"SrcOver", |
"SrcOver", |
||||
"SrcIn", |
"SrcIn", |
||||
"SrcOut", |
"SrcOut", |
||||
"Dest", |
"Dest", |
||||
"DestAtop", |
"DestAtop", |
||||
"DestOver", |
"DestOver", |
||||
"DestIn", |
"DestIn", |
||||
"DestOut", |
"DestOut", |
||||
"Clear", |
"Clear", |
||||
"Xor", |
"Xor", |
||||
}; |
}; |
||||
|
|
||||
string[] blenders = new []{ |
string[] blenders = new []{ |
||||
"Normal", |
"Normal", |
||||
"Multiply", |
"Multiply", |
||||
"Add", |
"Add", |
||||
"Subtract", |
"Subtract", |
||||
"Screen", |
"Screen", |
||||
"Darken", |
"Darken", |
||||
"Lighten", |
"Lighten", |
||||
"Overlay", |
"Overlay", |
||||
"HardLight" |
"HardLight" |
||||
}; |
}; |
||||
|
|
||||
foreach(var composer in composers) { |
foreach(var composer in composers) { |
||||
foreach(var blender in blenders) { |
foreach(var blender in blenders) { |
||||
|
|
||||
string blender_composer= $"{blender}{composer}"; |
string blender_composer= $"{blender}{composer}"; |
||||
|
|
||||
#> |
#> |
||||
internal class <#= blender_composer#> : PixelBlender<TPixel> |
internal class <#= blender_composer#> : PixelBlender<TPixel> |
||||
{ |
{ |
||||
/// <summary> |
/// <summary> |
||||
/// Gets the static instance of this blender. |
/// Gets the static instance of this blender. |
||||
/// </summary> |
/// </summary> |
||||
public static <#=blender_composer#> Instance { get; } = new <#=blender_composer#>(); |
public static <#=blender_composer#> Instance { get; } = new <#=blender_composer#>(); |
||||
|
|
||||
/// <inheritdoc /> |
/// <inheritdoc /> |
||||
public override TPixel Blend(TPixel background, TPixel source, float amount) |
public override TPixel Blend(TPixel background, TPixel source, float amount) |
||||
{ |
{ |
||||
TPixel dest = default; |
TPixel dest = default; |
||||
dest.PackFromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); |
dest.FromScaledVector4(PorterDuffFunctions.<#=blender_composer#>(background.ToScaledVector4(), source.ToScaledVector4(), amount.Clamp(0, 1))); |
||||
return dest; |
return dest; |
||||
} |
} |
||||
|
|
||||
/// <inheritdoc /> |
/// <inheritdoc /> |
||||
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, float amount) |
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, float amount) |
||||
{ |
{ |
||||
amount = amount.Clamp(0, 1); |
amount = amount.Clamp(0, 1); |
||||
for (int i = 0; i < destination.Length; i++) |
for (int i = 0; i < destination.Length; i++) |
||||
{ |
{ |
||||
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount); |
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
/// <inheritdoc /> |
/// <inheritdoc /> |
||||
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, ReadOnlySpan<float> amount) |
protected override void BlendFunction(Span<Vector4> destination, ReadOnlySpan<Vector4> background, ReadOnlySpan<Vector4> source, ReadOnlySpan<float> amount) |
||||
{ |
{ |
||||
for (int i = 0; i < destination.Length; i++) |
for (int i = 0; i < destination.Length; i++) |
||||
{ |
{ |
||||
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1)); |
destination[i] = PorterDuffFunctions.<#=blender_composer#>(background[i], source[i], amount[i].Clamp(0, 1)); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
<# |
<# |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
#> |
#> |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,243 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> source, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToVector4(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Argb32"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,217 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromBgr24(Configuration configuration, ReadOnlySpan<Bgr24> source, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToVector4(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, true); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgr24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Bgr24"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,243 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> source, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToVector4(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Bgra32"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,192 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromGray16(Configuration configuration, ReadOnlySpan<Gray16> source, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray16(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Gray16"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,192 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromGray8(Configuration configuration, ReadOnlySpan<Gray8> source, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Gray8> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromGray8(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Gray8"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,217 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromRgb24(Configuration configuration, ReadOnlySpan<Rgb24> source, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToVector4(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, false); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromScaledVector4(Configuration configuration, ReadOnlySpan<Vector4> sourceVectors, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.FromVector4(configuration, this, sourceVectors, destPixels, true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToScaledVector4(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Vector4> destVectors) |
||||
|
{ |
||||
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, true); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb24(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Rgb24"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,192 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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 FromRgb48(Configuration configuration, ReadOnlySpan<Rgb48> source, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Argb32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgb48(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<#@include file="_Common.ttinclude" #> |
||||
|
<#@ output extension=".cs" #> |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <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> |
||||
|
{ |
||||
|
<# |
||||
|
GenerateAllDefaultConversionMethods("Rgb48"); |
||||
|
#> |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,218 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
// <auto-generated />
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats.Utils; |
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.PixelFormats |
||||
|
{ |
||||
|
/// <content>
|
||||
|
/// Provides optimized overrides for bulk operations.
|
||||
|
/// </content>
|
||||
|
public partial struct Rgba32 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Provides optimized overrides for bulk operations.
|
||||
|
/// </summary>
|
||||
|
internal partial class PixelOperations : PixelOperations<Rgba32> |
||||
|
{ |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromRgba32(Configuration configuration, ReadOnlySpan<Rgba32> source, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
source.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
sourcePixels.CopyTo(destPixels); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Argb32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Argb32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToArgb32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromArgb32(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Argb32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromArgb32.ToRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgra32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Rgba32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Bgra32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromRgba32.ToBgra32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void FromBgra32(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Rgba32> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref uint sourceRef = ref Unsafe.As<Bgra32,uint>(ref MemoryMarshal.GetReference(sourcePixels)); |
||||
|
ref uint destRef = ref Unsafe.As<Rgba32, uint>(ref MemoryMarshal.GetReference(destPixels)); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
uint sp = Unsafe.Add(ref sourceRef, i); |
||||
|
Unsafe.Add(ref destRef, i) = PixelConverter.FromBgra32.ToRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Bgr24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Gray8> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray8 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Gray16> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Gray16 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb24> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgb48> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Rgba64> destPixels) |
||||
|
{ |
||||
|
Guard.NotNull(configuration, nameof(configuration)); |
||||
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); |
||||
|
|
||||
|
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
||||
|
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); |
||||
|
|
||||
|
for (int i = 0; i < sourcePixels.Length; i++) |
||||
|
{ |
||||
|
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); |
||||
|
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); |
||||
|
|
||||
|
dp.FromRgba32(sp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue