mirror of https://github.com/SixLabors/ImageSharp
7 changed files with 193 additions and 1 deletions
@ -0,0 +1,14 @@ |
|||
// <copyright file="ITiffEncoderOptions.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates the options for the <see cref="TiffEncoder"/>.
|
|||
/// </summary>
|
|||
public interface ITiffEncoderOptions : IEncoderOptions |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="TiffDecoder.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Formats |
|||
{ |
|||
using System; |
|||
using System.IO; |
|||
|
|||
/// <summary>
|
|||
/// Image decoder for generating an image out of a TIFF stream.
|
|||
/// </summary>
|
|||
public class TiffDecoder : IImageDecoder |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public void Decode<TColor>(Image<TColor> image, Stream stream, IDecoderOptions options) |
|||
where TColor : struct, IPixel<TColor> |
|||
{ |
|||
Guard.NotNull(image, "image"); |
|||
Guard.NotNull(stream, "stream"); |
|||
|
|||
using (TiffDecoderCore decoder = new TiffDecoderCore(options)) |
|||
{ |
|||
decoder.Decode(image, stream, false); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
// <copyright file="TiffDecoderCore.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Formats |
|||
{ |
|||
using System; |
|||
using System.IO; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Threading.Tasks; |
|||
|
|||
/// <summary>
|
|||
/// Performs the tiff decoding operation.
|
|||
/// </summary>
|
|||
internal class TiffDecoderCore : IDisposable |
|||
{ |
|||
/// <summary>
|
|||
/// The decoder options.
|
|||
/// </summary>
|
|||
private readonly IDecoderOptions options; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="TiffDecoderCore" /> class.
|
|||
/// </summary>
|
|||
/// <param name="options">The decoder options.</param>
|
|||
public TiffDecoderCore(IDecoderOptions options) |
|||
{ |
|||
this.options = options ?? new DecoderOptions(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the input stream.
|
|||
/// </summary>
|
|||
public Stream InputStream { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Decodes the image from the specified <see cref="Stream"/> and sets
|
|||
/// the data to image.
|
|||
/// </summary>
|
|||
/// <typeparam name="TColor">The pixel format.</typeparam>
|
|||
/// <param name="image">The image, where the data should be set to.</param>
|
|||
/// <param name="stream">The stream, where the image should be.</param>
|
|||
/// <param name="metadataOnly">Whether to decode metadata only.</param>
|
|||
public void Decode<TColor>(Image<TColor> image, Stream stream, bool metadataOnly) |
|||
where TColor : struct, IPixel<TColor> |
|||
{ |
|||
this.InputStream = stream; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Dispose
|
|||
/// </summary>
|
|||
public void Dispose() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
// <copyright file="TiffEncoder.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Formats |
|||
{ |
|||
using System; |
|||
using System.IO; |
|||
|
|||
/// <summary>
|
|||
/// Encoder for writing the data image to a stream in TIFF format.
|
|||
/// </summary>
|
|||
public class TiffEncoder : IImageEncoder |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public void Encode<TColor>(Image<TColor> image, Stream stream, IEncoderOptions options) |
|||
where TColor : struct, IPixel<TColor> |
|||
{ |
|||
ITiffEncoderOptions tiffOptions = TiffEncoderOptions.Create(options); |
|||
|
|||
this.Encode(image, stream, tiffOptions); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Encodes the image to the specified stream from the <see cref="Image{TColor}"/>.
|
|||
/// </summary>
|
|||
/// <typeparam name="TColor">The pixel format.</typeparam>
|
|||
/// <param name="image">The <see cref="Image{TColor}"/> to encode from.</param>
|
|||
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
|
|||
/// <param name="options">The options for the encoder.</param>
|
|||
public void Encode<TColor>(Image<TColor> image, Stream stream, ITiffEncoderOptions options) |
|||
where TColor : struct, IPixel<TColor> |
|||
{ |
|||
throw new NotImplementedException(); |
|||
// TiffEncoderCore encode = new TiffEncoderCore(options);
|
|||
// encode.Encode(image, stream);
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
// <copyright file="TiffEncoderOptions.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates the options for the <see cref="JTiffEncoder"/>.
|
|||
/// </summary>
|
|||
public sealed class TiffEncoderOptions : EncoderOptions, ITiffEncoderOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="TiffEncoderOptions"/> class.
|
|||
/// </summary>
|
|||
public TiffEncoderOptions() |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="TiffEncoderOptions"/> class.
|
|||
/// </summary>
|
|||
/// <param name="options">The options for the encoder.</param>
|
|||
private TiffEncoderOptions(IEncoderOptions options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Converts the options to a <see cref="ITiffEncoderOptions"/> instance with a
|
|||
/// cast or by creating a new instance with the specfied options.
|
|||
/// </summary>
|
|||
/// <param name="options">The options for the encoder.</param>
|
|||
/// <returns>The options for the <see cref="TiffEncoder"/>.</returns>
|
|||
internal static ITiffEncoderOptions Create(IEncoderOptions options) |
|||
{ |
|||
return options as ITiffEncoderOptions ?? new TiffEncoderOptions(options); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue