Add copy constructor and operator=.

2.0
castano 17 years ago
parent 3b24951e93
commit 79d305008a

@ -15,11 +15,27 @@ Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL)
{
}
Image::Image(const Image & img)
{
allocate(img.m_width, img.m_height);
m_format = img.m_format;
memcpy(m_data, img.m_data, sizeof(Color32) * m_width * m_height);
}
Image::~Image()
{
free();
}
const Image & Image::operator=(const Image & img)
{
allocate(img.m_width, img.m_height);
m_format = img.m_format;
memcpy(m_data, img.m_data, sizeof(Color32) * m_width * m_height);
return *this;
}
void Image::allocate(uint w, uint h)
{
m_width = w;

@ -13,7 +13,6 @@ namespace nv
/// 32 bit RGBA image.
class NVIMAGE_CLASS Image
{
NV_FORBID_COPY(Image);
public:
enum Format
@ -23,8 +22,12 @@ namespace nv
};
Image();
Image(const Image & img);
~Image();
const Image & operator=(const Image & img);
void allocate(uint w, uint h);
bool load(const char * name);

Loading…
Cancel
Save