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, 0, 0);
61 load_devil_file(fn, *priv);
63 throw unsupported_image_format("DevIL needed for non-PNG images");
69 void Image::load_io(IO::Base &io)
72 unsigned sig_len = io.read(sig_buf, sizeof(sig_buf));
74 if(sig_len==sizeof(sig_buf) && is_png(sig_buf, sig_len))
75 load_png(io, *priv, sig_buf, sig_len);
80 load_devil_io(io, *priv, sig_buf, sig_len);
82 throw unsupported_image_format("DevIL needed for non-PNG images");
87 PixelFormat Image::get_format() const
92 unsigned Image::get_width() const
97 unsigned Image::get_height() const
102 const void *Image::get_data() const
107 } // namespace Graphics