From 7a0461b1bc66d4108cf6282bb5894cbc5f7fdc41 Mon Sep 17 00:00:00 2001 From: Ildar Khayrutdinov Date: Fri, 21 Aug 2020 17:13:27 +0300 Subject: [PATCH] Compilation errors fixes. Temporarily disable obsolete metadata related methods and tests. --- .../Formats/Tiff/ImageExtensions.cs | 4 +- .../BlackIsZero1TiffColor.cs | 2 +- .../BlackIsZero4TiffColor.cs | 2 +- .../BlackIsZero8TiffColor.cs | 2 +- .../BlackIsZeroTiffColor.cs | 2 +- .../PaletteTiffColor.cs | 4 +- .../Rgb888TiffColor.cs | 2 +- .../RgbPlanarTiffColor.cs | 2 +- .../PhotometricInterpretation/RgbTiffColor.cs | 2 +- .../WhiteIsZero1TiffColor.cs | 2 +- .../WhiteIsZero4TiffColor.cs | 2 +- .../WhiteIsZero8TiffColor.cs | 2 +- .../WhiteIsZeroTiffColor.cs | 2 +- src/ImageSharp/Formats/Tiff/TiffDecoder.cs | 24 ++++++++++-- .../Formats/Tiff/TiffDecoderCore.cs | 39 +++++++++---------- src/ImageSharp/Formats/Tiff/TiffEncoder.cs | 20 ++++++---- .../Formats/Tiff/TiffEncoderCore.cs | 22 +++++------ .../Tiff/TiffIfd/TiffIfdEntryCreator.cs | 4 +- .../Codecs/DecodeTiff.cs | 6 +-- .../DeflateTiffCompressionTests.cs | 4 +- .../PhotometricInterpretationTestBase.cs | 4 +- .../Formats/Tiff/TiffDecoderIfdEntryTests.cs | 5 +-- .../Formats/Tiff/TiffDecoderMetadataTests.cs | 16 ++++---- .../Formats/Tiff/TiffEncoderMetadataTests.cs | 16 ++++---- .../Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs | 5 +-- .../TestUtilities/Tiff/TiffIfdParser.cs | 5 +-- 26 files changed, 107 insertions(+), 93 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/ImageExtensions.cs b/src/ImageSharp/Formats/Tiff/ImageExtensions.cs index 3414f84d3b..8355a4f261 100644 --- a/src/ImageSharp/Formats/Tiff/ImageExtensions.cs +++ b/src/ImageSharp/Formats/Tiff/ImageExtensions.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp /// The . /// public static Image SaveAsTiff(this Image source, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { return SaveAsTiff(source, stream, null); } @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp /// The . /// public static Image SaveAsTiff(this Image source, Stream stream, TiffEncoder encoder) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { encoder = encoder ?? new TiffEncoder(); encoder.Encode(source, stream); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs index e317a7af7f..16659d9a5e 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs index 62fff4737c..22a765465b 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs index 949549d17b..5b9c30068c 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs index 689a305ca7..a403602ead 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, uint[] bitsPerSample, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs index 6c4bb56127..6ed0f196e5 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, uint[] bitsPerSample, uint[] colorMap, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int colorCount = (int)Math.Pow(2, bitsPerSample[0]); TPixel[] palette = GeneratePalette(colorMap, colorCount); @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff [MethodImpl(MethodImplOptions.AggressiveInlining)] private static TPixel[] GeneratePalette(uint[] colorMap, int colorCount) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel[] palette = new TPixel[colorCount]; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs index 7582220f7b..68e1c986c3 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs index df7671d760..a96d298517 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[][] data, uint[] bitsPerSample, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs index ec33417998..4dea7909af 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, uint[] bitsPerSample, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs index 2d9914de71..022b8b6f8e 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs index 965abec819..268d8fe10c 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs index fb209cecbc..bf238dcd89 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs index 8bb720bb9c..850ad418dc 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// The height of the image block. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Decode(byte[] data, uint[] bitsPerSample, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TPixel color = default(TPixel); diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoder.cs b/src/ImageSharp/Formats/Tiff/TiffDecoder.cs index 1d4521b0b6..16dc8600e4 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoder.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoder.cs @@ -1,8 +1,9 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; - +using System.Threading; +using System.Threading.Tasks; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats @@ -19,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats /// public Image Decode(Configuration configuration, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(stream, "stream"); @@ -28,5 +29,22 @@ namespace SixLabors.ImageSharp.Formats return decoder.Decode(stream); } } + + /// + public Image Decode(Configuration configuration, Stream stream) + { + throw new System.NotImplementedException(); + } + + /// + public Task> DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel + { + throw new System.NotImplementedException(); + } + + public Task DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 608c2e5583..6da36210c7 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; @@ -7,10 +7,7 @@ using System.IO; using System.Text; using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.Memory; -using SixLabors.ImageSharp.MetaData; -using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Formats { @@ -106,7 +103,7 @@ namespace SixLabors.ImageSharp.Formats /// The stream, where the image should be. /// The decoded image. public Image Decode(Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { this.InputStream = stream; @@ -199,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats /// The IFD to read the image from. /// The decoded image. public Image DecodeImage(TiffIfd ifd) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { if (!ifd.TryGetIfdEntry(TiffTags.ImageLength, out TiffIfdEntry imageLengthEntry) || !ifd.TryGetIfdEntry(TiffTags.ImageWidth, out TiffIfdEntry imageWidthEntry)) @@ -235,7 +232,7 @@ namespace SixLabors.ImageSharp.Formats /// The IFD to read the image from. /// The image to write the metadata to. public void ReadMetadata(TiffIfd ifd, Image image) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { TiffResolutionUnit resolutionUnit = (TiffResolutionUnit)this.ReadUnsignedInteger(ifd, TiffTags.ResolutionUnit, (uint)TiffResolutionUnit.Inch); @@ -246,57 +243,59 @@ namespace SixLabors.ImageSharp.Formats if (ifd.TryGetIfdEntry(TiffTags.XResolution, out TiffIfdEntry xResolutionEntry)) { Rational xResolution = this.ReadUnsignedRational(ref xResolutionEntry); - image.MetaData.HorizontalResolution = xResolution.ToDouble() * resolutionUnitFactor; + image.Metadata.HorizontalResolution = xResolution.ToDouble() * resolutionUnitFactor; } if (ifd.TryGetIfdEntry(TiffTags.YResolution, out TiffIfdEntry yResolutionEntry)) { Rational yResolution = this.ReadUnsignedRational(ref yResolutionEntry); - image.MetaData.VerticalResolution = yResolution.ToDouble() * resolutionUnitFactor; + image.Metadata.VerticalResolution = yResolution.ToDouble() * resolutionUnitFactor; } } if (!this.ignoreMetadata) { + /* if (ifd.TryGetIfdEntry(TiffTags.Artist, out TiffIfdEntry artistEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.Artist, this.ReadString(ref artistEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.Artist, this.ReadString(ref artistEntry))); } if (ifd.TryGetIfdEntry(TiffTags.Copyright, out TiffIfdEntry copyrightEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.Copyright, this.ReadString(ref copyrightEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.Copyright, this.ReadString(ref copyrightEntry))); } if (ifd.TryGetIfdEntry(TiffTags.DateTime, out TiffIfdEntry dateTimeEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.DateTime, this.ReadString(ref dateTimeEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.DateTime, this.ReadString(ref dateTimeEntry))); } if (ifd.TryGetIfdEntry(TiffTags.HostComputer, out TiffIfdEntry hostComputerEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.HostComputer, this.ReadString(ref hostComputerEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.HostComputer, this.ReadString(ref hostComputerEntry))); } if (ifd.TryGetIfdEntry(TiffTags.ImageDescription, out TiffIfdEntry imageDescriptionEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.ImageDescription, this.ReadString(ref imageDescriptionEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.ImageDescription, this.ReadString(ref imageDescriptionEntry))); } if (ifd.TryGetIfdEntry(TiffTags.Make, out TiffIfdEntry makeEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.Make, this.ReadString(ref makeEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.Make, this.ReadString(ref makeEntry))); } if (ifd.TryGetIfdEntry(TiffTags.Model, out TiffIfdEntry modelEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.Model, this.ReadString(ref modelEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.Model, this.ReadString(ref modelEntry))); } if (ifd.TryGetIfdEntry(TiffTags.Software, out TiffIfdEntry softwareEntry)) { - image.MetaData.Properties.Add(new ImageProperty(TiffMetadataNames.Software, this.ReadString(ref softwareEntry))); + image.Metadata.Properties.Add(new ImageProperty(TiffMetadataNames.Software, this.ReadString(ref softwareEntry))); } + */ } } @@ -588,7 +587,7 @@ namespace SixLabors.ImageSharp.Formats /// The width of the image block. /// The height of the image block. public void ProcessImageBlockChunky(byte[] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { switch (this.ColorType) { @@ -641,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats /// The width of the image block. /// The height of the image block. public void ProcessImageBlockPlanar(byte[][] data, Buffer2D pixels, int left, int top, int width, int height) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { switch (this.ColorType) { @@ -1232,7 +1231,7 @@ namespace SixLabors.ImageSharp.Formats /// An array of byte offsets to each strip in the image. /// An array of the size of each strip (in bytes). private void DecodeImageStrips(Image image, int rowsPerStrip, uint[] stripOffsets, uint[] stripByteCounts) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { int stripsPerPixel = this.PlanarConfiguration == TiffPlanarConfiguration.Chunky ? 1 : this.BitsPerSample.Length; int stripsPerPlane = stripOffsets.Length / stripsPerPixel; diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoder.cs b/src/ImageSharp/Formats/Tiff/TiffEncoder.cs index 63886a0751..613f216ea2 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoder.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoder.cs @@ -1,7 +1,9 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.IO; +using System.Threading; +using System.Threading.Tasks; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats @@ -11,17 +13,19 @@ namespace SixLabors.ImageSharp.Formats /// public class TiffEncoder : IImageEncoder, ITiffEncoderOptions { - /// - /// Encodes the image to the specified stream from the . - /// - /// The pixel format. - /// The to encode from. - /// The to encode the image data to. + /// public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { var encode = new TiffEncoderCore(this); encode.Encode(image, stream); } + + /// + public Task EncodeAsync(Image image, Stream stream, CancellationToken cancellationToken) + where TPixel : unmanaged, IPixel + { + throw new System.NotImplementedException(); + } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs index 9ab72f316a..8354d0f05e 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs @@ -5,10 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using SixLabors.ImageSharp.Formats.Tiff; -using SixLabors.ImageSharp.MetaData; -using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Formats { @@ -43,7 +40,7 @@ namespace SixLabors.ImageSharp.Formats /// The to encode from. /// The to encode the image data to. public void Encode(Image image, Stream stream) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { Guard.NotNull(image, nameof(image)); Guard.NotNull(stream, nameof(stream)); @@ -134,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats /// The marker to write this IFD offset. /// The marker to write the next IFD offset (if present). public long WriteImage(TiffWriter writer, Image image, long ifdOffset) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { List ifdEntries = new List(); @@ -154,13 +151,14 @@ namespace SixLabors.ImageSharp.Formats /// The to encode from. /// The metadata entries to add to the IFD. public void AddMetadata(Image image, List ifdEntries) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { - ifdEntries.AddUnsignedRational(TiffTags.XResolution, new Rational(image.MetaData.HorizontalResolution)); - ifdEntries.AddUnsignedRational(TiffTags.YResolution, new Rational(image.MetaData.VerticalResolution)); + ifdEntries.AddUnsignedRational(TiffTags.XResolution, new Rational(image.Metadata.HorizontalResolution)); + ifdEntries.AddUnsignedRational(TiffTags.YResolution, new Rational(image.Metadata.VerticalResolution)); ifdEntries.AddUnsignedShort(TiffTags.ResolutionUnit, (uint)TiffResolutionUnit.Inch); - foreach (ImageProperty metadata in image.MetaData.Properties) + /* + foreach (ImageProperty metadata in image.Metadata.Properties) { switch (metadata.Name) { @@ -212,7 +210,7 @@ namespace SixLabors.ImageSharp.Formats break; } } - } + } */ } /// @@ -222,9 +220,9 @@ namespace SixLabors.ImageSharp.Formats /// The to encode from. /// The image format entries to add to the IFD. public void AddImageFormat(Image image, List ifdEntries) - where TPixel : struct, IPixel + where TPixel : unmanaged, IPixel { throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Tiff/TiffIfd/TiffIfdEntryCreator.cs b/src/ImageSharp/Formats/Tiff/TiffIfd/TiffIfdEntryCreator.cs index 35517d1901..e0a15fd055 100644 --- a/src/ImageSharp/Formats/Tiff/TiffIfd/TiffIfdEntryCreator.cs +++ b/src/ImageSharp/Formats/Tiff/TiffIfd/TiffIfdEntryCreator.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Text; -using SixLabors.ImageSharp.MetaData.Profiles.Exif; -using SixLabors.ImageSharp.Primitives; namespace SixLabors.ImageSharp.Formats.Tiff { @@ -351,4 +349,4 @@ namespace SixLabors.ImageSharp.Formats.Tiff bytes[offset + 3] = (byte)(value >> 24); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs index dd6fc34b3e..6c11615ca5 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors and contributors. +// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System.Drawing; @@ -9,7 +9,7 @@ using BenchmarkDotNet.Attributes; using SixLabors.ImageSharp.PixelFormats; using CoreImage = SixLabors.ImageSharp.Image; -using CoreSize = SixLabors.Primitives.Size; +using CoreSize = SixLabors.ImageSharp.Size; namespace SixLabors.ImageSharp.Benchmarks.Codecs { @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs } [Benchmark(Baseline = true, Description = "System.Drawing Tiff")] - public Size TiffSystemDrawing() + public System.Drawing.Size TiffSystemDrawing() { using (MemoryStream memoryStream = new MemoryStream(this.tiffBytes)) { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs index c739adcaf1..a8a127093f 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests Stream compressedStream = new MemoryStream(); using (Stream uncompressedStream = new MemoryStream(data), - deflateStream = new ZlibDeflateStream(compressedStream, 6)) + deflateStream = new ZlibDeflateStream(Configuration.Default.MemoryAllocator, compressedStream, ImageSharp.Formats.Png.PngCompressionLevel.Level6)) { uncompressedStream.CopyTo(deflateStream); } @@ -45,4 +45,4 @@ namespace SixLabors.ImageSharp.Tests return compressedStream; } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index 1c8341fad6..4b096abbb3 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests int resultWidth = expectedResult[0].Length; int resultHeight = expectedResult.Length; Image image = new Image(resultWidth, resultHeight); - image.Mutate(x => x.Fill(DefaultColor)); + image.Mutate(x => x.BackgroundColor(DefaultColor)); Buffer2D pixels = image.GetRootFramePixelBuffer(); decodeAction(pixels); @@ -63,4 +63,4 @@ namespace SixLabors.ImageSharp.Tests } } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs index 64a5b95161..f0a9fe42e0 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs @@ -11,8 +11,7 @@ namespace SixLabors.ImageSharp.Tests using ImageSharp.Formats; using ImageSharp.Formats.Tiff; - using SixLabors.ImageSharp.MetaData.Profiles.Exif; - using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Metadata.Profiles.Exif; public class TiffDecoderIfdEntryTests { @@ -843,4 +842,4 @@ namespace SixLabors.ImageSharp.Tests return (decoder, ifdEntry); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs index 6766ba80f7..3ddd0e9a13 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs @@ -77,10 +77,10 @@ namespace SixLabors.ImageSharp.Tests decoder.ReadMetadata(ifd, image); - Assert.Equal(expectedHorizonalResolution, image.MetaData.HorizontalResolution, 10); - Assert.Equal(expectedVerticalResolution, image.MetaData.VerticalResolution, 10); + Assert.Equal(expectedHorizonalResolution, image.Metadata.HorizontalResolution, 10); + Assert.Equal(expectedVerticalResolution, image.Metadata.VerticalResolution, 10); } - + /* [Theory] [MemberData(nameof(BaselineMetadataValues))] public void ReadMetadata_SetsAsciiMetadata(bool isLittleEndian, ushort tag, string metadataName, string metadataValue) @@ -102,10 +102,10 @@ namespace SixLabors.ImageSharp.Tests Image image = new Image(null, 20, 20); decoder.ReadMetadata(ifd, image); - var metadata = image.MetaData.Properties.FirstOrDefault(m => m.Name == metadataName).Value; + var metadata = image.Metadata.Properties.FirstOrDefault(m => m.Name == metadataName).Value; Assert.Equal(metadataValue, metadata); - } + } [Theory] [MemberData(nameof(BaselineMetadataValues))] @@ -129,9 +129,9 @@ namespace SixLabors.ImageSharp.Tests Image image = new Image(null, 20, 20); decoder.ReadMetadata(ifd, image); - var metadata = image.MetaData.Properties.FirstOrDefault(m => m.Name == metadataName).Value; + var metadata = image.Metadata.Properties.FirstOrDefault(m => m.Name == metadataName).Value; Assert.Null(metadata); - } + } */ } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs index c90d77f4a6..31ff39c97b 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs @@ -11,9 +11,8 @@ namespace SixLabors.ImageSharp.Tests using ImageSharp.Formats.Tiff; using System.Collections.Generic; - using SixLabors.ImageSharp.MetaData; - using SixLabors.ImageSharp.MetaData.Profiles.Exif; - using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Metadata; + using SixLabors.ImageSharp.Metadata.Profiles.Exif; public class TiffEncoderMetadataTests { @@ -30,8 +29,8 @@ namespace SixLabors.ImageSharp.Tests public void AddMetadata_SetsImageResolution() { Image image = new Image(100, 100); - image.MetaData.HorizontalResolution = 40.0; - image.MetaData.VerticalResolution = 50.5; + image.Metadata.HorizontalResolution = 40.0; + image.Metadata.VerticalResolution = 50.5; TiffEncoderCore encoder = new TiffEncoderCore(null); List ifdEntries = new List(); @@ -42,18 +41,19 @@ namespace SixLabors.ImageSharp.Tests Assert.Equal(TiffResolutionUnit.Inch, (TiffResolutionUnit?)ifdEntries.GetInteger(TiffTags.ResolutionUnit)); } + /* [Theory] [MemberData(nameof(BaselineMetadataValues))] public void AddMetadata_SetsAsciiMetadata(ushort tag, string metadataName, string metadataValue) { Image image = new Image(100, 100); - image.MetaData.Properties.Add(new ImageProperty(metadataName, metadataValue)); + image.Metadata.Properties.Add(new ImageProperty(metadataName, metadataValue)); TiffEncoderCore encoder = new TiffEncoderCore(null); List ifdEntries = new List(); encoder.AddMetadata(image, ifdEntries); Assert.Equal(metadataValue + "\0", ifdEntries.GetAscii(tag)); - } + } */ } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs index 7c0f55ee70..e203cc9f1b 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs @@ -10,8 +10,7 @@ namespace SixLabors.ImageSharp.Tests using ImageSharp.Formats.Tiff; - using SixLabors.ImageSharp.MetaData.Profiles.Exif; - using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Metadata.Profiles.Exif; public class TiffIfdEntryCreatorTests { @@ -406,4 +405,4 @@ namespace SixLabors.ImageSharp.Tests Assert.Equal(bytes, entry.Value); } } -} \ No newline at end of file +} diff --git a/tests/ImageSharp.Tests/TestUtilities/Tiff/TiffIfdParser.cs b/tests/ImageSharp.Tests/TestUtilities/Tiff/TiffIfdParser.cs index 55e95dc7f1..d58e273401 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tiff/TiffIfdParser.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tiff/TiffIfdParser.cs @@ -9,8 +9,7 @@ namespace SixLabors.ImageSharp.Tests using System.Text; using ImageSharp.Formats.Tiff; - using SixLabors.ImageSharp.MetaData.Profiles.Exif; - using SixLabors.ImageSharp.Primitives; + using SixLabors.ImageSharp.Metadata.Profiles.Exif; using Xunit; /// @@ -75,4 +74,4 @@ namespace SixLabors.ImageSharp.Tests return Encoding.UTF8.GetString(entry.Value, 0, (int)entry.Count); } } -} \ No newline at end of file +}