_checkImageTypeAndDecode (frames) {
    const fullEncodedBitStream = new Uint8Array(frames)
    const imageTypeObject = imageType(fullEncodedBitStream)
    if (imageTypeObject === null) {
      // this is uncompressed (octet-stream), just return undefined and
      // createURLFromRGBImage and colorMonochromeImageFrame will deal with it
      return {
        pixelData: undefined,
        decodedframeInfo: undefined,
        mediaType: undefined
      }
    }
    const mediaType = imageTypeObject.mime
    let pixelData
    let decodedframeInfo
    if (mediaType === 'image/jpeg') {
      if (!jpegDecoder) {
        throw new Error(
          'jpegDecoder was not initialized.'
        )
      }
      // data are compressed jpeg -> decode
      const { decodedPixelData, frameInfo } = this._decodeInternal(jpegDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/jp2' || mediaType === 'image/jpx') {
      if (!jp2jpxDecoder) {
        throw new Error(
          'jp2jpxDecoder was not initialized.'
        )
      }
      // data are compressed jp2 -> decode
      const { decodedPixelData, frameInfo } = this._decodeInternal(jp2jpxDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/jls') {
      if (!jlsDecoder) {
        throw new Error(
          'jlsDecoder was not initialized.'
        )
      }
      // data are compressed jls -> decode
      const { decodedPixelData, frameInfo } = this._decodeInternal(jlsDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/png') {
      return {
        pixelData: undefined,
        decodedframeInfo: undefined,
        mediaType
      }
    } else {
      throw new Error(
        'The media type ' + mediaType + ' is not supported by the offscreen render.'
      )
    }

    return {
      pixelData,
      decodedframeInfo,
      mediaType
    }
  }
/** Check image type of a compressed array and returns a decoded image
   * NOTE: for png at the moment we don't have a library for decoding,
   *       undefined is returned.
   * @param {number[]} frames - buffer of the image array
   * @returns {obejct} image array, frameInfo and mediaType.
   * @private
   */
Check image type of a compressed array and returns a decoded image
NOTE: for png at the moment we don't have a library for decoding,
undefined is returned.
@param {number[]} frames - buffer of the image array
@returns {obejct} image array, frameInfo and mediaType.
@private
Check image type of a compressed array and returns a decoded image NOTE : for png at the moment we don ' t have a library for decoding undefined is returned . @param { number [] } frames - buffer of the image array @returns { obejct } image array frameInfo and mediaType . @private
_checkImageTypeAndDecode (frames) {
    const fullEncodedBitStream = new Uint8Array(frames)
    const imageTypeObject = imageType(fullEncodedBitStream)
    if (imageTypeObject === null) {
      return {
        pixelData: undefined,
        decodedframeInfo: undefined,
        mediaType: undefined
      }
    }
    const mediaType = imageTypeObject.mime
    let pixelData
    let decodedframeInfo
    if (mediaType === 'image/jpeg') {
      if (!jpegDecoder) {
        throw new Error(
          'jpegDecoder was not initialized.'
        )
      }
      const { decodedPixelData, frameInfo } = this._decodeInternal(jpegDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/jp2' || mediaType === 'image/jpx') {
      if (!jp2jpxDecoder) {
        throw new Error(
          'jp2jpxDecoder was not initialized.'
        )
      }
      const { decodedPixelData, frameInfo } = this._decodeInternal(jp2jpxDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/jls') {
      if (!jlsDecoder) {
        throw new Error(
          'jlsDecoder was not initialized.'
        )
      }
      const { decodedPixelData, frameInfo } = this._decodeInternal(jlsDecoder, fullEncodedBitStream)
      pixelData = decodedPixelData.slice(0)
      decodedframeInfo = frameInfo
    } else if (mediaType === 'image/png') {
      return {
        pixelData: undefined,
        decodedframeInfo: undefined,
        mediaType
      }
    } else {
      throw new Error(
        'The media type ' + mediaType + ' is not supported by the offscreen render.'
      )
    }
    return {
      pixelData,
      decodedframeInfo,
      mediaType
    }
  }
_checkImageTypeAndDecode ( frames ) { const fullEncodedBitStream = new Uint8Array ( frames ) const imageTypeObject = imageType ( fullEncodedBitStream ) if ( imageTypeObject === null ) { return { pixelData : undefined , decodedframeInfo : undefined , mediaType : undefined } } const mediaType = imageTypeObject . mime let pixelData let decodedframeInfo if ( mediaType === 'image/jpeg' ) { if ( ! jpegDecoder ) { throw new Error ( 'jpegDecoder was not initialized.' ) } const { decodedPixelData , frameInfo } = this . _decodeInternal ( jpegDecoder , fullEncodedBitStream ) pixelData = decodedPixelData . slice ( 0 ) decodedframeInfo = frameInfo } else if ( mediaType === 'image/jp2' || mediaType === 'image/jpx' ) { if ( ! jp2jpxDecoder ) { throw new Error ( 'jp2jpxDecoder was not initialized.' ) } const { decodedPixelData , frameInfo } = this . _decodeInternal ( jp2jpxDecoder , fullEncodedBitStream ) pixelData = decodedPixelData . slice ( 0 ) decodedframeInfo = frameInfo } else if ( mediaType === 'image/jls' ) { if ( ! jlsDecoder ) { throw new Error ( 'jlsDecoder was not initialized.' ) } const { decodedPixelData , frameInfo } = this . _decodeInternal ( jlsDecoder , fullEncodedBitStream ) pixelData = decodedPixelData . slice ( 0 ) decodedframeInfo = frameInfo } else if ( mediaType === 'image/png' ) { return { pixelData : undefined , decodedframeInfo : undefined , mediaType } } else { throw new Error ( 'The media type ' + mediaType + ' is not supported by the offscreen render.' ) } return { pixelData , decodedframeInfo , mediaType } }
Check image type of a compressed array and returns a decoded image
 NOTE: for png at the moment we don't have a library for decoding,
       undefined is returned.
Check image type of a compressed array and returns a decoded image NOTE : for png at the moment we don ' t have a library for decoding undefined is returned .
// this is uncompressed (octet-stream), just return undefined and // createURLFromRGBImage and colorMonochromeImageFrame will deal with it // data are compressed jpeg -> decode // data are compressed jp2 -> decode // data are compressed jls -> decode