Exemplo n.º 1
0
        /// <summary>
        /// Writes the image pixel data to the stream.
        /// </summary>
        /// <typeparam name="T">The pixel format.</typeparam>
        /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
        /// <param name="image">The <see cref="QuantizedImage{T,TP}"/> containing indexed pixels.</param>
        /// <param name="writer">The stream to write to.</param>
        private void WriteImageData <T, TP>(QuantizedImage <T, TP> image, EndianBinaryWriter writer)
            where T : IPackedVector <TP>
            where TP : struct
        {
            byte[] indexedPixels = image.Pixels;

            LzwEncoder encoder = new LzwEncoder(indexedPixels, (byte)this.bitDepth);

            encoder.Encode(writer.BaseStream);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the image pixel data to the stream.
        /// </summary>
        /// <param name="image">The <see cref="QuantizedImage"/> containing indexed pixels.</param>
        /// <param name="stream">The stream to write to.</param>
        /// <param name="bitDepth">The bit depth of the image.</param>
        private void WriteImageData(QuantizedImage image, Stream stream, int bitDepth)
        {
            byte[] indexedPixels = image.Pixels;

            LzwEncoder encoder = new LzwEncoder(indexedPixels, (byte)bitDepth);
            encoder.Encode(stream);

            this.WriteByte(stream, GifConstants.Terminator);
        }