Browse Source

Add Image extensions to save TIFF format files

pull/119/head
Andrew Wilkinson 9 years ago
parent
commit
b71a644bc4
  1. 53
      src/ImageSharp/Formats/Tiff/ImageExtensions.cs

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

@ -0,0 +1,53 @@
// <copyright file="ImageExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.IO;
using Formats;
/// <summary>
/// Extension methods for the <see cref="Image{TColor}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the tiff format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// </returns>
public static Image<TColor> SaveAsTiff<TColor>(this Image<TColor> source, Stream stream)
where TColor : struct, IPixel<TColor>
{
return SaveAsTiff(source, stream, null);
}
/// <summary>
/// Saves the image to the given stream with the tiff format.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="options">The options for the encoder.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
/// <returns>
/// The <see cref="Image{TColor}"/>.
/// </returns>
public static Image<TColor> SaveAsTiff<TColor>(this Image<TColor> source, Stream stream, ITiffEncoderOptions options)
where TColor : struct, IPixel<TColor>
{
TiffEncoder encoder = new TiffEncoder();
encoder.Encode(source, stream, options);
return source;
}
}
}
Loading…
Cancel
Save