ephraimt

Sprite from buffer

Recommended Posts

I am trying to display an image that I get in the form of Uint8Array.

/*
width: 640,
height: 360,
data: Uint8Array(921600) [
     89,  72, 34, 255,  97,  80, 42, 255, 105,  93, 43, 255,
    117, 105, 55, 255, 117, 106, 49, 255, 110,  99, 42, 255,
    111,  98, 31, 255, 111,  98, 31, 255, 115, 107, 22, 255,
    117, 109, 24, 255, 119, 115, 16, 255, 117, 113, 14, 255,
    127, 121, 13, 255, 131, 125, 17, 255, 144, 126, 30, 255,
    146, 128, 32, 255, 143, 131, 35, 255, 135, 123, 27, 255,
    130, 112, 26, 255, 127, 109, 23, 255, 129, 103, 32, 255,
    126, 100, 29, 255, 125,  94, 28, 255, 123,  92, 26, 255,
    121,  80, 20, 255,
    ... 921500 more items
*/

const imageTexture = PIXI.Texture.fromBuffer(data, width, height);
const sprite = PIXI.Sprite(imageTexture);

Is there something else I have to do so that the Sprite displays the Texture?

If I create imageTexture using PIXI.Loader, then it works.

Share this post


Link to post
Share on other sites

"pixi.js-legacy": "^5.2.0"

Using canvas renderer.

My alternate method of creating an image Sprite is to use PIXI.Loader and then to pass the resulting resource.data to PIXI.Texture.from().

That works fine, so it seems the difference is isolated to the creation of the texture.

Share this post


Link to post
Share on other sites

Oh, right, fromBuffer() doesnt work with canvas2d. Whole TextureResource subsystem werent coded for it yet, because no one needed that. Now that you've asked for it , we can have that in two months or so, because it requires to code whole system for canvas and not just one "fromBuffer", and most of the team is busy.

Edited by ivan.popelyshev

Share this post


Link to post
Share on other sites
2 hours ago, ivan.popelyshev said:

Now that you've asked for it , we can have that in two months or so, because it requires to code whole system for canvas and not just one "fromBuffer", and most of the team is busy.

I am not asking for it. There are probably more important things for the team to work on!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.