/** * Method that will copy all of the passed source picture into the current picture object * * @param sourcePicture the picture object to copy */ public void copyPicture(SimplePicture sourcePicture) { Pixel sourcePixel = null; Pixel targetPixel = null; // loop through the columns for (int sourceX = 0, targetX = 0; sourceX < sourcePicture.getWidth() && targetX < this.getWidth(); sourceX++, targetX++) { // loop through the rows for (int sourceY = 0, targetY = 0; sourceY < sourcePicture.getHeight() && targetY < this.getHeight(); sourceY++, targetY++) { sourcePixel = sourcePicture.getPixel(sourceX, sourceY); targetPixel = this.getPixel(targetX, targetY); targetPixel.setColor(sourcePixel.getColor()); } } }