xtk / X

The X Toolkit
http://www.goXTK.com
Other
786 stars 263 forks source link

[Fix] Raw encoded NRRDs parse correctly #229

Open RhinoBlindado opened 2 years ago

RhinoBlindado commented 2 years ago

The original code used an ArrayBuffer to get the voxel data, this worked fine for gzip/gz encoded files because when the voxel data was decompressed, it returned a new ArrayBuffer of just the voxel data, so just using _data = _data.buffer; worked fine.

When a raw file was detected, it also grabbed the ArrayBuffer of the sliced data, but, it turns that this variable is a subarray of the whole file as seen in var _data = _bytes.subarray(_data_start);.

Problem is, trying to get the buffer from a sliced subarray returns the whole original buffer, not a sliced one; so this was fixed by using the same offset to only get the buffer data of the voxels like so: _data = _data.buffer.slice(_data_start);