Hi - wanting to make the screen size same as the image size automatically

edited December 2017 in Questions about Code

//trying to make the image fit within the screen. //I did try adding the pixel sizes with image (img,0,0,1000,1000) it worked //but I might not always know the image size so how to make it automatic //BTW this code must be so bad it hung my PC.

PImage img; //image is 1000x1000 pixels

int x = img.width;  //x is same as image width
int y = img.height;  //y is same as image height

Void setup() {
 size (x,y);  //screen size is same as image
 img = loadImage ("01.JPG"); 
}

voif draw() {
  image (img, 0,0); 
}

//I need to know how to manipulate image sizes without distorting the propotions

Tagged:

Answers

Sign In or Register to comment.