感谢各位大神!!!
(给各位大佬的小提示,题目里说的网站加载不出页面......)
代码在问题补充中!十分感谢!
结果如下:
这真是太令人迷惑了呜!怎么会输出这么奇怪的数字!(啊可能是我从网上查的位图资料有误?)
#include <iostream> #include <fstream> using namespace std; struct FILE_HEADER{ unsigned short bfType[2]; unsigned int bfSize; unsigned short bfReserved1; unsigned short bfReserved2; unsigned int bfOffBits; }; struct INFORMATION_HEADER{ unsigned int biSize; int biWidth; int biHeight; unsigned short biPlanes; unsigned short biBitCount; unsigned int biCompression; unsigned int biSizeImage; int biXPelsPerMeter; int biYPelsPerMeter; unsigned int biClrUsed; unsigned int biClrImportant; }; int main(){ FILE_HEADER h1; INFORMATION_HEADER h2; ifstream inf("DATA5611.BMP",ios::binary); if(!inf){ cerr<<"open error!"<<endl; abort(); } inf.seekg(ios::beg); inf.read((char *)&h1,sizeof(h1)); inf.seekg(sizeof(h1),ios::beg); inf.read((char *)&h2,sizeof(h2)); cout<<h2.biWidth<<" "<<h2.biHeight<<endl; inf.close(); return 0; }