node-addon-examples icon indicating copy to clipboard operation
node-addon-examples copied to clipboard

Please provide example of napi operate arraybuffer.

Open gzx-miller opened this issue 5 years ago • 1 comments

Please provide example of napi operate arraybuffer. I want show ffmpeg decoded image to electron canvas. So, I tried create a ArrayBuffer in js, then pass as param in napi function. then, I load ffmpeg to decode image one by one, but there is no clear way to copy image memory to this ArrayBuffer in napi one by one.

gzx-miller avatar Jul 10 '20 05:07 gzx-miller

If you are talking about JPEG image

Napi::Buffer<uint8_t> jpeg_buffer = Napi::Buffer<uint8_t>::New(env, jpeg_packet->data, jpeg_packet->size);

This jpeg_buffer can be passed to JS caller as a return value

prithivirajmurugan avatar Aug 21 '23 10:08 prithivirajmurugan