Пример #1
0
 public JPEGCompositeInfoChunk()
 {
     this.chunkSize        = HeaderSize;
     this.unCompressedSize = 0;
     this.imageType        = PSPDIBType.Thumbnail;
     this.imageData        = null;
 }
Пример #2
0
 public ChannelSubBlock(ushort majorVersion, uint uncompressedSize)
 {
     this.chunkSize = majorVersion > PSPConstants.majorVersion5 ? Version6HeaderSize : Version5HeaderSize;
     this.compressedChannelLength   = 0;
     this.uncompressedChannelLength = uncompressedSize;
     this.bitmapType  = PSPDIBType.Image;
     this.channelType = PSPChannelType.Composite;
     this.channelData = null;
 }
Пример #3
0
        public ChannelSubBlock(BufferedBinaryReader br, PSPCompression compression, ushort majorVersion)
        {
            this.chunkSize = majorVersion > PSPConstants.majorVersion5 ? br.ReadUInt32() : 0U;
            this.compressedChannelLength   = br.ReadUInt32();
            this.uncompressedChannelLength = br.ReadUInt32();
            this.bitmapType  = (PSPDIBType)br.ReadUInt16();
            this.channelType = (PSPChannelType)br.ReadUInt16();
            this.channelData = null;

            long dif = (long)this.chunkSize - Version6HeaderSize;

            if (dif > 0 && majorVersion > PSPConstants.majorVersion5)
            {
                br.Position += dif;
            }

            if (this.compressedChannelLength > 0U)
            {
                switch (compression)
                {
                case PSPCompression.None:
                    this.channelData = br.ReadBytes((int)this.compressedChannelLength);
                    break;

                case PSPCompression.RLE:
                    this.channelData = RLE.Decompress(br.ReadBytes((int)this.compressedChannelLength), this.uncompressedChannelLength);
                    break;

                case PSPCompression.LZ77:

                    byte[] compressedData = br.ReadBytes((int)this.compressedChannelLength);
                    this.channelData = new byte[this.uncompressedChannelLength];

                    ZlibCodec codec = new ZlibCodec
                    {
                        AvailableBytesIn  = (int)this.compressedChannelLength,
                        AvailableBytesOut = (int)this.uncompressedChannelLength,
                        InputBuffer       = compressedData,
                        OutputBuffer      = this.channelData
                    };
                    codec.InitializeInflate();

                    int status = codec.Inflate(FlushType.Finish);

                    codec.EndInflate();

                    if (status != ZlibConstants.Z_OK && status != ZlibConstants.Z_STREAM_END)
                    {
                        throw new ZlibException(codec.Message);
                    }

                    break;
                }
            }
        }
Пример #4
0
        public JPEGCompositeInfoChunk(BufferedBinaryReader br)
        {
            this.chunkSize        = br.ReadUInt32();
            this.compressedSize   = br.ReadUInt32();
            this.unCompressedSize = br.ReadUInt32();
            this.imageType        = (PSPDIBType)br.ReadUInt16();

            long dif = (long)this.chunkSize - HeaderSize;

            if (dif > 0)
            {
                br.Position += dif;
            }

            this.imageData = br.ReadBytes((int)this.compressedSize);
        }