]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/image.cpp
Replace Image::load_memory with load_io
[libs/gui.git] / source / graphics / image.cpp
index 5d2a21bb66e969d85da76f34811d4ff5e1f9836b..46c2b3fab3c29f0ce952133b1d55966531252e94 100644 (file)
@@ -52,7 +52,7 @@ void Image::load_file(const string &fn)
        if(ext==".png")
        {
                IO::BufferedFile file(fn);
-               load_png(file, *priv);
+               load_png(file, *priv, 0, 0);
        }
        else
 #endif
@@ -66,25 +66,22 @@ void Image::load_file(const string &fn)
        (void)fn;
 }
 
-void Image::load_memory(const void *data, unsigned size)
+void Image::load_io(IO::Base &io)
 {
+       char sig_buf[8];
+       unsigned sig_len = io.read(sig_buf, sizeof(sig_buf));
 #ifdef WITH_LIBPNG
-       if(size>=8 && is_png(data, 8))
-       {
-               IO::Memory mem(reinterpret_cast<const char *>(data), size);
-               load_png(mem, *priv);
-       }
+       if(sig_len==sizeof(sig_buf) && is_png(sig_buf, sig_len))
+               load_png(io, *priv, sig_buf, sig_len);
        else
 #endif
        {
 #ifdef WITH_DEVIL
-               load_devil_mem(data, size, *priv);
+               load_devil_io(io, *priv, sig_buf, sig_len);
 #else
                throw unsupported_image_format("DevIL needed for non-PNG images");
 #endif
        }
-       (void)data;
-       (void)size;
 }
 
 PixelFormat Image::get_format() const