本文整理汇总了TypeScript中neuroglancer/util/array.transposeArray2d函数的典型用法代码示例。如果您正苦于以下问题:TypeScript transposeArray2d函数的具体用法?TypeScript transposeArray2d怎么用?TypeScript transposeArray2d使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了transposeArray2d函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: decodeJpegStack
export function decodeJpegStack(data: Uint8Array, chunkDataSize: vec3, numComponents: number) {
let parser = new JpegDecoder();
parser.parse(data);
// Just check that the total number pixels matches the expected value.
if (parser.width * parser.height !== chunkDataSize[0] * chunkDataSize[1] * chunkDataSize[2]) {
throw new Error(
`JPEG data does not have the expected dimensions: ` +
`width=${parser.width}, height=${parser.height}, ` +
`chunkDataSize=${vec3.str(chunkDataSize)}`);
}
if (parser.numComponents !== numComponents) {
throw new Error(
`JPEG data does not have the expected number of components: ` +
`components=${parser.numComponents}, expected=${numComponents}`);
}
if (parser.numComponents === 1) {
return parser.getData(parser.width, parser.height, /*forceRGBOutput=*/false);
} else if (parser.numComponents === 3) {
let output = parser.getData(parser.width, parser.height, /*forceRGBOutput=*/false);
return transposeArray2d(output, parser.width * parser.height, 3);
} else {
throw new Error(
`JPEG data has an unsupported number of components: components=${parser.numComponents}`);
}
}
示例2: it
it('single axis', () => {
let arr = new Uint8Array(3), out = new Uint8Array(3);
arr.set([0, 1, 2]);
out.set([0, 1, 2]);
expect(transposeArray2d(arr, 3, 1)).toEqual(out);
});