If you need to read various types of values from arbitrary offsets, DataView is more handy. It has no alignment requirements.
How to create an Int32Array view that starts on an arbitrary byte of the buffer
-
30-06-2022 - |
質問
Given some ArrayBuffer like:
var data = new ArrayBuffer(64);
I want to be able to write 32bit integers at any position (not only 32bit aligned).
For example:
[0][1][2][3][4][5][6][7][8][9] ... byte data
[__________][__________] ... I want to create an Int32Array with 1 byte offset
Is that possible?
Unfortunately, the byteOffset
attribute is read-only and if it's set when creating the view, it only accepts multiples of 4 (for int32s).
解決
所属していません StackOverflow