Browse Source

Compilation errors fixes. Temporarily disable obsolete metadata related methods and tests.

pull/1570/head
Ildar Khayrutdinov 6 years ago
parent
commit
7a0461b1bc
  1. 4
      src/ImageSharp/Formats/Tiff/ImageExtensions.cs
  2. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs
  3. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs
  4. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs
  5. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs
  6. 4
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs
  7. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs
  8. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs
  9. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs
  10. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs
  11. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs
  12. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs
  13. 2
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs
  14. 24
      src/ImageSharp/Formats/Tiff/TiffDecoder.cs
  15. 39
      src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
  16. 20
      src/ImageSharp/Formats/Tiff/TiffEncoder.cs
  17. 22
      src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs
  18. 4
      src/ImageSharp/Formats/Tiff/TiffIfd/TiffIfdEntryCreator.cs
  19. 6
      tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs
  20. 4
      tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs
  21. 4
      tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs
  22. 5
      tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs
  23. 16
      tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs
  24. 16
      tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs
  25. 5
      tests/ImageSharp.Tests/Formats/Tiff/TiffIfd/TiffIfdEntryCreatorTests.cs
  26. 5
      tests/ImageSharp.Tests/TestUtilities/Tiff/TiffIfdParser.cs

4
src/ImageSharp/Formats/Tiff/ImageExtensions.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp
/// The <see cref="Image{TPixel}"/>.
/// </returns>
public static Image<TPixel> SaveAsTiff<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
return SaveAsTiff(source, stream, null);
}
@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp
/// The <see cref="Image{TPixel}"/>.
/// </returns>
public static Image<TPixel> SaveAsTiff<TPixel>(this Image<TPixel> source, Stream stream, TiffEncoder encoder)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
encoder = encoder ?? new TiffEncoder();
encoder.Encode(source, stream);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero8TiffColor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, uint[] bitsPerSample, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

4
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor.cs

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, uint[] bitsPerSample, uint[] colorMap, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
int colorCount = (int)Math.Pow(2, bitsPerSample[0]);
TPixel[] palette = GeneratePalette<TPixel>(colorMap, colorCount);
@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static TPixel[] GeneratePalette<TPixel>(uint[] colorMap, int colorCount)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel[] palette = new TPixel[colorCount];

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb888TiffColor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[][] data, uint[] bitsPerSample, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, uint[] bitsPerSample, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor.cs

@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

2
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <param name="height">The height of the image block.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Decode<TPixel>(byte[] data, uint[] bitsPerSample, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
TPixel color = default(TPixel);

24
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
/// <inheritdoc/>
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
Guard.NotNull(stream, "stream");
@ -28,5 +29,22 @@ namespace SixLabors.ImageSharp.Formats
return decoder.Decode<TPixel>(stream);
}
}
/// <inheritdoc/>
public Image Decode(Configuration configuration, Stream stream)
{
throw new System.NotImplementedException();
}
/// <inheritdoc/>
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>
{
throw new System.NotImplementedException();
}
public Task<Image> DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken)
{
throw new System.NotImplementedException();
}
}
}

