Moh*_*oui 5 crop reactjs react-native
我在 react native 中裁剪图像有一点问题。正如您在下面的示例中看到的那样,请在 此处输入图片说明
我想在白色矩形内裁剪图像,我不知道我是否使用了错误的公式
takePicture = async() => {
console.log("pic")
if (this.camera != null) {
const data = await this.camera.takePictureAsync();
/**
* Calcul
*/
const x_axis_scale = data.width / width
const y_axis_scale = data.height / height
var x_coord_int = 70 * x_axis_scale;
var y_coord_int = 120 * y_axis_scale;
var rect_width_int = 200 * x_axis_scale;
var rect_height_int = 70 * y_axis_scale
const res = await ImageEditor.cropImage(data.uri, {
offset: {x: x_coord_int, y: y_coord_int},
size: {
width:rect_width_int,
height: rect_height_int
}
})
this.setState({
imageCrop: res
})
}
};
Run Code Online (Sandbox Code Playgroud)
它不会正确裁剪。有什么帮助吗?
| 归档时间: |
|
| 查看次数: |
1720 次 |
| 最近记录: |