2 #include <msp/core/refptr.h>
3 #include <msp/fs/utils.h>
4 #include <msp/io/file.h>
5 #include <msp/io/memory.h>
6 #include "imageloader.h"
13 Image::Data::Data(const Data &other):
18 owned_pixels(other.pixels ? new char[stride*height] : 0),
22 copy(other.pixels, other.pixels+stride*height, pixels);
25 Image::Data &Image::Data::operator=(const Data &other)
27 delete[] owned_pixels;
28 pixels = owned_pixels = 0;
32 height = other.height;
33 stride = other.stride;
37 pixels = owned_pixels = new char[stride*height];
38 copy(other.pixels, other.pixels+stride*height, pixels);
46 delete[] owned_pixels;
50 void Image::load_file(const string &fn)
52 RefPtr<ImageLoader> loader = ImageLoader::open_file(fn);
56 void Image::load_io(IO::Seekable &io)
58 RefPtr<ImageLoader> loader = ImageLoader::open_io(io);
62 void Image::load(ImageLoader &loader)
64 if(loader.get_state()==ImageLoader::INITIAL)
69 void Image::load_into(ImageLoader &loader, void *buffer)
71 data.pixels = reinterpret_cast<char *>(buffer);
75 void Image::load_headers(ImageLoader &loader)
77 if(loader.get_state()==ImageLoader::INITIAL)
79 loader.load_headers(data);
82 } // namespace Graphics