本文整理匯總了TypeScript中jpgjs.JpegDecoder.getData方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript JpegDecoder.getData方法的具體用法?TypeScript JpegDecoder.getData怎麽用?TypeScript JpegDecoder.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jpgjs.JpegDecoder
的用法示例。
在下文中一共展示了JpegDecoder.getData方法的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: decodeJpegStack
export function decodeJpegStack(data: Uint8Array, chunkDataSize: Vec3) {
let parser = new JpegDecoder();
parser.parse(data);
if (parser.numComponents !== 1) {
throw new Error('JPEG data does not have the expected number of components');
}
// 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)}`);
}
return parser.getData(parser.width, parser.height, /*forceRGBOutput=*/false);
}