]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/devil/devilloader.cpp
Update .gitignore to include build products on Windows
[libs/gui.git] / source / graphics / devil / devilloader.cpp
index ab962d1d503352fbc5a44911c48817377241f872..8fbf59ccbee6150a44259437ac3f2fc78be5f02d 100644 (file)
@@ -1,7 +1,7 @@
+#include "devilloader.h"
 #include <algorithm>
 #include <msp/strings/format.h>
 #include <IL/il.h>
-#include "devilloader.h"
 
 using namespace std;
 
@@ -54,7 +54,7 @@ int tell(void *handle)
        return reinterpret_cast<Msp::IO::Seekable *>(handle)->tell();
 }
 
-std::string error_string(ILenum err)
+string error_string(ILenum err)
 {
        switch(err)
        {
@@ -101,7 +101,7 @@ bool DevilLoader::detect(const string &sig)
        return type!=IL_TYPE_UNKNOWN;
 }
 
-void DevilLoader::load(Image::Data &data)
+void DevilLoader::load_headers_(Image::Data &data)
 {
        ilSetRead(0, 0, eof, get, read, seek, tell);
        ilBindImage(id);
@@ -125,13 +125,20 @@ void DevilLoader::load(Image::Data &data)
        data.width = ilGetInteger(IL_IMAGE_WIDTH);
        data.height = ilGetInteger(IL_IMAGE_HEIGHT);
        data.stride = data.width*ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
+
+       ilBindImage(0);
+       ilResetRead();
+}
+
+void DevilLoader::load_pixels_(Image::Data &data)
+{
+       ilBindImage(id);
+
        unsigned data_size = data.stride*data.height;
-       data.data = new char[data_size];
        ILubyte *il_data = ilGetData();
-       copy(il_data, il_data+data_size, data.data);
+       copy(il_data, il_data+data_size, data.pixels);
 
        ilBindImage(0);
-       ilResetRead();
 }
 
 } // namespace Graphics