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.
Page Index Toggle Pages: 1
URL support in PImage() (Read 2254 times)
URL support in PImage()
May 12th, 2007, 3:44am
 
Hello,

I've been working on a hack to make PImage(String) understand URLs (protocol://stuff). I have a quick demo here:

http://www.csc.calpoly.edu/~wtracy/processing/

Drag the image links from the left onto the applet, and they open. (Yes, the demo is slightly laggy, and it assumes Java 1.4+. That's a problem with the demo, not the changes I made to P5.)

Would there be any interest in incorporating this into P5 if I put in the effort to change the quick hack into a real patch?

William Tracy
Re: URL support in PImage()
Reply #1 - May 12th, 2007, 11:34am
 
Hi

Would you mind exposing the code for this? I would love to contribute by making what you did here threaded, as well as add some callback support. What you did here is really fascinating!

~M
Re: URL support in PImage()
Reply #2 - May 12th, 2007, 6:03pm
 
If you're referring to my demo applet, it requires my PImage() patch to run (though you could load a java.awt.Image yourself and build the PImage from it).

Actually, to be honest, I started it from Seltar's example code here (towards the end of the thread), because I'm lazy:

http://processing.org/discourse/yabb_beta/YaBB.cgi?num=1147684168

I changed most of for my demo, though. I cleaned it up a bit and put it online now.

If you're referring to the patch itself, you probably want to let me finish refactoring it before you try to add features. Smiley

William Tracy

Edit again:

If you only care about running inside the web browser, replacing line 96 with this hack should make it run with the unpatched version of Processing:

img = loadImageSync(getImage(new java.net.URL(filename)));
Re: URL support in PImage()
Reply #3 - May 14th, 2007, 11:45pm
 
I feel like an idiot.

There *already is* URL support in PApplet.openStream(), which is used internally by loadImage().

My little demo applet works find with the unpatched version of Processing, and my hacking wasn't adding anything.

I have no idea how I didn't see that before, or how I even managed to convince myself that it didn't work in the first place. :-P

Anyway, hi. Smiley
Page Index Toggle Pages: 1