Exemple #1
0
void image::append_image_right(image& image_to_append) {

	// Bring both images to the same height
	if (this->size_.height < image_to_append.size().height)
		append_height(image_to_append.size().height);
	else if (this->size_.height > image_to_append.size().height)
		image_to_append.append_height(this->size_.height);

	// Append new rows from other image to the right of each row
	for (int y = 0; y < (int) image_to_append.size().height; ++y) 
		for (int x = 0; x < (int) image_to_append.size().width; ++x) 
		     	this->pixels_.at(y).push_back(image_to_append.pixels().at(y).at(x));


	this->size_.width += image_to_append.size().width;

#if DEBUG
	cout << "images merged. array sizes: "
	     << this->pixels_.at(1).size()
	     << " width, "
	     << this->pixels_.size()
	     << " height. image size: "
	     << this->size_.width
	     << ", "
	     << this->size_.height
	     << endl;
#endif
}