cpp-bmp-reader/main.cpp
2024-02-29 17:15:12 +03:00

27 lines
877 B
C++

#include <iostream>
#include <cstdint>
#include <filesystem>
#include <fstream>
struct BitmapFileHeader {
char signature[2] = {0, 0};
uint32_t fileSize = 0;
uint16_t reserved1 = 0;
uint16_t reserved2 = 0;
uint32_t imageDataOffset = 0;
};
const std::string FILENAME = "elef.bmp";
int main() {
BitmapFileHeader bitmapFileHeader;
{
std::ifstream ifs(FILENAME, std::ios_base::binary);
ifs.seekg(0, std::ios::beg);
ifs.read((char *) &bitmapFileHeader, 14);
}
std::cout << "Structure:\n" << "Signature: " << std::string(bitmapFileHeader.signature, 2) << "\nFile size: "
<< bitmapFileHeader.fileSize << "\nReserved 1: " << bitmapFileHeader.reserved1 << "\nReserved 2: "
<< bitmapFileHeader.reserved2 << "\nImage data offset: " << bitmapFileHeader.imageDataOffset << std::endl;
return 0;
}