0

In html is there a way to set an image's src directly from another image's data, rather than using the url (ie NOT image1.src = image2.src)

cheers.

UPDATE After looking at the restrictions of data uri s I have decided that its not the way forward. I will probably have to draw onto a canvas instead.

thanks for all your help

neil manuell
  • 225
  • 2
  • 10
  • 1
    No, but you can do it in `Javascript`, as it's DOM manipulation. – Nick R Jun 25 '13 at 15:43
  • Are you trying to accomplish this when the page loads or is it triggered at some point after the page is loaded? – Chad Cook Jun 25 '13 at 15:44
  • You can do this with the base64 data instead of the url. http://stackoverflow.com/questions/1207190/embedding-base64-images – mguimard Jun 25 '13 at 15:46
  • I have a single image on display, and a hidden preloaded list. on user interaction the displayed image is swapped for one off the list. When I change using src to src the latency is too great. I know I could do this with canvas, but then I'd have to write more code to make it responsive. – neil manuell Jun 25 '13 at 15:51
  • @Mguimard cheers, so I would have to load them in as base64 rather than using image? – neil manuell Jun 25 '13 at 15:59
  • I'm not sure to understand your needs, but if you already have loaded an image and just want to get the base64 you can do this as described in this post : http://stackoverflow.com/questions/934012/get-image-data-in-javascript – mguimard Jun 26 '13 at 11:57
  • @mguimard Thanks, since this solution requires canvas I figure I might as well just use the canvas directly. – neil manuell Jul 03 '13 at 12:28

1 Answers1

0

I am now using a div and setting the background-image css on user interaction. I originally solved the issue using canvas, but this is over complicated and not optimal for OSX devices.

neil manuell
  • 225
  • 2
  • 10