代码之家  ›  专栏  ›  技术社区  ›  xiaolingxiao

Expo.launchCameraAsync自定义图像视图?

  •  1
  • xiaolingxiao  · 技术社区  · 6 年前

    我正在为我的应用程序创建相机功能,以便在用户拍摄照片后,他们可以重新缩放并围绕边界框移动它。 Expo 有一个开箱即用的API,可以满足我的要求:

    ImagePicker.launchCameraAsync({ allowsEditing: true, aspect: [4,3] })
    

    import { ImagePicker, Camera, Permissions, FileSystem } from 'expo';
    
        <View style={{ flex: 1 }}>
            <Camera 
                style = {{ flex: 1 }} 
                type  = {this.state.type}
                ref   = {ref => { this.camera = ref }} 
            >
                <View style={camera.container}>
                    <TouchableOpacity 
                        style = {this.state.css.touchable}
                        onPress={this.onTap}
                    />
    
                    <Button transparent
                        onPress = {this.onSnapShot}
                        style   = {[camera.buttonContainer, this.state.css.button]}
                    >
                        <Entypo 
                            name  = 'circle' 
                            size  = {fonts.camera} 
                            color = {colors.wineWhite}
                        />
                    </Button>
                </View>
            </Camera>
        </View>
    

    细节并不重要,关键是我可以创建一个 Camera 查看。现在的问题是,有没有一种方法可以通过这个摄像头进入 launchCameraAsync

    2 回复  |  直到 6 年前
        1
  •  1
  •   Mats    6 年前

    我认为这种结合是不可能的。

    ImagePicker.launchCameraAsync({ allowsEditing: true, aspect: [4,3] }) 正在调用完全封装的expo组件。

    如果要创建自定义视图,必须自己处理所有状态和视频/照片操作。

        2
  •  1
  •   Filipe    6 年前

    尝试启动 ImageManipulator 拍完照片后。在调用takePictureAsync之后,等待承诺解决,然后您将获得图像的本地uri,能够将其传递给ImageManipulator。