Added Read method

This commit is contained in:
Leonetienne
2022-03-05 22:00:57 +01:00
parent 33932906c4
commit 808738ac2e
9 changed files with 277 additions and 17 deletions

36
Src/BmpReader.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef BMPPP_BMPREADER_H
#define BMPPP_BMPREADER_H
#include <string>
#include <fstream>
namespace Leonetienne::BmpPP {
class BMP;
class BmpReader {
public:
static bool Read(BMP& image, const std::string& filename);
private:
// Will read sizeof(T) bytes of is into buffer
template <typename T>
static std::ifstream& ReadBytes(std::ifstream& is, T& buffer) {
const std::size_t sizeofT = sizeof(T);
buffer = 0x0;
std::uint8_t buf;
for (std::size_t i = 0; i < sizeofT; i++)
{
is.read((char*)&buf, 1);
T bbuf = buf << (i * 8);
buffer |= bbuf;
}
return is;
}
};
}
#endif //BMPP_BMPREADER_H