mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.1 KiB
30 lines
1.1 KiB
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace SixLabors.ImageSharp.Formats.Tiff
|
|
{
|
|
/// <summary>
|
|
/// Class to handle cases where TIFF image data is compressed using LZW compression.
|
|
/// </summary>
|
|
internal static class LzwTiffCompression
|
|
{
|
|
/// <summary>
|
|
/// Decompresses image data into the supplied buffer.
|
|
/// </summary>
|
|
/// <param name="stream">The <see cref="Stream"/> to read image data from.</param>
|
|
/// <param name="byteCount">The number of bytes to read from the input stream.</param>
|
|
/// <param name="buffer">The output buffer for uncompressed data.</param>
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void Decompress(Stream stream, int byteCount, byte[] buffer)
|
|
{
|
|
SubStream subStream = new SubStream(stream, byteCount);
|
|
using (var decoder = new TiffLzwDecoder(subStream))
|
|
{
|
|
decoder.DecodePixels(buffer.Length, 8, buffer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|