On Thursday, March 12, 2020 at 11:35:30 AM UTC-6, Agniva De Sarker wrote: > > There is no base64 conversion now anywhere. If you read the code below, > you'll see I use > > dst := js.Global().Get("Uint8Array").New(len(s.outBuf.Bytes())) > n := js.CopyBytesToJS(dst, s.outBuf.Bytes()) > s.console.Call("log", "bytes copied:", strconv.Itoa(n)) > js.Global().Call("displayImage", dst) > > Essentially, I copy over the bytes to the array and pass the array over to > JS land. > > And then displayImage does this: > > function displayImage(buf) { > let blob = new Blob([buf], {'type': imageType}); > document.getElementById('targetImg').src = URL.createObjectURL(blob); > } >
I see. In your case, targetImg is an <img>, right? Do you know how I could use this same technique with a <canvas>? Thanks for the code. It's good to see that there's a way to skip base64 conversions during the Go-to-JavaScript data transfer. — Scott -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/633d160f-4636-40f9-84be-d59af911eedd%40googlegroups.com.