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)