X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fimage.cpp;h=a0e6e380ad24d54b20c5144c6001208147f9dbc5;hb=8e58f5bca4258e73e84e604ff2573fe9713b7b3f;hp=3e1124faaf06800158413189c054529db2ca4060;hpb=cfd3548464e6424fc9decf0539d6cd04b031ba10;p=libs%2Fgui.git diff --git a/source/graphics/image.cpp b/source/graphics/image.cpp index 3e1124f..a0e6e38 100644 --- a/source/graphics/image.cpp +++ b/source/graphics/image.cpp @@ -17,6 +17,36 @@ Image::Data::Data(): data(0) { } +Image::Data::Data(const Data &other): + fmt(other.fmt), + width(other.width), + height(other.height), + stride(other.stride), + data(other.data ? new char[stride*height] : 0) +{ + if(data) + copy(other.data, other.data+stride*height, data); +} + +Image::Data &Image::Data::operator=(const Data &other) +{ + delete[] data; + data = 0; + + fmt = other.fmt; + width = other.width; + height = other.height; + stride = other.stride; + + if(other.data) + { + data = new char[stride*height]; + copy(other.data, other.data+stride*height, data); + } + + return *this; +} + Image::Data::~Data() { delete[] data; @@ -29,7 +59,7 @@ void Image::load_file(const string &fn) load(*loader); } -void Image::load_io(IO::Base &io) +void Image::load_io(IO::Seekable &io) { RefPtr loader = ImageLoader::open_io(io); load(*loader);