39
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
/// <param name="stream">The stream, where the image should be.</param>
/// <returns>The decoded image.</returns>
public Image<TPixel> Decode<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
this.InputStream = stream;
@ -199,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="ifd">The IFD to read the image from.</param>
/// <returns>The decoded image.</returns>
public Image<TPixel> DecodeImage<TPixel>(TiffIfd ifd)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
if (!ifd.TryGetIfdEntry(TiffTags.ImageLength, out TiffIfdEntry imageLengthEntry)
|| !ifd.TryGetIfdEntry(TiffTags.ImageWidth, out TiffIfdEntry imageWidthEntry))
@ -235,7 +232,7 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="ifd">The IFD to read the image from.</param>
/// <param name="image">The image to write the metadata to.</param>
public void ReadMetadata<TPixel>(TiffIfd ifd, Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
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
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
public void ProcessImageBlockChunky<TPixel>(byte[] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
switch (this.ColorType)
{
@ -641,7 +640,7 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="width">The width of the image block.</param>
/// <param name="height">The height of the image block.</param>
public void ProcessImageBlockPlanar<TPixel>(byte[][] data, Buffer2D<TPixel> pixels, int left, int top, int width, int height)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
switch (this.ColorType)
{
@ -1232,7 +1231,7 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="stripOffsets">An array of byte offsets to each strip in the image.</param>
/// <param name="stripByteCounts">An array of the size of each strip (in bytes).</param>
private void DecodeImageStrips<TPixel>(Image<TPixel> image, int rowsPerStrip, uint[] stripOffsets, uint[] stripByteCounts)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
int stripsPerPixel = this.PlanarConfiguration == TiffPlanarConfiguration.Chunky ? 1 : this.BitsPerSample.Length;
int stripsPerPlane = stripOffsets.Length / stripsPerPixel;

20
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
/// </summary>
public class TiffEncoder : IImageEncoder, ITiffEncoderOptions
{
/// <summary>
/// Encodes the image to the specified stream from the <see cref="Image{TPixel}"/>.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
/// <inheritdoc/>
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
var encode = new TiffEncoderCore(this);
encode.Encode(image, stream);
}
/// <inheritdoc/>
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
{
throw new System.NotImplementedException();
}
}
}

22
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
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@ -134,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="ifdOffset">The marker to write this IFD offset.</param>
/// <returns>The marker to write the next IFD offset (if present).</returns>
public long WriteImage<TPixel>(TiffWriter writer, Image<TPixel> image, long ifdOffset)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
List<TiffIfdEntry> ifdEntries = new List<TiffIfdEntry>();
@ -154,13 +151,14 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="ifdEntries">The metadata entries to add to the IFD.</param>
public void AddMetadata<TPixel>(Image<TPixel> image, List<TiffIfdEntry> ifdEntries)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
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;
}
}
}
} */
}
/// <summary>
@ -222,9 +220,9 @@ namespace SixLabors.ImageSharp.Formats
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
/// <param name="ifdEntries">The image format entries to add to the IFD.</param>
public void AddImageFormat<TPixel>(Image<TPixel> image, List<TiffIfdEntry> ifdEntries)
where TPixel : struct, IPixel<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
throw new NotImplementedException();
}
}
}
}

4
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);
}
}
}
}

6
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))
{

4
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;
}
}
}
}

4
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<Rgba32> image = new Image<Rgba32>(resultWidth, resultHeight);
image.Mutate(x => x.Fill(DefaultColor));
image.Mutate(x => x.BackgroundColor(DefaultColor));
Buffer2D<Rgba32> pixels = image.GetRootFramePixelBuffer();
decodeAction(pixels);
@ -63,4 +63,4 @@ namespace SixLabors.ImageSharp.Tests
}
}
}
}
}

5
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);
}
}
}
}

16
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs

@ -77,10 +77,10 @@ namespace SixLabors.ImageSharp.Tests
decoder.ReadMetadata<Rgba32>(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<Rgba32> image = new Image<Rgba32>(null, 20, 20);
decoder.ReadMetadata<Rgba32>(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<Rgba32> image = new Image<Rgba32>(null, 20, 20);
decoder.ReadMetadata<Rgba32>(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);
}
} */
}
}
}

16
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<Rgba32> image = new Image<Rgba32>(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<TiffIfdEntry> ifdEntries = new List<TiffIfdEntry>();
@ -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<Rgba32> image = new Image<Rgba32>(100, 100);
image.MetaData.Properties.Add(new ImageProperty(metadataName, metadataValue));
image.Metadata.Properties.Add(new ImageProperty(metadataName, metadataValue));
TiffEncoderCore encoder = new TiffEncoderCore(null);
List<TiffIfdEntry> ifdEntries = new List<TiffIfdEntry>();
encoder.AddMetadata(image, ifdEntries);
Assert.Equal(metadataValue + "\0", ifdEntries.GetAscii(tag));
}
} */
}
}
}

5
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);
}
}
}
}

5
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;
/// <summary>
@ -75,4 +74,4 @@ namespace SixLabors.ImageSharp.Tests
return Encoding.UTF8.GetString(entry.Value, 0, (int)entry.Count);
}
}
}
}

Loading…
Cancel
Save