【问题标题】:React native crop image反应原生裁剪图像
【发布时间】: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


    【解决方案1】:

    对不起,这个问题我无能为力。但是有一个库react-native-image-crop-picker 可以帮助解决裁剪问题。希望这会有所帮助。

    【讨论】:

    猜你喜欢
    • 2019-06-19
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多