]> git.tdb.fi Git - libs/gui.git/commitdiff
Use standard fixed size integer types
authorMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 10:13:08 +0000 (12:13 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 27 Nov 2022 14:20:17 +0000 (16:20 +0200)
Those in quartzloader.cpp are apparently Apple's types and are
appropriate there.

source/graphics/bmploader.cpp

index 582edc6d233afb952eb542aa9cedbec8cb648805..8a6c7a00872275211f2f17cfb48f62d8283c3d5b 100644 (file)
@@ -1,5 +1,5 @@
 #include "bmploader.h"
-#include <msp/core/inttypes.h>
+#include <cstdint>
 
 using namespace std;
 
@@ -15,7 +15,7 @@ void read_full(Msp::IO::Base &io, char *buffer, unsigned size)
 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);
@@ -53,25 +53,25 @@ void BmpLoader::load_headers_(Image::Data &data)
        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");