當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript postprocess.postProcessRawData函數代碼示例

本文整理匯總了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);
}
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:30,代碼來源:raw.ts

示例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);
}
開發者ID:google,項目名稱:neuroglancer,代碼行數:18,代碼來源:bossNpz.ts

示例3: decodeJpegChunk

export function decodeJpegChunk(chunk: VolumeChunk, response: ArrayBuffer) {
  postProcessRawData(chunk, decodeJpegStack(new Uint8Array(response), chunk.chunkDataSize!));
}
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:3,代碼來源:jpeg.ts


注:本文中的neuroglancer/sliceview/backend_chunk_decoders/postprocess.postProcessRawData函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。