【发布时间】:2020-01-30 03:17:31
【问题描述】:
我在 React Native 中裁剪图像时遇到了一点问题。 正如你可以看到下面的例子 enter image description here
我想裁剪白色矩形内的图像,我不知道我是否使用了错误的公式
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
})
}
};
它不会正确裁剪。 有什么帮助吗?
【问题讨论】:
标签: reactjs react-native crop