首页 新闻 会员 周边 捐助

noj检测位图长宽以及求助各位大佬第二弹呜!!!

0
悬赏园豆:5 [已关闭问题] 关闭于 2020-06-07 19:00

感谢各位大神!!!


(给各位大佬的小提示,题目里说的网站加载不出页面......)
代码在问题补充中!十分感谢!
结果如下:

这真是太令人迷惑了呜!怎么会输出这么奇怪的数字!(啊可能是我从网上查的位图资料有误?)

问题补充:
#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;
}
一条C鱼的主页 一条C鱼 | 初学一级 | 园豆:194
提问于:2020-05-18 22:44
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册