bmp ファイルから読み取るためのコードを次に示します (windows.h を使用)。BITMAPFILEHEADER から正しい値を読み取りますが、BITMAPINFOHEADER から読み取られるすべての値は 40 (16 進数で 28) です。なにが問題ですか?
ifstream file("d3.bmp",ios::binary);
BITMAPFILEHEADER fheader;
BITMAPINFOHEADER aImg;
ofstream fileOut("newfile5.txt",ios::app);
file.read((char*)&fheader.bfType, sizeof(WORD));
fileOut<<std::hex<<fheader.bfType<<"\n";
file.read((char*)&fheader.bfSize, sizeof(DWORD));
fileOut<<fheader.bfSize<<"\n";
file.read((char*)&fheader.bfReserved1, sizeof(WORD));
fileOut<<fheader.bfReserved1<<"\n";
file.read((char*)&fheader.bfReserved2, sizeof(WORD));
fileOut<<fheader.bfReserved2<<"\n";
file.read((char*)&fheader.bfOffBits, sizeof(DWORD));
fileOut<<fheader.bfOffBits<<"\n";
file.read((char*)&aImg.biSize,sizeof(DWORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biWidth, sizeof(LONG));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biHeight, sizeof(LONG));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biPlanes, sizeof(WORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biBitCount, sizeof(WORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biCompression, sizeof(DWORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biSizeImage, sizeof(DWORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biXPelsPerMeter, sizeof(LONG));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biYPelsPerMeter, sizeof(LONG));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biClrUsed, sizeof(DWORD));
fileOut<<aImg.biSize<<"\n";
file.read((char*)&aImg.biClrImportant, sizeof(DWORD));
fileOut<<aImg.biSize<<"\n";