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 & HelpSyntax Questions › Loading image w/ a string sent from a client
Page Index Toggle Pages: 1
Loading image w/ a string sent from a client (Read 328 times)
Loading image w/ a string sent from a client
May 22nd, 2009, 7:58am
 
Hi guys, newbie here with a question.

So I'm trying to load images into processing while the sketch is running, with the images to be loaded specified by a message sent from a client. Basically, a message sent from max a max patch specifies what image to be loaded.

I'm trying to stay away from explaining the whole project, because then the conversation might get off topic, but I do have to say that the images can not be loaded in setup(), because the images have not been downloaded before the sketch is running (i'm scraping the images in max)

Anyway, here is a little sketch that doesnt work... can anyone help me?

import processing.net.*;

Server server;

PImage img;
String incomingMessage = "";

void setup() {
 size(500,500);
 server = new Server(this,5204);
}

void draw() {
 background(255);
 
Client client = server.available();

if (client != null) {
 incomingMessage = client.readString();
println(incomingMessage);
}
 if (mousePressed) {
 img = loadImage(incomingMessage);
 image(img, 100, 100, 100,100);
}
}
Page Index Toggle Pages: 1