Sg2.9
new Raster(url)?
Recent RSS
new Raster(url)?
From:  Quentin T
Date:  20. September 2008, 18:15

Does this work?

var r=new Raster(url);

If so, what should my url variable look like?

I tried something like "http://www.url.com/image.jpg" but I got an "Unable to convert [the url] to java.lang.Short"...

I also tried to convert the String to java.lang.Short, but with no luck.
Any clue?

Re: new Raster(url)?
Date:  20. September 2008, 18:56

You need to use a java URL:

var url = new java.net.URL("http://www.test.com/test.jpg");
new Raster(url);
Re: new Raster(url)?
From:  Quentin T
Date:  20. September 2008, 19:12

Nice!
Thanks for your quick reply!

Sg is really cool but when it comes to documentation it can get really painful... I hope it gets better!

Re: new Raster(url)?
From:  Quentin T
Date:  20. September 2008, 19:35

Outch!
It seems to be working with lots of different URLs but this one (one I'd like to use) throws a com.scratchdisk.script.rhino.RhinoScriptException:

var url = new java.net.URL("http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=Hello%20wrld&choe=UTF-8&chof=gif");
new Raster(url);

Any idea?

Re: new Raster(url)?
Date:  20. September 2008, 19:56

I think its because the url doesn't have an extension such as .gif or .jpeg..

Re: new Raster(url)?
From:  Quentin T
Date:  20. September 2008, 20:13

I tried to append "&dummy=.gif" to the URL but that doesn't change a thing... Too bad!

My QR Code script is fizzling out!

Re: new Raster(url)?
Date:  23. September 2008, 15:00

The following should work:

var url = new java.net.URL("http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=Hello%20wrld&choe=UTF-8&chof=gif");
var conn = url.openConnection();
var inputStream = new java.io.BufferedInputStream(conn.getInputStream());
var img = javax.imageio.ImageIO.read(inputStream);
new Raster(img);
img.flush();

Still not sure why calling new Raster directly with that url doesn't work.. Hmm..

Re: new Raster(url)?
From:  Quentin T
Date:  23. September 2008, 15:32

Wow, what a script!
I'll try that this evening, thanks for helping!

Re: new Raster(url)?
From:  Quentin T
Date:  23. September 2008, 22:18

Well nope, I get errors...
The first is "javax is not defined" (line 4) so I replaced it with "java" but I get a "read is not a function" (line 4 also).

Probably my version of Java?

Re: new Raster(url)?
Date:  23. September 2008, 23:03

hmmm, didn't know javax was non standard.. I'm sure its possible in standard java too, I'll take another stab at it soon!

Re: new Raster(url)?
From:  andyadams
Date:  13. February 2015, 03:26

I am a java barcode designer and i want to make qrcode with some url links.I want to inject the URL of a classpath resource in a way that does not create a dependency on Spring in the Bean. Meaning, the bean should not use Spring's interfaces/classes. How can I do that?

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Area Type Resizer 03.08.12