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

0% Statements 0/11
0% Branches 0/6
0% Functions 0/1
0% Lines 0/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
  if (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;
 
  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 decodeJPEGBaseline;