Another short demo:
- /*
- * A simple application to show how to change the window size to fit an image.
- * No provision is made for images that are bigger than the screen dimensions.
- * That would be a good exercise.
- * Makes use of "undocumented" features, found in the Processing JavaDocs but
- * not in the online help pages: frame.setResizable and frame.setSize.
- * Click in the window to load a new image.
- */
- PImage img;
- void setup() {
- String path = selectInput("Select an image file to display...");
- if (null != path) {
- img = loadImage(path);
- size(img.width, img.height);
- }
- else {
- size(320, 240);
- }
- // permit the display window to be resized
- frame.setResizable(true);
- }
- void draw() {
- if (mousePressed == true) {
- pickImage();
- }
- if (null != img) image(img, 0, 0, width, height);
- }
- void pickImage() {
- String path = selectInput("Select an image file to display...");
- if (null == path) {
- println("no file selected");
- }
- else {
- img = loadImage(path);
- frame.setSize(img.width, img.height);
- }
- }
-- Paul
----- |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| ---