Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Show Image from Server on Browsers Canvas
Show Image from Server on Browsers Canvas [message #1803303] Tue, 26 February 2019 14:55 Go to next message
Nin Pa is currently offline Nin PaFriend
Messages: 33
Registered: September 2013
Member
Hello!
I am trying to show an Image from the server in a canvas, that is contained in a swt browser.
I just finished doing it the other way, saving the image from the canvas on the server using

String script += "return canvas.toDataURL('image/png');";
String dataURL = (String) browser.evaluate(script);
byte[] imagedata = DatatypeConverter.parseBase64Binary(dataURL.substring(dataURL.indexOf(",") + 1));
			BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(imagedata));
			ImageIO.write(bufferedImage, "png", new File(imgFilePath));


Is there a way doing it the other way round? Sending an image from java to the canvas?

Would be great, if there is a solution for my problem...
Greetings!
Re: Show Image from Server on Browsers Canvas [message #1803308 is a reply to message #1803303] Tue, 26 February 2019 15:31 Go to previous messageGo to next message
Vincenzo Caselli is currently offline Vincenzo CaselliFriend
Messages: 227
Registered: January 2012
Senior Member

Hi Nin Pa,
you can define a Servlet in RAP (via "org.eclipse.equinox.http.registry.servlets" Extension Point), implement it reading a stream on the server file system and rendering it on the response.
Then the SWT Browser can point to the servlet URL (e.g. "/doc?id=378") so to make the document or image visible to the user.
HTH
Vincenzo Caselli
RCP Vision
Re: Show Image from Server on Browsers Canvas [message #1803327 is a reply to message #1803308] Tue, 26 February 2019 21:49 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
Alternatively you can create a ServiceHandler to deliver files to the client.
https://www.eclipse.org/rap/developers-guide/devguide.php?topic=resources.html&version=3.7
Re: Show Image from Server on Browsers Canvas [message #1803599 is a reply to message #1803327] Tue, 05 March 2019 09:26 Go to previous message
Nin Pa is currently offline Nin PaFriend
Messages: 33
Registered: September 2013
Member
Thank you very much!
It worked for me using the ResourceManager and register the image, than getting the URL with RWT.getResourceManager().getLocation(imgName) and pointing to it in the img.src :)
Previous Topic:download service servlet error on Tomcat 8
Next Topic:Browser Search not Working
Goto Forum:
  


Current Time: Mon Dec 09 02:10:57 GMT 2019

Powered by FUDForum. Page generated in 0.02567 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top