]> 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 cb6a1b6251764a29fd90cc7c0a36c3e509e9a991..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)
        {
@@ -74,8 +74,6 @@ std::string error_string(ILenum err)
 namespace Msp {
 namespace Graphics {
 
-ImageLoader::Register<DevilLoader> DevilLoader::reg;
-
 DevilLoader::DevilLoader(IO::Seekable &i):
        io(i)
 {
@@ -103,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);
@@ -126,14 +124,22 @@ void DevilLoader::load(Image::Data &data)
 
        data.width = ilGetInteger(IL_IMAGE_WIDTH);
        data.height = ilGetInteger(IL_IMAGE_HEIGHT);
-       unsigned data_size = data.width*data.height*ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
-       data.data = new char[data_size];
-       ILubyte *il_data = ilGetData();
-       copy(il_data, il_data+data_size, data.data);
+       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;
+       ILubyte *il_data = ilGetData();
+       copy(il_data, il_data+data_size, data.pixels);
+
+       ilBindImage(0);
+}
+
 } // namespace Graphics
 } // namespace Msp