jdtt 2020-05-16 19:26 采纳率: 66.7%
浏览 154

noj检测位图长宽。绝望了啊啊啊啊

啊绝望了,求各位大佬看一下我的代码

PS:我知道可能会有各种问题,但题目给出的网站显示“页面不存在”啊啊啊!

图片说明

图片说明

截图可能有点重复,但不影响各位大佬的阅读!下面是我的代码:

感谢各位!!!

#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();
}
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-09-23 13:44
    关注
    评论

报告相同问题?