反应本地作物图像 [英] React native crop image
本文介绍了反应本地作物图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在裁剪本机图像时遇到一些问题.如您所见,下面的示例在此处输入图片描述
I have a little problem with cropping images in react native. As you can see the example below enter image description here
我想在白色矩形内裁剪图像,不知道是否使用了错误的公式
I want to crop the image inside the white rectangle, I don't know if I'm using the wrong formula or not
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
})
}
};
无法正确裁剪.有帮助吗?
It doesn'tt crop correcty. Any help?
推荐答案
对不起,我不能解决这个问题.但是有一个库 react-native-image-crop-picker 这可以帮助解决裁剪问题.希望这会有所帮助.
Sorry , i can't help about this issue . But there is a library react-native-image-crop-picker which can help with cropping issue . Hope this helps.
这篇关于反应本地作物图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文