/** Test Main. It will explore Splatoon! */
 public static void main(String args[]) {
   // Picture pix = new Picture("snowman.jpg");
   Picture pix = new Picture("splatoon.jpg");
   Picture smallPic = pix.scale(.5, .48);
   smallPic.explore();
   smallPic.write("smallSplatoon.jpg");
 }
Example #2
0
  private Picture initialImage() {
    pic2 = new Picture(500, 600);
    pic1 = new Picture(500, 600);

    for (int x = 0; x < pic2.width(); x++)
      for (int y = 0; y < pic2.height(); y++) {
        double dist = 1.0 - Math.sqrt((x - 300) * (x - 300) + (y - 200) * (y - 200)) / 500;
        int red =
            (int)
                (dist < 0.5
                    ? 0
                    : Math.min(Math.pow(dist, 0.4) + Math.pow(dist - 0.5, 0.1), 1.0) * 255);
        int green = (int) (dist * 255);
        int blue = 0;
        pic2.set(x, y, new Color(red, green, blue));
      }
    return pic2;
  }
Example #3
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("seagull.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("Bknight.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("Russet_Potato.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("D://Documents/ApComputers/pixLab/images/beach.jpg");
   pix.explore();
 }
 /** Test Main. It will explore the beach */
 public static void main(String args[]) {
   Picture pix = new Picture("connor.jpg");
   Picture smallP = pix.scale(0.1, 0.1);
   smallP.write("smallPictures.jpg");
   pix.explore();
 }