1 #include <msp/core/refptr.h>
2 #include <msp/fs/utils.h>
3 #include <msp/io/file.h>
4 #include <msp/io/memory.h>
6 #include "imageloader.h"
21 Image::Data::Data(const Data &other):
26 owned_pixels(other.pixels ? new char[stride*height] : 0),
30 copy(other.pixels, other.pixels+stride*height, pixels);
33 Image::Data &Image::Data::operator=(const Data &other)
35 delete[] owned_pixels;
36 pixels = owned_pixels = 0;
40 height = other.height;
41 stride = other.stride;
45 pixels = owned_pixels = new char[stride*height];
46 copy(other.pixels, other.pixels+stride*height, pixels);
54 delete[] owned_pixels;
58 void Image::load_file(const string &fn)
60 RefPtr<ImageLoader> loader = ImageLoader::open_file(fn);
64 void Image::load_io(IO::Seekable &io)
66 RefPtr<ImageLoader> loader = ImageLoader::open_io(io);
70 void Image::load(ImageLoader &loader)
72 if(loader.get_state()==ImageLoader::INITIAL)
77 void Image::load_into(ImageLoader &loader, void *buffer)
79 data.pixels = reinterpret_cast<char *>(buffer);
83 void Image::load_headers(ImageLoader &loader)
85 if(loader.get_state()==ImageLoader::INITIAL)
87 loader.load_headers(data);
90 } // namespace Graphics