From b3a07e21f7a7341cd77ee133a812a08d5e4b1d68 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sat, 31 Aug 2013 16:37:07 -0400 Subject: [PATCH] Add assignment operator --- PVRTCEncoder/src/Image.cpp | 8 ++++++++ PVRTCEncoder/src/Image.h | 1 + 2 files changed, 9 insertions(+) diff --git a/PVRTCEncoder/src/Image.cpp b/PVRTCEncoder/src/Image.cpp index baff30c..7335ccb 100644 --- a/PVRTCEncoder/src/Image.cpp +++ b/PVRTCEncoder/src/Image.cpp @@ -84,6 +84,14 @@ Image::Image(const Image &other) memcpy(m_Pixels, other.m_Pixels, m_Width * m_Height * sizeof(Pixel)); } +Image &Image::operator=(const Image &other) { + m_Width = other.m_Width; + m_Height = other.m_Height; + m_Pixels = new Pixel[other.m_Width * other.m_Height]; + memcpy(m_Pixels, other.m_Pixels, m_Width * m_Height * sizeof(Pixel)); + return *this; +} + Image::~Image() { assert(m_Pixels); delete [] m_Pixels; diff --git a/PVRTCEncoder/src/Image.h b/PVRTCEncoder/src/Image.h index 286ed67..5ab8ebb 100644 --- a/PVRTCEncoder/src/Image.h +++ b/PVRTCEncoder/src/Image.h @@ -65,6 +65,7 @@ class Image { Image(uint32 height, uint32 width); Image(uint32 height, uint32 width, const Pixel *pixels); Image(const Image &); + Image &operator=(const Image &); ~Image(); void BilinearUpscale(uint32 times, EWrapMode wrapMode = eWrapMode_Clamp);