I'm reading bytes from a PNG image via std::basic_ifstream<std::uint8_t>
. I'm having problems reading a sequence of 4 bytes that should be interpreted as 32 bit int.
std::uint32_t read_chunk_length(std::basic_ifstream<std::uint8_t> &ifs) {
std::uint32_t length;
ifs.read(reinterpret_cast<std::uint8_t*>(&length), 4);
return length;
}
When reading a sequence that is 00 00 00 0d and should thus be 0xd (or 13), the above function gives me 0xd000000 (or 218103808 instead). Apologies if the question is trivial.