public static void main(String[] args) {
   Picture p = new Picture(FileChooser.getMediaPath("horse.jpg"));
   Graphics g = p.getGraphics();
   Point ul = new Point(68, 24);
   Point te = new Point(182, 123);
   String message = "This is a test." + "  Of a message with more than one line in it.";
   SpeechBalloon balloon = new SpeechBalloon(ul, 200, te, message);
   balloon.draw(g);
   p.show();
 }
Пример #2
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");

  }
Пример #3
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");
 }
Пример #4
0
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture desert = new Picture("Desert.jpg");
    Picture koala = new Picture("Koala.jpg");
    //    beach.explore();
    //    beach.zeroBlue();
    //    desert.chromakey(koala);
    //    desert.sepia(25, 3);
    koala.sepia();
    //    desert.encode("ABCDEFGHIJKLMNOPasdfgwe6");
    //    System.out.println(desert.decode());

    //    desert.explore();
    koala.explore();
  }
Пример #5
0
 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());
     }
   }
 }
Пример #6
0
 /**
  * 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());
 }
Пример #7
0
 public static void main(String[] args) {
   String fileName = FileChooser.pickAFile();
   Picture pictObj = new Picture(fileName);
   pictObj.changeWhole(.5);
   pictObj.changeWhole(.8);
   pictObj.scrible(200, 200, 50);
   pictObj.scrible(350, 320, 100);
   pictObj.ManipBoxUniformly(200, 200, 300, 300, .2);
   pictObj.ManipBoxUniformly(100, 100, 400, 300, .5);
   pictObj.ManipBoxPattern(100, 100, 300, 300, .3);
   pictObj.ManipBoxPattern(300, 300, 400, 400, .8);
   pictObj.explore();
 }
Пример #8
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());
     }
   }
 }
  /**
   * Method to add a picture to the frame sequence
   *
   * @param picture the picture to add
   */
  public void addFrame(Picture picture) {

    // add this picture to the list
    pictureList.add(picture);

    // write out this frame
    picture.write(directory + baseName + numberFormat.format(frameNumber) + ".jpg");

    // if this sequence is being shown update the frame
    if (shown) {
      if (pictureFrame != null) pictureFrame.setPicture(picture);
      else pictureFrame = new PictureFrame(picture);
    }

    // increment the frame number
    frameNumber++;
  }
Пример #10
0
 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());
     }
   }
 }
Пример #11
0
  /** Method to create a collage of several pictures */
  public void createCollage() {
    Picture pic2 = new Picture("moon-surface.jpg");

    Picture picNoBlue = new Picture(pic2);
    picNoBlue.zeroBlue();

    Picture effect1 = new Picture(pic2);
    effect1.edgeDetection(10);

    Picture effect2 = new Picture(pic2);

    this.copy(effect1, 250, 600);
    this.copy(pic2, 0, 600);
    effect2.mirrorVertical();
    this.copy(effect2, 250, 0);

    this.copy(picNoBlue, 0, 0);

    this.write("collage.jpg");
  }
Пример #12
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.zeroBlue();
   beach.explore();
 }
Пример #13
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();
 }