Add image destructors.
This commit is contained in:
parent
9e8d79d384
commit
a871d92723
30
rotation.cpp
30
rotation.cpp
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue