Example #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
}
Example #2
0
void image::insert_image(Pos& pos, image& image_to_insert) {
	// Check dimensions
	if (pos.x + image_to_insert.size().width > this->size_.width ||
	    pos.y + image_to_insert.size().height > this->size_.height) {
		cout << "Cant insert image: Size mismatch!" << endl;
		return;
	}

	for (int y = 0; y < image_to_insert.size().height; ++y)
		for (int x = 0; x < image_to_insert.size().width; ++x) 
			this->pixels_[y + pos.y][x + pos.x] = image_to_insert.pixels().at(y).at(x);
		
}
Example #3
0
void image::append_image_bot(image& image_to_append) {
	
	// Bring both images to the same width
	if (this->size_.width < image_to_append.size().width)
		append_width(image_to_append.size().width);
	else if (this->size_.width > image_to_append.size().width)
		image_to_append.append_width(this->size_.width);

	// Append new rows from other image at bottom
	for (vector<RGBA> row : image_to_append.pixels())
		this->pixels_.push_back(row);

	// Update height
	this->size_.height += image_to_append.size().height;
}