Passing an image from the Servoy media library into a plugin

Questions and answers on developing, deploying and using plugins and JavaBeans

Passing an image from the Servoy media library into a plugin

Postby pbakker » Mon Aug 02, 2004 9:51 am

Hi,

Been strugling with this for a while now, cannot find a way to do it...

I'm trying to pass an image from the Servoy Media library into a plugin. So far no succes.

I think on the Servoy side I would have to do something like:

plugins.PBS_Tools.insertImage(plugins.http.getMediaData("media:///image.gif"))

But on the plugin side, how do I retrieve it again? This is what I have now, but this in combination with the way I call the function in Servoy doesn't work....:

public void js_insertImage (Image image)
{
bladibladibla;
}

Any help appreciated..

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Jan Blok » Mon Aug 02, 2004 11:19 pm

In the plugin java code you can open an inputstream from an URL
like:
InputStream is = new URL("media:///image.gif").openStream();
from the stream you can read the bytes. (do not forget to close the steam!)
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam

Postby pbakker » Tue Aug 03, 2004 11:49 am

Jan,

Tnx for the pointer. Didn't get that up and running, but looking at it from that angle, I found the following that works:

String name2 = "media:///" + name;
URL url = new URL(name2);
Image image = ImageIO.read(url);

In the sample above, name is a string that the function needs as parameter.

Is this a good way to achieve the same? As far as I understand it, there's nothing I have to close now, right?

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Jan Blok » Tue Aug 03, 2004 7:25 pm

correct
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 12 guests

cron