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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 428x | import type { ByteArray } from 'dicom-parser'; import type { Types } from '@cornerstonejs/core'; import type { WebWorkerDecodeConfig } from '../../types'; const local = { JpegImage: undefined, decodeConfig: {} as WebWorkerDecodeConfig, }; export function initialize( decodeConfig?: WebWorkerDecodeConfig ): Promise<void> { local.decodeConfig = decodeConfig; if (local.JpegImage) { return Promise.resolve(); } return new Promise((resolve, reject) => { import('../../codecs/jpeg') .then((module) => { local.JpegImage = module.default; resolve(); }) .catch(reject); }); } async function decodeJPEGBaseline12BitAsync( imageFrame: Types.IImageFrame, pixelData: ByteArray ): Promise<Types.IImageFrame> { // check to make sure codec is loaded await initialize(); if (typeof local.JpegImage === 'undefined') { throw new Error('No JPEG Baseline decoder loaded'); } const jpeg = new local.JpegImage(); jpeg.parse(pixelData); // Do not use the internal jpeg.js color transformation, // since we will handle this afterwards jpeg.colorTransform = false; if (imageFrame.bitsAllocated === 8) { imageFrame.pixelData = jpeg.getData(imageFrame.columns, imageFrame.rows); return imageFrame; } else if (imageFrame.bitsAllocated === 16) { imageFrame.pixelData = jpeg.getData16(imageFrame.columns, imageFrame.rows); return imageFrame; } } export default decodeJPEGBaseline12BitAsync; |