Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HuffmanScanDecoder"/> class.
 /// </summary>
 /// <param name="stream">The input stream.</param>
 /// <param name="frame">The image frame.</param>
 /// <param name="dcHuffmanTables">The DC Huffman tables.</param>
 /// <param name="acHuffmanTables">The AC Huffman tables.</param>
 /// <param name="componentsLength">The length of the components. Different to the array length.</param>
 /// <param name="restartInterval">The reset interval.</param>
 /// <param name="spectralStart">The spectral selection start.</param>
 /// <param name="spectralEnd">The spectral selection end.</param>
 /// <param name="successiveHigh">The successive approximation bit high end.</param>
 /// <param name="successiveLow">The successive approximation bit low end.</param>
 /// <param name="cancellationToken">The token to monitor cancellation.</param>
 public HuffmanScanDecoder(
     BufferedReadStream stream,
     JpegFrame frame,
     HuffmanTable[] dcHuffmanTables,
     HuffmanTable[] acHuffmanTables,
     int componentsLength,
     int restartInterval,
     int spectralStart,
     int spectralEnd,
     int successiveHigh,
     int successiveLow,
     CancellationToken cancellationToken)
 {
     this.dctZigZag         = ZigZag.CreateUnzigTable();
     this.stream            = stream;
     this.scanBuffer        = new HuffmanScanBuffer(stream);
     this.frame             = frame;
     this.dcHuffmanTables   = dcHuffmanTables;
     this.acHuffmanTables   = acHuffmanTables;
     this.components        = frame.Components;
     this.componentsLength  = componentsLength;
     this.restartInterval   = restartInterval;
     this.todo              = restartInterval;
     this.spectralStart     = spectralStart;
     this.spectralEnd       = spectralEnd;
     this.successiveHigh    = successiveHigh;
     this.successiveLow     = successiveLow;
     this.cancellationToken = cancellationToken;
 }
Пример #2
0
        public JpegComponent(JpegFrame frame, byte id, int horizontalFactor, int verticalFactor, byte quantizationTableIndex, int index)
        {
            this.Frame = frame;
            this.Id    = id;

            // Validate sampling factors.
            if (horizontalFactor == 0 || verticalFactor == 0)
            {
                JpegThrowHelper.ThrowBadSampling();
            }

            this.HorizontalSamplingFactor = horizontalFactor;
            this.VerticalSamplingFactor   = verticalFactor;
            this.SamplingFactors          = new Size(this.HorizontalSamplingFactor, this.VerticalSamplingFactor);

            if (quantizationTableIndex > 3)
            {
                JpegThrowHelper.ThrowBadQuantizationTable();
            }

            this.QuantizationTableIndex = quantizationTableIndex;
            this.Index = index;
        }