mirror of https://github.com/SixLabors/ImageSharp
7 changed files with 105 additions and 115 deletions
@ -0,0 +1,31 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Tiff |
|||
{ |
|||
/// <summary>
|
|||
/// Enum for the different tiff encoding options.
|
|||
/// </summary>
|
|||
public enum TiffEncodingMode |
|||
{ |
|||
/// <summary>
|
|||
/// No mode specified. Will preserve the bits per pixels of the input image.
|
|||
/// </summary>
|
|||
Default = 0, |
|||
|
|||
/// <summary>
|
|||
/// The image will be encoded as RGB, 8 bit per channel.
|
|||
/// </summary>
|
|||
Rgb = 1, |
|||
|
|||
/// <summary>
|
|||
/// The image will be encoded as RGB with a color palette.
|
|||
/// </summary>
|
|||
ColorPalette = 2, |
|||
|
|||
/// <summary>
|
|||
/// The image will be encoded as 8 bit gray.
|
|||
/// </summary>
|
|||
Gray = 3, |
|||
} |
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.IO; |
|||
using ImageMagick; |
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|||
|
|||
using Xunit; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.Formats.Tiff |
|||
{ |
|||
public class TiffTestUtils |
|||
{ |
|||
public static void CompareWithReferenceDecoder<TPixel>( |
|||
TestImageProvider<TPixel> provider, |
|||
Image<TPixel> image, |
|||
bool useExactComparer = true, |
|||
float compareTolerance = 0.01f) |
|||
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel> |
|||
{ |
|||
string path = TestImageProvider<TPixel>.GetFilePathOrNull(provider); |
|||
if (path == null) |
|||
{ |
|||
throw new InvalidOperationException("CompareToOriginal() works only with file providers!"); |
|||
} |
|||
|
|||
var testFile = TestFile.Create(path); |
|||
Image<Rgba32> magickImage = DecodeWithMagick<Rgba32>(Configuration.Default, new FileInfo(testFile.FullPath)); |
|||
if (useExactComparer) |
|||
{ |
|||
ImageComparer.Exact.VerifySimilarity(magickImage, image); |
|||
} |
|||
else |
|||
{ |
|||
ImageComparer.Tolerant(compareTolerance).VerifySimilarity(magickImage, image); |
|||
} |
|||
} |
|||
|
|||
public static Image<TPixel> DecodeWithMagick<TPixel>(Configuration configuration, FileInfo fileInfo) |
|||
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel> |
|||
{ |
|||
using var magickImage = new MagickImage(fileInfo); |
|||
magickImage.AutoOrient(); |
|||
var result = new Image<TPixel>(configuration, magickImage.Width, magickImage.Height); |
|||
|
|||
Assert.True(result.TryGetSinglePixelSpan(out Span<TPixel> resultPixels)); |
|||
|
|||
using IUnsafePixelCollection<ushort> pixels = magickImage.GetPixelsUnsafe(); |
|||
byte[] data = pixels.ToByteArray(PixelMapping.RGBA); |
|||
|
|||
PixelOperations<TPixel>.Instance.FromRgba32Bytes( |
|||
configuration, |
|||
data, |
|||
resultPixels, |
|||
resultPixels.Length); |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue