+#include <string.h>
+
+#include "imago2.h"
+#include "image.h"
+
+Image::Image()
+{
+ w = h = 0;
+ pixels = 0;
+}
+
+Image::~Image()
+{
+ delete [] pixels;
+}
+
+Image::Image(const Image &image)
+{
+ w = image.w;
+ h = image.h;
+
+ pixels = new unsigned char[w * h * 4];
+ memcpy(pixels, image.pixels, w * h * 4);
+}
+
+Image &Image::operator =(const Image &image)
+{
+ if(&image == this)
+ return *this;
+
+ delete [] pixels;
+
+ w = image.w;
+ h = image.h;
+
+ pixels = new unsigned char[w * h * 4];
+ memcpy(pixels, image.pixels, w * h * 4);
+
+ return *this;
+}
+
+Image::Image(Image &&image)
+{
+ w = image.w;
+ h = image.h;
+
+ pixels = image.pixels;
+ image.pixels = 0;
+}
+
+Image &Image::operator =(Image &&image)
+{
+ if(&image == this)
+ return *this;
+
+ delete [] pixels;
+
+ w = image.w;
+ h = image.h;
+
+ pixels = image.pixels;
+ image.pixels = 0;
+
+ return *this;
+}
+
+bool Image::load(const char *fname)
+{
+ unsigned char *imago_pixels;
+ if(!(imago_pixels = (unsigned char *)img_load_pixels(fname, &w, &h))) {
+ fprintf(stderr, "Failed to load pixels from file: %s.\n", fname);
+ return false;
+ }
+
+ delete [] pixels;
+ pixels = new unsigned char[w * h * 4];
+ memcpy(pixels, imago_pixels, w * h * 4);
+
+ img_free_pixels(imago_pixels);
+
+ return true;
+}
\ No newline at end of file