Add image destructors.

master
Fabien Freling 2014-07-03 23:53:06 +02:00
parent 9e8d79d384
commit a871d92723
1 changed files with 30 additions and 0 deletions

View File

@ -6,11 +6,17 @@
#include <cassert>
#include <cstring>
#include <chrono>
#include <cstdlib>
#include <xmmintrin.h>
#include <emmintrin.h>
using namespace std;
//
//
// Point
//
template <typename T>
struct TPoint {
@ -22,15 +28,24 @@ struct TPoint {
, y(b)
{}
};
typedef TPoint<int> Point;
typedef TPoint<double> DPoint; // absolute point, can be negative
template<typename Elem, typename Traits, typename T>
std::basic_ostream<Elem, Traits>& operator << (std::basic_ostream<Elem, Traits>& o, TPoint<T> const& p)
{
o << "(" << p.x << ", " << p.y << ")";
return o;
}
//
//
// Image
//
struct Image {
unsigned int width;
unsigned int height;
@ -42,6 +57,11 @@ struct Image {
, buffer(NULL)
{}
virtual ~Image()
{
delete [] buffer;
}
Image(unsigned int w, unsigned int h)
{
this->width = w;
@ -221,6 +241,16 @@ struct TiledImage : public Image {
, nb_row_tile(0)
{}
~TiledImage()
{
unsigned int const nb_tiles = nb_col_tile * nb_row_tile;
for (unsigned int i = 0; i < nb_tiles; ++i)
{
delete [] tiles[i];
}
delete [] tiles;
}
TiledImage(unsigned int w, unsigned int h)
{
allocate_memory(w, h);