Fixed memory overwrite bug. This fixes the png writer and led control.

This commit is contained in:
T. van der Zwan
2013-08-03 23:24:22 +02:00
parent 240218a6bd
commit cbbb1d740b
11 changed files with 167 additions and 166 deletions

View File

@@ -3,6 +3,7 @@
#include <cassert>
#include <cstring>
#include <vector>
// Local includes
#include "RgbColor.h"
@@ -33,13 +34,17 @@ public:
inline void copy(const RgbImage& other)
{
std::cout << "This image size: [" << width() << "x" << height() << "]. Other image size: [" << other.width() << "x" << other.height() << "]" << std::endl;
assert(other.mWidth == mWidth);
assert(other.mHeight == mHeight);
memcpy(mColors, other.mColors, mWidth*mHeight*sizeof(RgbColor));
}
RgbColor* memptr()
{
return mColors;
}
private:
inline unsigned toIndex(const unsigned x, const unsigned y) const
@@ -47,19 +52,9 @@ private:
return y*mWidth + x;
}
RgbImage(const RgbImage&)
{
// empty
}
RgbImage& operator=(const RgbImage& other)
{
return *this;
}
private:
unsigned mWidth;
unsigned mHeight;
const unsigned mWidth;
const unsigned mHeight;
/** The colors of the image */
RgbColor* mColors;