Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1640x 1640x 1640x 1640x 1640x 1640x | import getPixelDataTypeFromMinMax from '../shared/getPixelDataTypeFromMinMax'; /** * Helper function to set the right typed array. * This is needed because web workers can transfer array buffers but not typed arrays * * Here we are setting the pixel data to the right typed array based on the final * min and max values */ function setPixelDataType(imageFrame) { const minValue = imageFrame.smallestPixelValue; const maxValue = imageFrame.largestPixelValue; const TypedArray = getPixelDataTypeFromMinMax(minValue, maxValue); if (TypedArray) { // @ts-ignore const typedArray = new TypedArray(imageFrame.pixelData); imageFrame.pixelData = typedArray; } else E{ throw new Error('Could not apply a typed array to the pixel data'); } } export default setPixelDataType; |