I have added a proof of concept for image creation from the Jmol applet at

 http://www.stolaf.edu/academics/chemapps/jmol/docs/examples-11/new.htm

It's the same page I've been using, but there is a new link just under 
the applet that you can click to get the image.

Note that this all depends upon the user not using Internet Explorer or 
possibly some other configurations that do not support the data: URI
<http://en.wikipedia.org/wiki/Data:_URL>

This modification of Jmol has not been checked in and may not appear in 
versions of Jmol. I don't think copyright is any issue -- the license is 
very generous -- but the lack of MSIE support concerns me. To date we've 
been able to keep this pretty much platform independent.

So it has its drawbacks. Right now I am not checking for browsers. I 
think the primary use would be for developers and web site designers who 
want to get images directly off their site and who can choose their browser.

How it works:

1) I added

   getProperty image

which, in terms of JavaScript is carried out as

   var image = jmolGetPropertyAsString("image")

Now, this returns a base64-encoded jpeg image. What can we do with that?

2) The link on that page reads:

<a href="javascript:void(open('getimage.htm','_blank'))">image</a>

which, you say, doesn't make any sense, because we are using an anchor 
to run javascript to open a different file??

3) The file getimage.htm is simply:

<script>
var image = opener.jmolGetPropertyAsString("image")
document.write('<img src="data:image/jpg;base64,'+image+'">')
</script>

(a bit sparse, I know, but I'm just testing here)

What this does is go BACK to the original page, get the image, and 
display it.

Strangely enough, say you change the model. You don't have to go back to 
that original "show image" link -- all you do is reload this page, 
because it will go get the CURRENT image, not the last one.

So to make this work you would just have to have that little 
getimage.htm file in some directory and link to it in this way from your 
page.

Is that cool, or what?

Bob

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to