Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142239

How to effectively concat Uint8Array?

$
0
0

I'm trying to create a GIF image from scratch on the browser. It all works, but it get a lot of time to build small image which feels underwhelming. (2.6s for a 300x200 with 100 frames on a high-end proc)

Currently, I'm concatenating all my data into a simple Array and turn everything into a Uint8Array when done. I guess using Uint8Array would be better memory and efficiency wise, but I didn't figured out how to concat my data as I create it.

I tried to recreate the Uint8Array each times, but it obviously reduces performances. I tried to use Stream, but never manage to make it work.

// kinda concat
stream = new Uint8Array([
    ...stream,
    ...graphicControlExtension,
    ...imageDescriptor,
]);

MDN Stream example are just confusing, so if someone could point me to the right direction it would be dope. =D


Viewing all articles
Browse latest Browse all 142239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>