Example #1
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture beach = new Picture("beach.jpg");
    beach.explore();
    beach.mirrorVerticalBottomToTop();
    // beach.mirrorVerticalRightToLeft();
    // beach.Grayscale();
    // beach.maxBlue();
    // beach.createCollage();
    // beach.rightRed();
    beach.explore();
    // beach.write("5FilterBeach.jpeg");

  }
Example #2
0
 /** Method to create a collage of several pictures */
 public void createCollage() {
   Picture flower1 = new Picture("flower1.jpg");
   Picture flower2 = new Picture("flower2.jpg");
   this.copy(flower1, 0, 0);
   this.copy(flower2, 100, 0);
   this.copy(flower1, 200, 0);
   Picture flowerNoBlue = new Picture(flower2);
   flowerNoBlue.zeroBlue();
   this.copy(flowerNoBlue, 300, 0);
   this.copy(flower1, 400, 0);
   this.copy(flower2, 500, 0);
   this.mirrorVertical();
   this.write("collage.jpg");
 }
Example #3
0
 /**
  * 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());
     }
   }
 }
Example #4
0
 /* Main method for testing - each class in Java can have a main
  * method
  */
 public static void main(String[] args) {
   Picture beach = new Picture("pixLab/images/beach.jpg");
   beach.explore();
   beach.keepOnlyRed();
   beach.explore();
 }