Skip to content Skip to sidebar Skip to footer

How Do I Read Out The First 4 Bytes In Javascript, Turn It Into An Integer And Remove The Rest?

I need to transfer webcam data over the internet from one browser to another. The webcam is displayed in a HTML5 canvas. Then I get its dataUrl, and turn it into a blob. Then I se

Solution 1:

You can use Blob.slice() method to get bytes.
See docs: https://developer.mozilla.org/en-US/docs/Web/API/Blob.slice

1)

var bytes = blob.slice(0,4);

2)

var arrayOfBytes = [];
for(var i=0;i<blob.size/4;i++){
    arrayOfBytes[i] = blob.slice(i*4,4+(i*4));
}

Note: I didn't test it!


Post a Comment for "How Do I Read Out The First 4 Bytes In Javascript, Turn It Into An Integer And Remove The Rest?"