mirror of https://github.com/SixLabors/ImageSharp
1 changed files with 53 additions and 0 deletions
@ -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…
Reference in new issue