Exemple #1
0
        void Decompress(Stream stream, ImageHeader h)
        {
            // No extra work is required for empty frames
            if (h.Size.Width == 0 || h.Size.Height == 0)
            {
                return;
            }

            if (recurseDepth > imageCount)
            {
                throw new InvalidDataException("Format20/40 headers contain infinite loop");
            }

            switch (h.Format)
            {
            case Format.Format20:
            case Format.Format40:
            {
                if (h.RefImage.Data == null)
                {
                    ++recurseDepth;
                    Decompress(stream, h.RefImage);
                    --recurseDepth;
                }

                h.Data = CopyImageData(h.RefImage.Data);
                Format40.DecodeInto(ReadCompressedData(stream, h), h.Data);
                break;
            }

            case Format.Format80:
            {
                var imageBytes = new byte[Size.Width * Size.Height];
                Format80.DecodeInto(ReadCompressedData(stream, h), imageBytes);
                h.Data = imageBytes;
                break;
            }

            default:
                throw new InvalidDataException();
            }
        }
Exemple #2
0
        void Decompress(Stream stream, ImageHeader h)
        {
            if (recurseDepth > ImageCount)
            {
                throw new InvalidDataException("Format20/40 headers contain infinite loop");
            }

            switch (h.Format)
            {
            case Format.Format20:
            case Format.Format40:
            {
                if (h.RefImage.Image == null)
                {
                    ++recurseDepth;
                    Decompress(stream, h.RefImage);
                    --recurseDepth;
                }

                h.Image = CopyImageData(h.RefImage.Image);
                Format40.DecodeInto(ReadCompressedData(stream, h), h.Image);
                break;
            }

            case Format.Format80:
            {
                var imageBytes = new byte[Width * Height];
                Format80.DecodeInto(ReadCompressedData(stream, h), imageBytes);
                h.Image = imageBytes;
                break;
            }

            default:
                throw new InvalidDataException();
            }
        }