commit 5c69bc10341958d3818b54a96264f91f580d6c68 Author: Evgenij Titarenko Date: Thu Feb 29 17:15:12 2024 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ffe7e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +cmake-* +.idea \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8b0a302 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.27) +project(image_test_cpp) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(image_test_cpp main.cpp) diff --git a/elef.bmp b/elef.bmp new file mode 100644 index 0000000..13dff5f Binary files /dev/null and b/elef.bmp differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..b7bd61f --- /dev/null +++ b/main.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +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; +}