#include "Bitmap.h" #include #include namespace msdfgen { template Bitmap::Bitmap() : pixels(NULL), w(0), h(0) { } template Bitmap::Bitmap(int width, int height) : w(width), h(height) { pixels = new T[N*w*h]; } template Bitmap::Bitmap(const BitmapConstRef &orig) : w(orig.width), h(orig.height) { pixels = new T[N*w*h]; memcpy(pixels, orig.pixels, sizeof(T)*N*w*h); } template Bitmap::Bitmap(const Bitmap &orig) : w(orig.w), h(orig.h) { pixels = new T[N*w*h]; memcpy(pixels, orig.pixels, sizeof(T)*N*w*h); } #ifdef MSDFGEN_USE_CPP11 template Bitmap::Bitmap(Bitmap &&orig) : pixels(orig.pixels), w(orig.w), h(orig.h) { orig.pixels = NULL; orig.w = 0, orig.h = 0; } #endif template Bitmap::~Bitmap() { delete [] pixels; } template Bitmap & Bitmap::operator=(const BitmapConstRef &orig) { if (pixels != orig.pixels) { delete [] pixels; w = orig.width, h = orig.height; pixels = new T[N*w*h]; memcpy(pixels, orig.pixels, sizeof(T)*N*w*h); } return *this; } template Bitmap & Bitmap::operator=(const Bitmap &orig) { if (this != &orig) { delete [] pixels; w = orig.w, h = orig.h; pixels = new T[N*w*h]; memcpy(pixels, orig.pixels, sizeof(T)*N*w*h); } return *this; } #ifdef MSDFGEN_USE_CPP11 template Bitmap & Bitmap::operator=(Bitmap &&orig) { if (this != &orig) { delete [] pixels; pixels = orig.pixels; w = orig.w, h = orig.h; orig.pixels = NULL; } return *this; } #endif template int Bitmap::width() const { return w; } template int Bitmap::height() const { return h; } template T * Bitmap::operator()(int x, int y) { return pixels+N*(w*y+x); } template const T * Bitmap::operator()(int x, int y) const { return pixels+N*(w*y+x); } template Bitmap::operator T *() { return pixels; } template Bitmap::operator const T *() const { return pixels; } template Bitmap::operator BitmapRef() { return BitmapRef(pixels, w, h); } template Bitmap::operator BitmapConstRef() const { return BitmapConstRef(pixels, w, h); } }