private void LoadPSPFile(Stream input) { byte[] sigBytes = new byte[32]; input.ProperRead(sigBytes, 0, sigBytes.Length); if (!CheckSig(sigBytes)) { throw new FormatException(Properties.Resources.InvalidPSPFile); } using (BufferedBinaryReader reader = new BufferedBinaryReader(input)) { this.fileHeader = new FileHeader(reader); while (reader.Position < reader.Length) { uint blockSig = reader.ReadUInt32(); if (blockSig != PSPConstants.blockIdentifier) { throw new FormatException(Properties.Resources.InvalidBlockSignature); } PSPBlockID blockID = (PSPBlockID)reader.ReadUInt16(); uint initialBlockLength = this.fileHeader.Major <= PSPConstants.majorVersion5 ? reader.ReadUInt32() : 0; uint blockLength = reader.ReadUInt32(); switch (blockID) { case PSPBlockID.ImageAttributes: this.imageAttributes = new GeneralImageAttributes(reader, this.fileHeader.Major); break; case PSPBlockID.Creator: this.creator = new CreatorBlock(reader, blockLength); break; case PSPBlockID.ColorPalette: this.globalPalette = new ColorPaletteBlock(reader, this.fileHeader.Major); break; case PSPBlockID.LayerStart: this.layerBlock = new LayerBlock(reader, this.imageAttributes, this.fileHeader.Major); break; case PSPBlockID.ExtendedData: this.extData = new ExtendedDataBlock(reader, blockLength); break; #if DEBUG case PSPBlockID.CompositeImageBank: this.compImage = new CompositeImageBlock(reader, this.fileHeader.Major); break; #endif default: reader.Position += blockLength; break; } } } }
public PSPFile() { this.fileHeader = null; this.imageAttributes = null; this.extData = null; this.creator = null; this.compImage = null; this.globalPalette = null; this.layerBlock = null; this.v5Thumbnail = null; }