I'm attempting to insert an image into a Pixi canvas by using a base64 data URL string. I need to use that because the image is getting created from a camera feed (video tag).
It works if I insert a regular image URL into the first argument of Sprite.from
, but not when I use a base64 data URL.
Ex: https://codepen.io/gigamesh/pen/GRRzdrL?editors=1111
Is what I'm attempting even possible? If so, how?
pixi.js
version: 5.1.2data:image/gif
- not possible. You need your own gif decoder. I had it somewhere...
You can pass video element direct to Texture constructor (from
call it)
here is the solution for anyone who finds this thread:
// img tag points to base64 URL
const image = document.querySelector('img')
const base = new PIXI.BaseTexture(image);
const texture = new PIXI.Texture(base);
const sprite = new PIXI.Sprite(texture);
Most helpful comment
here is the solution for anyone who finds this thread:
https://codepen.io/Slaz/pen/bGGzxPw?editors=1111