Skip to content Skip to sidebar Skip to footer

Winrt, Javascript, Image From Byte Array

I have a C++/CX component that can return an image as a stream (I could easily make it return an IBuffer, if that makes things easier). Currently, the component's return type is IR

Solution 1:

I've done this in C# before not in C++, but the basics should be similar.

  1. Get the byte array from the stream
  2. Convert the byte array to Base64String (Convert.ToBase64String)
  3. Now you can use this string directly in the image tag:

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

Post a Comment for "Winrt, Javascript, Image From Byte Array"