We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Exorting problem
Page Index Toggle Pages: 1
Exorting problem (Read 624 times)
Exorting problem
May 23rd, 2007, 10:49pm
 
hi i wanted to export a program, which loads in image and sets the size for the frame as the image size.

it doesn't work. the size is always 200,200 and a part of the image sometimes is F5,F5,F5 showed but most time most is just blank. also the rest, like checking mouseX, mouseY doens't work.
. how can i get the frame inside the browser get with the right size?

PImage img;

void setup() {
 img = loadImage("test.jpg");
 size(img.width,img.height);
 image(img,0,0);
}
Re: Exorting problem
Reply #1 - May 23rd, 2007, 11:10pm
 
Unfortunately, size has to be the first thing in setup, or it just won't work. So you need to somehow know the size of the image in advance.
Re: Exorting problem
Reply #2 - May 23rd, 2007, 11:29pm
 
You can also try this code, if you want to show all the images by using the same screen resolution (even if the images do have different).

Quote:
PImage img;

void setup() {
size(640,480); // replace it by the display's native resolution or applet size
background(0);  
img = loadImage("test.jpg");
}

void draw() {
 image(img,0,0,width,height); // will be stretched according to size()
}


Also, i didn't really get if you want to run your sketch as an application or inside a webpage.
Re: Exorting problem
Reply #3 - May 25th, 2007, 8:49am
 
mh yes i thought that scaling would be the only way. it should be shown on a webpage, but the the pictures will change. so maybe i can start the applet with a size set by the html code
Page Index Toggle Pages: 1