Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIXI.Sprite.from() not working with base64 data URL #6229

Closed
gigamesh opened this issue Nov 19, 2019 · 3 comments
Closed

PIXI.Sprite.from() not working with base64 data URL #6229

gigamesh opened this issue Nov 19, 2019 · 3 comments

Comments

@gigamesh
Copy link

gigamesh commented Nov 19, 2019

Expected Behavior

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).

Current Behavior

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?

Environment

@ivanpopelyshev
Copy link
Collaborator

data:image/gif - not possible. You need your own gif decoder. I had it somewhere...

@eXponenta
Copy link
Contributor

You can pass video element direct to Texture constructor (from call it)

@gigamesh
Copy link
Author

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);

https://codepen.io/Slaz/pen/bGGzxPw?editors=1111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants