private void LoadTGAFooterInfo(BinaryReader binReader)
{
if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) {
try {
// set the cursor at the beginning of the signature string.
binReader.BaseStream.Seek((TargaConstants.FooterSignatureOffsetFromEnd * -1), SeekOrigin.End);
// read the signature bytes and convert to ascii string
string Signature = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterSignatureByteLength)).TrimEnd('\0');
// do we have a proper signature
if (string.Compare(Signature, TargaConstants.TargaFooterASCIISignature) == 0) {
// this is a NEW targa file.
// create the footer
this.eTGAFormat = TGAFormat.NEW_TGA;
// set cursor to beginning of footer info
binReader.BaseStream.Seek((TargaConstants.FooterByteLength * -1), SeekOrigin.End);
// read the Extension Area Offset value
int ExtOffset = binReader.ReadInt32();
// read the Developer Directory Offset value
int DevDirOff = binReader.ReadInt32();
// skip the signature we have already read it.
binReader.ReadBytes(TargaConstants.FooterSignatureByteLength);
// read the reserved character
string ResChar = System.Text.Encoding.ASCII.GetString(binReader.ReadBytes(TargaConstants.FooterReservedCharByteLength)).TrimEnd('\0');
// set all values to our TargaFooter class
this.objTargaFooter.SetExtensionAreaOffset(ExtOffset);
this.objTargaFooter.SetDeveloperDirectoryOffset(DevDirOff);
this.objTargaFooter.SetSignature(Signature);
this.objTargaFooter.SetReservedCharacter(ResChar);
} else {
// this is not an ORIGINAL targa file.
this.eTGAFormat = TGAFormat.ORIGINAL_TGA;
}
} catch {
// clear all
this.ClearAll();
throw;
}
} else {
this.ClearAll();
throw new Exception(@"Error loading file, could not read file from disk.");
}
}