public void cropAndCopy( Picture sourcePicture, int startSourceRow, int endSourceRow, int startSourceCol, int endSourceCol, int startDestRow, int startDestCol) { Pixel leftPixel = null; Pixel rightPixel = null; Pixel[][] pixels = this.getPixels2D(); Color rightColor = null; Pixel[][] fromPixels = sourcePicture.getPixels2D(); Pixel[][] toPixels = this.getPixels2D(); Pixel fromPixel = null; Pixel toPixel = null; for (int fromRow = startSourceRow, toRow = endSourceRow; fromRow < fromPixels.length && toRow < toPixels.length; fromRow++, toRow++) { for (int fromCol = startSourceCol, toCol = endSourceCol; fromCol < fromPixels[0].length && toCol < toPixels[0].length; fromCol++, toCol++) { fromPixel = fromPixels[fromRow][fromCol]; toPixel = toPixels[toRow][toCol]; toPixel.setColor(fromPixel.getColor()); } } }
/** * Method to replace blue pixels with pixels from the second picture. * * @param second picture to replace blue pixels with */ public void chromakey(Picture second) { Pixel[][] pixels = this.getPixels2D(); Pixel[][] pixels2 = second.getPixels2D(); for (int row = 0; row < pixels.length; row++) for (int col = 0; col < pixels[0].length; col++) if (pixels[row][col].getColor().getBlue() >= 200) pixels[row][col].setColor(pixels2[row][col].getColor()); }
/** * copy from the passed fromPic to the specified startRow and startCol in the current picture * * @param fromPic the picture to copy from * @param startRow the start row to copy to * @param startCol the start col to copy to */ public void copy(Picture fromPic, int startRow, int startCol) { Pixel fromPixel = null; Pixel toPixel = null; Pixel[][] toPixels = this.getPixels2D(); Pixel[][] fromPixels = fromPic.getPixels2D(); for (int fromRow = 0, toRow = startRow; fromRow < fromPixels.length && toRow < toPixels.length; fromRow++, toRow++) { for (int fromCol = 0, toCol = startCol; fromCol < fromPixels[0].length && toCol < toPixels[0].length; fromCol++, toCol++) { fromPixel = fromPixels[fromRow][fromCol]; toPixel = toPixels[toRow][toCol]; toPixel.setColor(fromPixel.getColor()); } } }
public void copy( Picture fromPic, int fromStartRow, int fromStartCol, int toStartRow, int toStartCol, int fromEndRow, int fromEndCol) { Pixel fromPixel = null; Pixel toPixel = null; Pixel[][] toPixels = this.getPixels2D(); Pixel[][] fromPixels = fromPic.getPixels2D(); for (int fromRow = fromStartRow, toRow = toStartRow; fromRow <= fromEndRow && toRow < toPixels.length; fromRow++, toRow++) { for (int fromCol = fromStartCol, toCol = toStartCol; fromCol <= fromEndCol && toCol < toPixels.length; fromCol++, toCol++) { fromPixel = fromPixels[fromRow][fromCol]; toPixel = toPixels[toRow][toCol]; toPixel.setColor(fromPixel.getColor()); } } }