mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
17 changed files with 188 additions and 3 deletions
@ -0,0 +1,49 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System; |
|||
using System.Buffers; |
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorSpaces; |
|||
using SixLabors.ImageSharp.ColorSpaces.Conversion; |
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation |
|||
{ |
|||
/// <summary>
|
|||
/// Implements decoding pixel data with photometric interpretation of type 'CieLab' with the planar configuration.
|
|||
/// </summary>
|
|||
internal class CieLabPlanarTiffColor<TPixel> : TiffBasePlanarColorDecoder<TPixel> |
|||
where TPixel : unmanaged, IPixel<TPixel> |
|||
{ |
|||
private static readonly ColorSpaceConverter ColorSpaceConverter = new(); |
|||
|
|||
private const float Inv255 = 1.0f / 255.0f; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override void Decode(IMemoryOwner<byte>[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height) |
|||
{ |
|||
Span<byte> l = data[0].GetSpan(); |
|||
Span<byte> a = data[1].GetSpan(); |
|||
Span<byte> b = data[2].GetSpan(); |
|||
|
|||
var color = default(TPixel); |
|||
int offset = 0; |
|||
for (int y = top; y < top + height; y++) |
|||
{ |
|||
Span<TPixel> pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); |
|||
for (int x = 0; x < pixelRow.Length; x++) |
|||
{ |
|||
var lab = new CieLab((l[offset] & 0xFF) * 100f * Inv255, (sbyte)a[offset], (sbyte)b[offset]); |
|||
var rgb = ColorSpaceConverter.ToRgb(lab); |
|||
|
|||
color.FromVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); |
|||
pixelRow[x] = color; |
|||
|
|||
offset++; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System; |
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorSpaces; |
|||
using SixLabors.ImageSharp.ColorSpaces.Conversion; |
|||
using SixLabors.ImageSharp.Memory; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation |
|||
{ |
|||
/// <summary>
|
|||
/// Implements decoding pixel data with photometric interpretation of type 'CieLab'.
|
|||
/// </summary>
|
|||
internal class CieLabTiffColor<TPixel> : TiffBaseColorDecoder<TPixel> |
|||
where TPixel : unmanaged, IPixel<TPixel> |
|||
{ |
|||
private static readonly ColorSpaceConverter ColorSpaceConverter = new(); |
|||
|
|||
private const float Inv255 = 1.0f / 255.0f; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override void Decode(ReadOnlySpan<byte> data, Buffer2D<TPixel> pixels, int left, int top, int width, int height) |
|||
{ |
|||
var color = default(TPixel); |
|||
int offset = 0; |
|||
for (int y = top; y < top + height; y++) |
|||
{ |
|||
Span<TPixel> pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); |
|||
|
|||
for (int x = 0; x < pixelRow.Length; x++) |
|||
{ |
|||
float l = (data[offset] & 0xFF) * 100f * Inv255; |
|||
var lab = new CieLab(l, (sbyte)data[offset + 1], (sbyte)data[offset + 2]); |
|||
var rgb = ColorSpaceConverter.ToRgb(lab); |
|||
|
|||
color.FromVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); |
|||
pixelRow[x] = color; |
|||
|
|||
offset += 3; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:13bc9da102f85124855217fad757ca907f5d68442e54e3b7039ac048d7b2ad3f |
|||
size 25791 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:13bc9da102f85124855217fad757ca907f5d68442e54e3b7039ac048d7b2ad3f |
|||
size 25791 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:6f9481c91c58ca7bbab9de4b9ae95fe4a2197ae4b6ef6b15b72d4858aba3a1a4 |
|||
size 25782 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:7542b5b3abe049614f2ddaf78ffe995edac13e768f0b2fc9f324c6ef43b379eb |
|||
size 1312046 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:28592d9da8d51f60700b7136369d2d6bd40550d5f8c7758e570b5e624c71a3e4 |
|||
size 1307488 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:6affced5550e51441c4cde7f1770d4e57cfa594bd271a12f9571359733c2185d |
|||
size 55346 |
|||
Loading…
Reference in new issue