4 #include <msp/fs/utils.h>
5 #include <msp/io/file.h>
6 #include <msp/io/memory.h>
8 #include "image_devil.h"
10 #include "image_private.h"
17 Image::Private::Private()
32 #if !defined(WITH_DEVIL) && !defined(WITH_LIBPNG)
33 throw runtime_error("no image support");
41 ilDeleteImages(1, &priv->id);
48 void Image::load_file(const string &fn)
50 string ext = FS::extpart(fn);
54 IO::BufferedFile file(fn);
55 load_png(file, *priv);
61 load_devil_file(fn, *priv);
63 throw unsupported_image_format("DevIL needed for non-PNG images");
69 void Image::load_memory(const void *data, unsigned size)
72 if(size>=8 && is_png(data, 8))
74 IO::Memory mem(reinterpret_cast<const char *>(data), size);
81 load_devil_mem(data, size, *priv);
83 throw unsupported_image_format("DevIL needed for non-PNG images");
90 PixelFormat Image::get_format() const
95 unsigned Image::get_width() const
100 unsigned Image::get_height() const
105 const void *Image::get_data() const
110 } // namespace Graphics