17 Image::Image(const Image &image)
22 pixels = new unsigned char[w * h * 4];
23 memcpy(pixels, image.pixels, w * h * 4);
26 Image &Image::operator =(const Image &image)
36 pixels = new unsigned char[w * h * 4];
37 memcpy(pixels, image.pixels, w * h * 4);
42 Image::Image(Image &&image)
47 pixels = image.pixels;
51 Image &Image::operator =(Image &&image)
61 pixels = image.pixels;
67 bool Image::load(const char *fname)
69 unsigned char *imago_pixels;
70 if(!(imago_pixels = (unsigned char *)img_load_pixels(fname, &w, &h))) {
71 fprintf(stderr, "Failed to load pixels from file: %s.\n", fname);
76 pixels = new unsigned char[w * h * 4];
77 memcpy(pixels, imago_pixels, w * h * 4);
79 img_free_pixels(imago_pixels);