fmt(RGB),
width(0),
height(0),
- data(0)
+ owned_pixels(0),
+ pixels(0)
{ }
+Image::Data::Data(const Data &other):
+ fmt(other.fmt),
+ width(other.width),
+ height(other.height),
+ stride(other.stride),
+ owned_pixels(other.pixels ? new char[stride*height] : 0),
+ pixels(owned_pixels)
+{
+ if(pixels)
+ copy(other.pixels, other.pixels+stride*height, pixels);
+}
+
+Image::Data &Image::Data::operator=(const Data &other)
+{
+ delete[] owned_pixels;
+ pixels = owned_pixels = 0;
+
+ fmt = other.fmt;
+ width = other.width;
+ height = other.height;
+ stride = other.stride;
+
+ if(other.pixels)
+ {
+ pixels = owned_pixels = new char[stride*height];
+ copy(other.pixels, other.pixels+stride*height, pixels);
+ }
+
+ return *this;
+}
+
Image::Data::~Data()
{
- delete[] data;
+ delete[] owned_pixels;
}
load(*loader);
}
-void Image::load_io(IO::Base &io)
+void Image::load_io(IO::Seekable &io)
{
RefPtr<ImageLoader> loader = ImageLoader::open_io(io);
load(*loader);
void Image::load(ImageLoader &loader)
{
+ if(loader.get_state()==ImageLoader::INITIAL)
+ data = Data();
loader.load(data);
}
+void Image::load_into(ImageLoader &loader, void *buffer)
+{
+ data.pixels = reinterpret_cast<char *>(buffer);
+ load(loader);
+}
+
+void Image::load_headers(ImageLoader &loader)
+{
+ if(loader.get_state()==ImageLoader::INITIAL)
+ data = Data();
+ loader.load_headers(data);
+}
+
} // namespace Graphics
} // namespace Msp