|
Author |
Topic: Using loadImage to load picture from web (Read 888 times) |
|
gkoshra
|
Using loadImage to load picture from web
« on: Jun 2nd, 2003, 1:47pm » |
|
Hello, I was wondering if you could load an image from a specified URL location, so I did this... Code: BImage theImage; theImage = loadImage("http://www.gomako.co.uk/image/raa.jpg"); image(theImage, 0, 0, width, height-20); |
| But it gave me a null pointer exception at the image() bit. I'm assuming that's because it didn't manage to load the image. Is that right? If so, is there a way to get images loaded from a specified location? Cheers, Ben.
|
|
|
|
arielm
|
Re: Using loadImage to load picture from web
« Reply #1 on: Jun 2nd, 2003, 8:00pm » |
|
took your code into 0054, split the 3 statements, and it worked: Code: BImage theImage; void setup() { theImage = loadImage("http://www.gomako.co.uk/image/raa.jpg"); } void loop() { image(theImage, 0, 0, width, height-20); } |
| also, i think this code will not work when exported as an applet, unless the applet's .jar and the image are in the same folder...
|
Ariel Malka | www.chronotext.org
|
|
|
gkoshra
|
Re: Using loadImage to load picture from web
« Reply #2 on: Jun 10th, 2003, 4:51pm » |
|
Bah. I tried copying your code and doing it that way, but I still get blankness. Perhaps it's because i'm at work and there's a pooping great firewall in the way. I really should get a home connection. Ta for looking though.
|
|
|
|
fry
|
Re: Using loadImage to load picture from web
« Reply #3 on: Jun 24th, 2003, 8:29pm » |
|
this definitely should work, so if it's not and you can get it to semi-consistently fail with a particular example, please post a .zip of your sketch folder so we can figure out what's up.
|
|
|
|
gkoshra
|
Re: Using loadImage to load picture from web
« Reply #4 on: Jun 25th, 2003, 9:46am » |
|
Hi there, I tried this in P54 and p55 and get the same result. It says "could not load image http://www.gomako.co.uk/image/raa.jpg java.lang.NullPointerException" Then a load of other stuff. I just copied and pasted the code from arielm's post. Do you think it has something to do with my work network/interet connection? I've zipped the sketch folder and put it here -> http://www.gomako.co.uk/p5/net_image.zip
|
|
|
|
arielm
|
Re: Using loadImage to load picture from web
« Reply #5 on: Jun 25th, 2003, 11:30am » |
|
the zip file contains the same: Code:BImage theImage; void setup() { theImage = loadImage("http://www.gomako.co.uk/image/raa.jpg"); } void loop() { image(theImage, 0, 0, width, height-20); } |
| as before... it still works from within p5 in my machine so i guess it's definitely a net issue on your side... but why do you need "http://"? because i think it won't work correctly anyway within an applet (i.e: not inside the p5 environment), but if you just post your applet at http://www.gomako.co.uk/image/ and use loadImage("image.jpg"), then it should work...
|
« Last Edit: Jun 25th, 2003, 11:38am by arielm » |
|
Ariel Malka | www.chronotext.org
|
|
|
fry
|
Re: Using loadImage to load picture from web
« Reply #6 on: Jun 25th, 2003, 6:32pm » |
|
on Jun 25th, 2003, 11:30am, arielm wrote:but why do you need "http://" because i think it won't work correctly anyway within an applet (i.e: not inside the p5 environment), but if you just post your applet at http://www.gomako.co.uk/image/ and use loadImage("image.jpg"), then it should work... |
| yeah, unless your applet is at http://www.gomako.co.uk/image/ the image won't be able to download.. this is because of java applet security issues, which are outside our control. is this the problem
|
|
|
|
gkoshra
|
Re: Using loadImage to load picture from web
« Reply #7 on: Jun 26th, 2003, 10:25am » |
|
Hi guys, thanks for all your answers and stuff. I put the image into the applet folder/applet into the image folder and all was fine. The thing I was aiming for in the end was for a user to be able to input the url of an image and load it from that, but it seems like java's security issues are going to scupper that. It's no big deal anyhow, it was just a tryout. Cheers, Ben.
|
|
|
|
benelek
|
Re: Using loadImage to load picture from web
« Reply #8 on: Jun 27th, 2003, 3:12am » |
|
actually, you could probably use an interface with some javascript in the page to get the javascript to load the image, and then feed it back into the applet... if you feel like going to extremes
|
|
|
|
gkoshra
|
Re: Using loadImage to load picture from web:
« Reply #9 on: Jun 27th, 2003, 10:57am » |
|
Sounds too scary for me I don't think I'll be bothering just yet.
|
|
|
|
|