fmt(RGB),
width(0),
height(0),
+ owned_pixels(0),
pixels(0)
{ }
width(other.width),
height(other.height),
stride(other.stride),
- pixels(other.pixels ? new char[stride*height] : 0)
+ 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[] pixels;
- pixels = 0;
+ delete[] owned_pixels;
+ pixels = owned_pixels = 0;
fmt = other.fmt;
width = other.width;
if(other.pixels)
{
- pixels = new char[stride*height];
+ pixels = owned_pixels = new char[stride*height];
copy(other.pixels, other.pixels+stride*height, pixels);
}
Image::Data::~Data()
{
- delete[] pixels;
+ delete[] owned_pixels;
}
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