lundi 20 avril 2015

Select image and create object. Processing 2.0

here is a code snippet from my Image class:

class Image{

  public int width;
  public int height;

  public PImage img;

  Image(PApplet parent){

    width = 512;
    height = 512;

    img = new PImage();
    img = parent.loadImage("test.jpg");
    img.resize(width, height);
  }
}

I draw it in the main file in such a way:

image(image.img, 287, 280);

I'd like to choose the image having clicked it:

void mousePressed() {
   if (gui.btnOver1) {
     selectInput("Choose file:", "fileSelected");
   }
}

However, I don't know how to use this function in an OOP way:

void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    img = loadImage(selection.getAbsolutePath());
    img.loadPixels();
  }
}

Thanks for help.

1 commentaire:

  1. Borgata Hotel Casino & Spa - MapyRO
    Welcome to Borgata 충청북도 출장안마 Hotel Casino & Spa. A Casino in Atlantic City, NJ. It 목포 출장마사지 is owned and 영천 출장안마 operated by Caesars Entertainment and operated by  광양 출장샵 Rating: 4 · ‎16 reviews 충청북도 출장샵

    RépondreSupprimer