Ejemplo n.º 1
0
        public LayerBitmapInfoChunk(BufferedBinaryReader br, PSPCompression compression, ushort majorVersion)
        {
            long startOffset = br.Position;

            this.chunkSize    = br.ReadUInt32();
            this.bitmapCount  = br.ReadUInt16();
            this.channelCount = br.ReadUInt16();
            this.channels     = new ChannelSubBlock[this.channelCount];

            long dif = this.chunkSize - (br.Position - startOffset);

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

            for (int i = 0; i < this.channelCount; i++)
            {
                uint head = br.ReadUInt32();
                if (head != PSPConstants.blockIdentifier)
                {
                    throw new FormatException(Properties.Resources.InvalidBlockSignature);
                }
                ushort blockID = br.ReadUInt16();
                PSPUtil.CheckBlockType(blockID, PSPBlockID.Channel);
#pragma warning disable IDE0059 // Value assigned to symbol is never used
                uint size = br.ReadUInt32();
#pragma warning restore IDE0059 // Value assigned to symbol is never used

                this.channels[i] = new ChannelSubBlock(br, compression, majorVersion);
            }
        }
Ejemplo n.º 2
0
        public CompositeImageBlock(BufferedBinaryReader br, ushort majorVersion)
        {
            this.blockSize      = br.ReadUInt32();
            this.attrChunkCount = br.ReadUInt32();

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

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

            this.attrChunks = new CompositeImageAttributesChunk[(int)this.attrChunkCount];

            for (int i = 0; i < this.attrChunkCount; i++)
            {
                uint blockSig = br.ReadUInt32();
                if (blockSig != PSPConstants.blockIdentifier)
                {
                    throw new FormatException(Properties.Resources.InvalidBlockSignature);
                }
                ushort blockType = br.ReadUInt16();
                PSPUtil.CheckBlockType(blockType, PSPBlockID.CompositeImageAttributes);
#pragma warning disable IDE0059 // Value assigned to symbol is never used
                uint attrChunkLength = br.ReadUInt32();
#pragma warning restore IDE0059 // Value assigned to symbol is never used

                this.attrChunks[i] = new CompositeImageAttributesChunk(br);
            }

            for (int i = 0; i < this.attrChunkCount; i++)
            {
                uint blockSig = br.ReadUInt32();
                if (blockSig != PSPConstants.blockIdentifier)
                {
                    throw new FormatException(Properties.Resources.InvalidBlockSignature);
                }
                PSPBlockID blockType = (PSPBlockID)br.ReadUInt16();
#pragma warning disable IDE0059 // Value assigned to symbol is never used
                uint chunkLength = br.ReadUInt32();
#pragma warning restore IDE0059 // Value assigned to symbol is never used

                switch (blockType)
                {
                case PSPBlockID.CompositeImage:
                    this.imageChunk = new CompositeImageInfoChunk(br, this.attrChunks[i], majorVersion);
                    break;

                case PSPBlockID.JPEGImage:
                    this.jpegChunk = new JPEGCompositeInfoChunk(br);
                    break;
                }
            }

            if (this.jpegChunk.imageData != null)
            {
                using (MemoryStream ms = new MemoryStream(this.jpegChunk.imageData))
                {
                    using (System.Drawing.Bitmap th = new System.Drawing.Bitmap(ms))
                    {
                        Debug.WriteLine(string.Format("JPEG thumbnail size: {0}x{1}", th.Width, th.Height));
                    }
                }
            }
        }