简体   繁体   中英

Expo.launchCameraAsync custom image view?

I am creating camera feature for my app so that after the user takes the photo, they can rescale and move it around a bounding box. Expo have an out of box API that does what I want:

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

but I would also like the camera screen itself to be full screen, so no black bars on top and bottom, I have the view here:

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>

The detail isn't important, the point is that I can create a Camera view. Now the question is is there a way to pass in this camera view into launchCameraAsync ? The documentation does not seem to provide a solution.

I think this combinition is not possible.

ImagePicker.launchCameraAsync({ allowsEditing: true, aspect: [4,3] }) is calling a full capsuled expo component.

If you want to create a customized view, you have to handle all states and video/photo actions by you're own.

Try launching an ImageManipulator after the picture is taken. After calling takePictureAsync, wait for the promise to resolve, then you'll get the local uri of the image, being able to pass that to the ImageManipulator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM