简体   繁体   中英

get base64 in javascript to silverlight image

I have a javascript function that get base64 string then I need to pass this value to a silverlight object within my page to render the base64 as jpeg image

Now I use AJAX to build the image and rerender it on the page but it take alot of time I believe that with silverlight it won't take that much of time

So any resources on this issue?

You can just set the image src to the base64 string, both on tags and in CSS. So you don't have to convert the base64 string, you can just render it in place. This will give you a faster user experience.

Replace the underscores in the following examples with your base64 string:

<img src="data:image/png;base64,______________">

Or, using CSS:

background-image: url(data:image/png;base64,_____________);

If you want to send something from JavaScript to Silverlight (1) to process it (2), and then maybe back from Silverlight to JavaScript (3), check out the below links. When I say "process it", this probably means saving the image and sending back an image URL. But if you want to display it using Silverlight, this is of course unnecessary.

  1. JavaScript/Silverlight Interop (includes passing JS parameter to Silverlight)
  2. C#: Base64 string to Bitmap
  3. Pass parameters from Silverlight to JavaScript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM