#include "bmploader.h"
-#include <msp/core/inttypes.h>
+#include <cstdint>
using namespace std;
template<typename T>
T decode(const char *data)
{
- const Msp::UInt8 *udata = reinterpret_cast<const Msp::UInt8 *>(data);
+ const uint8_t *udata = reinterpret_cast<const uint8_t *>(data);
T result = 0;
for(unsigned i=0; i<sizeof(T); ++i)
result |= udata[i]<<(i*8);
if(!sig_bytes && (bm_header[0]!='B' || bm_header[1]!='M'))
throw bad_image_data("bitmap header mismatch");
- unsigned data_offset = decode<UInt32>(bm_header+10);
+ unsigned data_offset = decode<uint32_t>(bm_header+10);
char dib_header[124];
read_full(io, dib_header, 12);
- unsigned dib_length = min<unsigned>(decode<UInt32>(dib_header), sizeof(dib_header));
+ unsigned dib_length = min<unsigned>(decode<uint32_t>(dib_header), sizeof(dib_header));
if(dib_length<40)
throw bad_image_data("DIB header too short (very old bmp file?)");
read_full(io, dib_header+12, dib_length-12);
- data.width = decode<UInt32>(dib_header+4);
- Int32 height = decode<UInt32>(dib_header+8);
+ data.width = decode<uint32_t>(dib_header+4);
+ int32_t height = decode<uint32_t>(dib_header+8);
data.height = abs(height);
- unsigned color_planes = decode<UInt16>(dib_header+12);
+ unsigned color_planes = decode<uint16_t>(dib_header+12);
if(color_planes!=1)
throw bad_image_data("color_planes!=1");
- unsigned bits_per_pixel = decode<UInt16>(dib_header+14);
- unsigned compression = decode<UInt32>(dib_header+16);
+ unsigned bits_per_pixel = decode<uint16_t>(dib_header+14);
+ unsigned compression = decode<uint32_t>(dib_header+16);
if(compression)
throw unsupported_image_format("compression not supported");