RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()), pixelMap(nullptr) {
	const int size = other.getWidth() * other.getHeight();
	if(size > 0) {
		pixelMap = new RGB[size];
		std::memcpy(pixelMap, other.pixelMap, sizeof(RGB) * size);
	}
}
void RGBImageStudent::set(const RGBImageStudent &other) {

	RGBImage::set(other.getWidth(), other.getHeight());
   for (int i = 0; i < this->getHeight()*this->getWidth(); i++) {
       pixelmap[i] = other.getPixel(i);
   }
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : 
	RGBImage(other.getWidth(), other.getHeight()),
	_image(new RGB[other.getWidth() * other.getHeight()]) {

	for (int i = 0; i < getWidth() * getHeight(); ++i)
		_image[i] = other._image[i];
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()){    
    init_rgb_image();
    for (int y = 0; y < height; y++){
        for (int x = 0; x < width; x++){
            rgb_image[x][y] = other.getPixel(x, y);
        }
    }
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	RGBImage::set(other.getWidth(), other.getHeight());
	delete[] _image;
	_image = new RGB[getWidth() * getHeight()];

	for (int i = 0; i < getWidth() * getHeight(); ++i)
		_image[i] = other._image[i];
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()), pixelMap(nullptr) {
	const int SIZE = other.getSize();
	if (SIZE > 0) {
		pixelMap = new RGB[SIZE];
		for (int i = 0; i < SIZE; i++) {
			pixelMap[i] = other.getPixel(i);
		}
	}
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	RGBImage::set(other.getWidth(), other.getHeight());

    RGB* otherStorage = new RGB[other.getWidth() * other.getHeight()];
    for(int i = 0; i < storageWidth * storageHeight; i++){
		otherStorage[i] = storage[i];
    }
    delete[] storage;
    storage = otherStorage;
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	const int	SIZE = other.getSize();
	RGBImage::set(other.getWidth(), other.getHeight());

	if (SIZE > 0) {
		delete[] pixelMap;
		pixelMap = new RGB[SIZE];
		for (int i = 0; i < SIZE; i++) {
			pixelMap[i] = other.getPixel(i);
		}
	}
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()) {
	pixelStorage = new RGB*[other.getWidth()];
	for (int x = 0; x < other.getWidth(); x++)
	{
		pixelStorage[x] = new RGB[other.getHeight()];
		for (int y = 0; y < other.getHeight(); y++)
		{
			pixelStorage[x][y] = other.pixelStorage[x][y];
		}
	}
	//TODO: Create a copy from the other object
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	const int oldSize = getWidth() * getHeight(), newSize = other.getWidth() * other.getHeight();
	RGBImage::set(other.getWidth(), other.getHeight());
	
	if(oldSize == newSize && pixelMap != nullptr) {
		std::memcpy(pixelMap, other.pixelMap, sizeof(RGB) * newSize);
	} else {
		delete pixelMap;
		if(newSize > 0) {
			pixelMap = new RGB[newSize];
			std::memcpy(pixelMap, other.pixelMap, sizeof(RGB) * newSize);
		} else {
			pixelMap = nullptr;
		}
	}
}
void RGBImageStudent::set(const RGBImageStudent &other) {
    RGB** t_rgb_array = rgb_image;
    int old_height = height;
    width = other.width;
    height = other.height;
    init_rgb_image();
    for (int y = 0; y < height; y++){
        for (int x = 0; x < width; x++){
            rgb_image[x][y] = other.getPixel(x, y);
        }
    }
    delete_rgb_array(t_rgb_array, old_height);
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()) {
	img = new RGB[getWidth()*getHeight()]{RGB{ 0, 0, 0 }};
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	pixelStorage = other.pixelStorage;
	RGBImage::set(other.getWidth(), other.getHeight());
	//TODO: resize or create a new pixel storage and copy the object (Don't forget to delete the old storage)
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage{ other.getWidth(), other.getHeight() } {
	pixelmap = new RGB[this->getWidth() * this->getHeight()];
   for (int i = 0; i < this->getHeight()*this->getWidth(); i++) {
       pixelmap[i] = other.getPixel(i);
   }
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	int oldWidth = getWidth();
	int oldHeight = getHeight();
	RGBImage::set(other.getWidth(), other.getHeight());
	translateToNewWith(oldHeight, oldHeight, other.getWidth(), other.getHeight());
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) :
    RGBImage(other.getWidth(), other.getHeight()) {
	RGBImageStudent copy;
	copy = other;
}
RGBImageStudent::RGBImageStudent(const RGBImageStudent &other) : RGBImage(other.getWidth(), other.getHeight()) {
	//int throwError = 0, e = 1 / throwError;
	//TODO: Create a copy from the other object
	RGBImageStudent temp =  RGBImageStudent(other.getWidth(),other.getHeight());
	temp.setAllPixels(getAllPixels());
}
void RGBImageStudent::set(const RGBImageStudent &other) {
	RGBImage::set(other.getWidth(), other.getHeight());
	//int throwError = 0, e = 1 / throwError;
	//TODO: resize or create a new pixel storage and copy the object (Don't forget to delete the old storage)
	set(other.getWidth(), other.getHeight());
}