gre / react-native-view-shot

Snapshot a React Native view and save it to an image

Home Page:https://github.com/gre/react-native-view-shot-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advice needed - what’s the most efficient way of getting pixel data into a buffer

tomyates opened this issue · comments

I’m currently doing something which I admit is pretty hacky but I’d like to know how to improve it.

I have an iOS app, and I'm using a 3D engine (Babylon) to render a scene. One the elements of the scene is a sprite that gets it's texture from a video elsewhere in RN.

15 times a second I’m taking a shot of a webrtc video component and saving the result as a png tmp file.
In Babylon, I’m loading that in as texture by reading the tmp file 15 times and second.

This works ok, however, it feels really inefficient and a waste of hdd read and writes.
I've tried using base64 string data instead - but this is far slower, as it's coming over the bridge.

Is there a better solution that doesn't use tmp files, perhaps using RAW pixel data?

Thanks!

i'm not really sure how this question relates to this library. i'm afriad you may need to ask on other website, like stackoverflow.