mirror of https://github.com/SixLabors/ImageSharp
2 changed files with 74 additions and 0 deletions
@ -0,0 +1,42 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.Formats.Heic; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Tests.Formats.Heic; |
||||
|
|
||||
|
[Trait("Format", "Heic")] |
||||
|
[ValidateDisposedMemoryAllocations] |
||||
|
public class HeicDecoderTests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[InlineData(TestImages.Heic.Image1)] |
||||
|
[InlineData(TestImages.Heic.Sample640x427)] |
||||
|
public void Identify(string imagePath) |
||||
|
{ |
||||
|
TestFile testFile = TestFile.Create(imagePath); |
||||
|
using MemoryStream stream = new(testFile.Bytes, false); |
||||
|
|
||||
|
ImageInfo imageInfo = Image.Identify(stream); |
||||
|
HeicMetadata heicMetadata = imageInfo.Metadata.GetHeicMetadata(); |
||||
|
|
||||
|
Assert.NotNull(imageInfo); |
||||
|
Assert.Equal(imageInfo.Metadata.DecodedImageFormat, HeicFormat.Instance); |
||||
|
//Assert.Equal(heicMetadata.Channels, channels);
|
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFile(TestImages.Heic.Image1, PixelTypes.Rgba32)] |
||||
|
[WithFile(TestImages.Heic.Sample640x427, PixelTypes.Rgba32)] |
||||
|
public void Decode<TPixel>(TestImageProvider<TPixel> provider) |
||||
|
where TPixel : unmanaged, IPixel<TPixel> |
||||
|
{ |
||||
|
using Image<TPixel> image = provider.GetImage(); |
||||
|
HeicMetadata qoiMetadata = image.Metadata.GetHeicMetadata(); |
||||
|
image.DebugSave(provider); |
||||
|
|
||||
|
image.CompareToReferenceOutput(provider); |
||||
|
//Assert.Equal(heicMetadata.Channels, channels);
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.Formats.Heic; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
||||
|
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Tests.Formats.Heic; |
||||
|
|
||||
|
[Trait("Format", "Heic")] |
||||
|
[ValidateDisposedMemoryAllocations] |
||||
|
public class HeicEncoderTests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[WithFile(TestImages.Heic.Sample640x427, PixelTypes.Rgba32)] |
||||
|
public static void Encode<TPixel>(TestImageProvider<TPixel> provider) |
||||
|
where TPixel : unmanaged, IPixel<TPixel> |
||||
|
{ |
||||
|
using Image<TPixel> image = provider.GetImage(new MagickReferenceDecoder()); |
||||
|
using MemoryStream stream = new(); |
||||
|
HeicEncoder encoder = new(); |
||||
|
image.Save(stream, encoder); |
||||
|
stream.Position = 0; |
||||
|
|
||||
|
using Image<TPixel> encodedImage = (Image<TPixel>)Image.Load(stream); |
||||
|
HeicMetadata heicMetadata = encodedImage.Metadata.GetHeicMetadata(); |
||||
|
|
||||
|
ImageComparer.Exact.CompareImages(image, encodedImage); |
||||
|
//Assert.Equal(heicMetadata.Channels, channels);
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue