给定一个 PICT 图像文件(文件格式的任一版本),我如何从标题数据中读取宽度和高度?
例如,这是我为 GIF 文件确定此信息的方式:
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) {
int c1 = fs.ReadByte();
int c2 = fs.ReadByte();
int c3 = fs.ReadByte();
if (c1 == 'G' && c2 == 'I' && c3 == 'F') {
fs.Seek(3, SeekOrigin.Current);
width = ReadInt(fs, 2, false);
height = ReadInt(fs, 2, false);
return true;
}
}
// Signature for ReadInt:
// int ReadInt(FileStream fs, int bytes, bool bigEndian)