Add copy constructor and operator=.
This commit is contained in:
@ -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()
|
Image::~Image()
|
||||||
{
|
{
|
||||||
free();
|
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)
|
void Image::allocate(uint w, uint h)
|
||||||
{
|
{
|
||||||
m_width = w;
|
m_width = w;
|
||||||
|
@ -13,7 +13,6 @@ namespace nv
|
|||||||
/// 32 bit RGBA image.
|
/// 32 bit RGBA image.
|
||||||
class NVIMAGE_CLASS Image
|
class NVIMAGE_CLASS Image
|
||||||
{
|
{
|
||||||
NV_FORBID_COPY(Image);
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Format
|
enum Format
|
||||||
@ -23,8 +22,12 @@ namespace nv
|
|||||||
};
|
};
|
||||||
|
|
||||||
Image();
|
Image();
|
||||||
|
Image(const Image & img);
|
||||||
~Image();
|
~Image();
|
||||||
|
|
||||||
|
const Image & operator=(const Image & img);
|
||||||
|
|
||||||
|
|
||||||
void allocate(uint w, uint h);
|
void allocate(uint w, uint h);
|
||||||
bool load(const char * name);
|
bool load(const char * name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user