@@ -45,20 +45,20 @@ exports.convertRgbaToPng = (rgba, width, height, compressionLevel = COMPRESSION_
4545 pointer = resultBuffer . writeUInt8 ( PNG . COMPRESSION_DEFLATE , pointer ) ;
4646 pointer = resultBuffer . writeUInt8 ( PNG . FILTER_NO_FILTER , pointer ) ;
4747 pointer = resultBuffer . writeUInt8 ( PNG . INTERLACE_NO_INTERLACE , pointer ) ;
48- const ihdrCrc = crc32 ( Buffer . from ( resultBuffer . buffer , ihdrPointer , pointer - ihdrPointer ) ) ;
48+ const ihdrCrc = crc32 ( resultBuffer . subarray ( ihdrPointer , pointer ) ) ;
4949 pointer = resultBuffer . writeUInt32BE ( ihdrCrc , pointer ) ;
5050
5151 // IDAT
5252 const idatPointer = ( pointer = resultBuffer . writeUInt32BE ( compressedData . length , pointer ) ) ;
5353 pointer += resultBuffer . write ( "IDAT" , idatPointer , "ascii" ) ;
5454 pointer += compressedData . copy ( resultBuffer , pointer ) ;
55- const idatCrc = crc32 ( Buffer . from ( resultBuffer . buffer , idatPointer , pointer - idatPointer ) ) ;
55+ const idatCrc = crc32 ( resultBuffer . subarray ( idatPointer , pointer ) ) ;
5656 pointer = resultBuffer . writeUInt32BE ( idatCrc , pointer ) ;
5757
5858 // IEND (empty)
5959 const iendPointer = ( pointer = resultBuffer . writeUInt32BE ( 0 , pointer ) ) ;
6060 pointer += resultBuffer . write ( "IEND" , pointer , "ascii" ) ;
61- const iendCrc = crc32 ( Buffer . from ( resultBuffer . buffer , iendPointer , pointer - iendPointer ) ) ;
61+ const iendCrc = crc32 ( resultBuffer . subarray ( iendPointer , pointer ) ) ;
6262 pointer = resultBuffer . writeUInt32BE ( iendCrc , pointer ) ;
6363
6464 if ( pointer !== resultBuffer . byteLength ) {
0 commit comments