public CompositeImageBlock(CompositeImageAttributesChunk[] attributes, JPEGCompositeInfoChunk jpg, CompositeImageInfoChunk info) { this.blockSize = HeaderSize; this.attrChunkCount = (uint)attributes.Length; this.attrChunks = attributes; this.jpegChunk = jpg; this.imageChunk = info; }
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)); } } } }