|
|
|
@ -52,146 +52,182 @@ namespace SixLabors.ImageSharp.PixelFormats |
|
|
|
{ |
|
|
|
Vector4Converters.RgbaCompatible.ToVector4(configuration, this, sourcePixels, destVectors, modifiers.Remove(PixelConversionModifiers.Scale | PixelConversionModifiers.Premultiply)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToArgb32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Argb32> destinationPixels) |
|
|
|
public override void ToRgba32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Bgr24> sourcePixels, |
|
|
|
Span<Rgba32> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Rgba32, byte>(destinationPixels); |
|
|
|
PixelConverter.FromBgr24.ToRgba32(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
/// <inheritdoc />
|
|
|
|
public override void FromRgba32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Rgba32> sourcePixels, |
|
|
|
Span<Bgr24> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgba32, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); |
|
|
|
PixelConverter.FromRgba32.ToBgr24(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToBgra32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Bgra32> destinationPixels) |
|
|
|
public override void ToArgb32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Bgr24> sourcePixels, |
|
|
|
Span<Argb32> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Argb32, byte>(destinationPixels); |
|
|
|
PixelConverter.FromBgr24.ToArgb32(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
/// <inheritdoc />
|
|
|
|
public override void FromArgb32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Argb32> sourcePixels, |
|
|
|
Span<Bgr24> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Argb32, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); |
|
|
|
PixelConverter.FromArgb32.ToBgr24(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L8> destinationPixels) |
|
|
|
public override void ToBgra32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Bgr24> sourcePixels, |
|
|
|
Span<Bgra32> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Bgra32, byte>(destinationPixels); |
|
|
|
PixelConverter.FromBgr24.ToBgra32(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < sourcePixels.Length; i++) |
|
|
|
{ |
|
|
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref L8 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
/// <inheritdoc />
|
|
|
|
public override void FromBgra32( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Bgra32> sourcePixels, |
|
|
|
Span<Bgr24> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgra32, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); |
|
|
|
PixelConverter.FromBgra32.ToBgr24(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destinationPixels) |
|
|
|
public override void ToRgb24( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Bgr24> sourcePixels, |
|
|
|
Span<Rgb24> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Bgr24, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Rgb24, byte>(destinationPixels); |
|
|
|
PixelConverter.FromBgr24.ToRgb24(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < sourcePixels.Length; i++) |
|
|
|
{ |
|
|
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref L16 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
/// <inheritdoc />
|
|
|
|
public override void FromRgb24( |
|
|
|
Configuration configuration, |
|
|
|
ReadOnlySpan<Rgb24> sourcePixels, |
|
|
|
Span<Bgr24> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
ReadOnlySpan<byte> source = MemoryMarshal.Cast<Rgb24, byte>(sourcePixels); |
|
|
|
Span<byte> dest = MemoryMarshal.Cast<Bgr24, byte>(destinationPixels); |
|
|
|
PixelConverter.FromRgb24.ToBgr24(source, dest); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La16> destinationPixels) |
|
|
|
public override void ToL8(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L8> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ref L8 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
|
|
|
|
for (int i = 0; i < sourcePixels.Length; i++) |
|
|
|
{ |
|
|
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref La16 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
ref L8 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La32> destinationPixels) |
|
|
|
public override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ref L16 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
|
|
|
|
for (int i = 0; i < sourcePixels.Length; i++) |
|
|
|
{ |
|
|
|
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); |
|
|
|
ref La32 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
ref L16 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToRgb24(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgb24> destinationPixels) |
|
|
|
public override void ToLa16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La16> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ref La16 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
|
|
|
|
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); |
|
|
|
ref La16 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override void ToRgba32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Rgba32> destinationPixels) |
|
|
|
public override void ToLa32(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<La32> destinationPixels) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.DestinationShouldNotBeTooShort(sourcePixels, destinationPixels, nameof(destinationPixels)); |
|
|
|
|
|
|
|
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); |
|
|
|
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
ref La32 destRef = ref MemoryMarshal.GetReference(destinationPixels); |
|
|
|
|
|
|
|
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); |
|
|
|
ref La32 dp = ref Unsafe.Add(ref destRef, i); |
|
|
|
|
|
|
|
dp.FromBgr24(sp); |
|
|
|
} |
|
|
|
|