how can i take a screenshot of camera screen using a button in react native?

亡梦爱人 提交于 2019-12-07 10:26:50

问题


I use a react native camera and a overlaying image on my app. Now i want to take a screenshot of that screen using a button. But when i take screenshot then only the overlaying image are shown on the image. i need to capture the screen with camera view and the overlaying image also.

return (
      <Camera
        ref={(cam) => {
          this.camera = cam;
        }}
        style={styles.preview}
        aspect={Camera.constants.Aspect.fill}
        captureTarget={Camera.constants.CaptureTarget.disk}
      >
      	<Image
              style={{width: 400, height: 400}}
              source={require('./image/shilpamela.png')}
            />
        <TouchableHighlight
          style={styles.capture}
          //onPress={this.takePicture.bind(this)}
          onPress={
            () => {
              captureScreen({
                format: "jpg",
                quality: 0.8
              })
              .then(
                uri => {
                  CameraRollExtended.saveToCameraRoll({
                    uri: uri,
                    album: 'Name'
                  }, 'photo')
                },
                error => console.error("Oops, snapshot failed", error)
              );
            }
          }
          underlayColor="rgba(255, 255, 255, 0.5)"
        >
          <View>
            <Image
              style={{width: 60, height: 60}}
              source={require('./image/cam_button.png')}
            />
          </View>
        </TouchableHighlight>
      </Camera>
    );

来源:https://stackoverflow.com/questions/47975792/how-can-i-take-a-screenshot-of-camera-screen-using-a-button-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!