4 #include <msp/io/file.h>
5 #include <msp/io/memory.h>
7 #include "image_devil.h"
9 #include "image_private.h"
16 Image::Private::Private()
31 #if !defined(WITH_DEVIL) && !defined(WITH_LIBPNG)
32 throw runtime_error("no image support");
40 ilDeleteImages(1, &priv->id);
47 void Image::load_file(const string &fn)
50 if(fn.size()>4 && !fn.compare(fn.size()-4, 4, ".png"))
52 IO::BufferedFile file(fn);
53 load_png(file, *priv);
59 load_devil_file(fn, *priv);
61 throw unsupported_image_format("DevIL needed for non-PNG images");
67 void Image::load_memory(const void *data, unsigned size)
70 if(size>=8 && is_png(data, 8))
72 IO::Memory mem(reinterpret_cast<const char *>(data), size);
79 load_devil_mem(data, size, *priv);
81 throw unsupported_image_format("DevIL needed for non-PNG images");
88 PixelFormat Image::get_format() const
93 unsigned Image::get_width() const
98 unsigned Image::get_height() const
103 const void *Image::get_data() const
108 } // namespace Graphics