mirror of https://github.com/SixLabors/ImageSharp
10 changed files with 165 additions and 95 deletions
@ -0,0 +1,44 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
using System.IO; |
||||
|
using SixLabors.ImageSharp.Compression.Zlib; |
||||
|
using SixLabors.ImageSharp.Memory; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Processing.Processors.Quantization; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.Experimental.Tiff.Writers |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Utility class for writing TIFF data to a <see cref="Stream"/>.
|
||||
|
/// </summary>
|
||||
|
internal abstract class TiffBaseColorWriter |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="TiffBaseColorWriter" /> class.
|
||||
|
/// </summary>
|
||||
|
/// <param name="output">The output stream.</param>
|
||||
|
/// <param name="memoryAllocator">The memory allocator.</param>
|
||||
|
/// <param name="configuration">The configuration.</param>
|
||||
|
/// <param name="entriesCollector">The entries collector.</param>
|
||||
|
public TiffBaseColorWriter(TiffStreamWriter output, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector) |
||||
|
{ |
||||
|
this.Output = output; |
||||
|
this.MemoryAllocator = memoryAllocator; |
||||
|
this.Configuration = configuration; |
||||
|
this.EntriesCollector = entriesCollector; |
||||
|
} |
||||
|
|
||||
|
protected TiffStreamWriter Output { get; } |
||||
|
|
||||
|
protected MemoryAllocator MemoryAllocator { get; } |
||||
|
|
||||
|
protected Configuration Configuration { get; } |
||||
|
|
||||
|
protected TiffEncoderEntriesCollector EntriesCollector { get; } |
||||
|
|
||||
|
public abstract int Write<TPixel>(Image<TPixel> image, IQuantizer quantizer, TiffEncoderCompression compression, DeflateCompressionLevel compressionLevel, bool useHorizontalPredictor) |
||||
|
where TPixel : unmanaged, IPixel<TPixel>; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.Memory; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.Experimental.Tiff.Writers |
||||
|
{ |
||||
|
internal static class TiffColorWriterFactory |
||||
|
{ |
||||
|
public static TiffBaseColorWriter Create(TiffEncodingMode mode, TiffStreamWriter output, MemoryAllocator memoryAllocator, Configuration configuration, TiffEncoderEntriesCollector entriesCollector) |
||||
|
{ |
||||
|
switch (mode) |
||||
|
{ |
||||
|
case TiffEncodingMode.ColorPalette: |
||||
|
return new TiffPaletteWriter(output, memoryAllocator, configuration, entriesCollector); |
||||
|
case TiffEncodingMode.Gray: |
||||
|
return new TiffGrayWriter(output, memoryAllocator, configuration, entriesCollector); |
||||
|
case TiffEncodingMode.BiColor: |
||||
|
return new TiffBiColorWriter(output, memoryAllocator, configuration, entriesCollector); |
||||
|
default: |
||||
|
return new TiffRgbWriter(output, memoryAllocator, configuration, entriesCollector); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue