all files / src/webWorker/decodeTask/decoders/ decodeJPEGBaseline.js

63.64% Statements 7/11
33.33% Branches 2/6
100% Functions 1/1
63.64% Lines 7/11
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                                         
 
 
function decodeJPEGBaseline (imageFrame, pixelData) {
  // check to make sure codec is loaded
  Iif (typeof JpegImage === 'undefined') {
    throw new Error('No JPEG Baseline decoder loaded');
  }
  const jpeg = new JpegImage();
 
  jpeg.parse(pixelData);
 
  // Do not use the internal jpeg.js color transformation,
  // since we will handle this afterwards
  jpeg.colorTransform = false;
 
  Eif (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 decodeJPEGBaseline;