Ejemplo n.º 1
0
        private static double[,] Uncompress(CompressedImage image, int degreeOfParallelism)
        {
            var allQuantizedBytes = HuffmanCodec.HuffmanCodec.Decode(image.CompressedBytes, image.DecodeTable, image.BitsCount, degreeOfParallelism);

            var result = new double[image.Height, image.Width];

            for (var y = 0; y < image.Height; y += DCTSize)
            {
                for (var x = 0; x < image.Width; x += DCTSize)
                {
                    var quantizedBytes = new byte[DCTSize * DCTSize];
                    Array.Copy(allQuantizedBytes, y * image.Width + x * DCTSize, quantizedBytes, 0, quantizedBytes.Length);
                    var quantizedFreqs = ZigZagUnScan(quantizedBytes);
                    var channelFreqs   = DeQuantize(quantizedFreqs, image.Quality);
                    var subMatrix      = DCT.IDCT2D(channelFreqs, degreeOfParallelism);
                    subMatrix.ShiftMatrixValues(128);
                    result.SetSubmatrix(subMatrix, y, x);
                }
            }
            return(result);
        }