mirror of https://github.com/SixLabors/ImageSharp
15 changed files with 182 additions and 31 deletions
@ -0,0 +1,51 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Formats.Tiff.Utils; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.Tiff.Utils; |
|||
|
|||
[Trait("Format", "Tiff")] |
|||
public class TiffUtilitiesTest |
|||
{ |
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0)] |
|||
[InlineData(42, 84, 128, 0)] |
|||
[InlineData(65535, 65535, 65535, 0)] |
|||
public void ColorFromRgba64Premultiplied_WithZeroAlpha_ReturnsDefaultPixel(ushort r, ushort g, ushort b, ushort a) |
|||
{ |
|||
Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied<Rgba64>(r, g, b, a); |
|||
|
|||
Assert.Equal(default, actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535)] |
|||
[InlineData(32767, 0, 0, 65535, 32767, 0, 0, 65535)] |
|||
[InlineData(0, 32767, 0, 65535, 0, 32767, 0, 65535)] |
|||
[InlineData(0, 0, 32767, 65535, 0, 0, 32767, 65535)] |
|||
public void ColorFromRgba64Premultiplied_WithNoAlpha_ReturnExpectedValues(ushort r, ushort g, ushort b, ushort a, ushort expectedR, ushort expectedG, ushort expectedB, ushort expectedA) |
|||
{ |
|||
Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied<Rgba64>(r, g, b, a); |
|||
|
|||
Assert.Equal(new Rgba64(expectedR, expectedG, expectedB, expectedA), actual); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(32766, 0, 0, 32766, 65535, 0, 0, 32766)] // Red, 50% Alpha
|
|||
[InlineData(0, 32766, 0, 32766, 0, 65535, 0, 32766)] // Green, 50% Alpha
|
|||
[InlineData(0, 0, 32766, 32766, 0, 0, 65535, 32766)] // Blue, 50% Alpha
|
|||
[InlineData(8191, 0, 0, 16383, 32765, 0, 0, 16383)] // Red, 25% Alpha
|
|||
[InlineData(0, 8191, 0, 16383, 0, 32765, 0, 16383)] // Green, 25% Alpha
|
|||
[InlineData(0, 0, 8191, 16383, 0, 0, 32765, 16383)] // Blue, 25% Alpha
|
|||
[InlineData(8191, 0, 0, 0, 0, 0, 0, 0)] // Red, 0% Alpha
|
|||
[InlineData(0, 8191, 0, 0, 0, 0, 0, 0)] // Green, 0% Alpha
|
|||
[InlineData(0, 0, 8191, 0, 0, 0, 0, 0)] // Blue, 0% Alpha
|
|||
public void ColorFromRgba64Premultiplied_WithAlpha_ReturnExpectedValues(ushort r, ushort g, ushort b, ushort a, ushort expectedR, ushort expectedG, ushort expectedB, ushort expectedA) |
|||
{ |
|||
Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied<Rgba64>(r, g, b, a); |
|||
|
|||
Assert.Equal(new Rgba64(expectedR, expectedG, expectedB, expectedA), actual); |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Formats.Webp.Chunks; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.WebP; |
|||
|
|||
[Trait("Format", "Webp")] |
|||
public class WebpVp8XTests |
|||
{ |
|||
[Fact] |
|||
public void WebpVp8X_WriteTo_Writes_Reserved_Bytes() |
|||
{ |
|||
// arrange
|
|||
WebpVp8X header = new(false, false, false, false, false, 10, 40); |
|||
MemoryStream ms = new(); |
|||
byte[] expected = [86, 80, 56, 88, 10, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 39, 0, 0]; |
|||
|
|||
// act
|
|||
header.WriteTo(ms); |
|||
|
|||
// assert
|
|||
byte[] actual = ms.ToArray(); |
|||
Assert.Equal(expected, actual); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:c33a2f63836975bdc7631f26634b3fb0ae98bfaff730300877339cb568141cde |
|||
size 124 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:e50dfa103459d21642df5e1ca760081fbdfe3b7244624d9d87d8a20f45b51bbe |
|||
size 117953 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:3333503012aa29e23f0d0e52993ad3499514251208fb3318e2bb1560d54650fa |
|||
size 117956 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:c33a2f63836975bdc7631f26634b3fb0ae98bfaff730300877339cb568141cde |
|||
size 124 |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:6e4d2db56a1b7fdea09ed65eab1d10a02952821f6662ca77caa44b8c51b30310 |
|||
size 416 |
|||
Loading…
Reference in new issue