Skip to content

Instantly share code, notes, and snippets.

@esimov
Last active July 6, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimov/14a44bd63dd7cd03641e19d5598649ba to your computer and use it in GitHub Desktop.
Save esimov/14a44bd63dd7cd03641e19d5598649ba to your computer and use it in GitHub Desktop.
rgba := c.ctx.Call("getImageData", 0, 0, width, height).Get("data")
// Convert the rgba value of type Uint8ClampedArray to Uint8Array in order to
// be able to transfer it from Javascript to Go via the js.CopyBytesToGo function.
uint8Arr := js.Global().Get("Uint8Array").New(rgba)
js.CopyBytesToGo(data, uint8Arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment