本文整理汇总了TypeScript中neuroglancer/sliceview/backend_chunk_decoders/postprocess.postProcessRawData函数的典型用法代码示例。如果您正苦于以下问题:TypeScript postProcessRawData函数的具体用法?TypeScript postProcessRawData怎么用?TypeScript postProcessRawData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了postProcessRawData函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: decodeRawChunk
export function decodeRawChunk(chunk: VolumeChunk, response: ArrayBuffer) {
let {spec} = chunk.source!;
let {dataType} = spec;
let numElements = prod3(chunk.chunkDataSize!);
let bytesPerElement = DATA_TYPE_BYTES[dataType];
let expectedBytes = numElements * bytesPerElement * spec.numChannels;
if (expectedBytes !== response.byteLength) {
throw new Error(
`Raw-format chunk is ${response.byteLength} bytes, but ${numElements} * ${bytesPerElement} = ${expectedBytes} bytes are expected.`);
}
let data: ArrayBufferView;
switch (dataType) {
case DataType.UINT8:
data = new Uint8Array(response);
break;
case DataType.UINT16:
data = new Uint16Array(response);
break;
case DataType.UINT32:
case DataType.UINT64:
data = new Uint32Array(response);
break;
case DataType.FLOAT32:
data = new Float32Array(response);
break;
default:
throw new Error(`Unexpected data type: ${dataType}.`);
}
postProcessRawData(chunk, data);
}
示例2: decodeBossNpzChunk
export function decodeBossNpzChunk(chunk: VolumeChunk, response: ArrayBuffer) {
let parseResult = parseNpy(inflate(new Uint8Array(response)));
let chunkDataSize = chunk.chunkDataSize!;
let source = chunk.source!;
let {shape} = parseResult;
if (shape.length !== 3 || shape[0] !== chunkDataSize[2] ||
shape[1] !== chunkDataSize[1] || shape[2] !== chunkDataSize[0]) {
throw new Error(
`Shape ${JSON.stringify(shape)} does not match chunkDataSize ${vec3Key(chunkDataSize)}`);
}
let parsedDataType = parseResult.dataType.dataType;
let {spec} = source;
if (parsedDataType !== spec.dataType) {
throw new Error(
`Data type ${DataType[parsedDataType]} does not match expected data type ${DataType[spec.dataType]}`);
}
postProcessRawData(chunk, parseResult.data);
}
示例3: decodeJpegChunk
export function decodeJpegChunk(chunk: VolumeChunk, response: ArrayBuffer) {
postProcessRawData(chunk, decodeJpegStack(new Uint8Array(response), chunk.chunkDataSize!));
}