X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fbmploader.cpp;h=eb069a11dceea856174040ecf29427cbd36028f9;hb=1ea8498c4c729f849095e2f4aa3d282de2000a35;hp=d88e2aa6435f36f3c908bf3c274a9799a5b2339e;hpb=054fca09f0bbd64fdbd6406a0643de938a9cd4fb;p=libs%2Fgui.git diff --git a/source/graphics/bmploader.cpp b/source/graphics/bmploader.cpp index d88e2aa..eb069a1 100644 --- a/source/graphics/bmploader.cpp +++ b/source/graphics/bmploader.cpp @@ -1,5 +1,5 @@ -#include #include "bmploader.h" +#include using namespace std; @@ -15,7 +15,7 @@ void read_full(Msp::IO::Base &io, char *buffer, unsigned size) template T decode(const char *data) { - const Msp::UInt8 *udata = reinterpret_cast(data); + const uint8_t *udata = reinterpret_cast(data); T result = 0; for(unsigned i=0; i10) throw invalid_argument("BmpLoader::BmpLoader"); } -bool BmpLoader::detect(const std::string &sig) +bool BmpLoader::detect(const string &sig) { static const char bmp_sig[] = { 'B', 'M' }; if(sig.size()(bm_header+10); + unsigned data_offset = decode(bm_header+10); char dib_header[124]; read_full(io, dib_header, 12); - unsigned dib_length = min(decode(dib_header), sizeof(dib_header)); + unsigned dib_length = min(decode(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(dib_header+4); - Int32 height = decode(dib_header+8); + data.width = decode(dib_header+4); + int32_t height = decode(dib_header+8); data.height = abs(height); - unsigned color_planes = decode(dib_header+12); + unsigned color_planes = decode(dib_header+12); if(color_planes!=1) throw bad_image_data("color_planes!=1"); - unsigned bits_per_pixel = decode(dib_header+14); - unsigned compression = decode(dib_header+16); + unsigned bits_per_pixel = decode(dib_header+14); + unsigned compression = decode(dib_header+16); if(compression) throw unsupported_image_format("compression not supported"); @@ -98,7 +97,6 @@ void BmpLoader::load_headers_(Image::Data &data) void BmpLoader::load_pixels_(Image::Data &data) { - data.pixels = new char[data.stride*data.height]; if(invert_row_order) { for(unsigned y=0; y