小编Moh*_*oui的帖子

反应原生裁剪图像

我在 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
        }
      }) …
Run Code Online (Sandbox Code Playgroud)

crop reactjs react-native

5
推荐指数
1
解决办法
1720
查看次数

标签 统计

crop ×1

react-native ×1

reactjs ×1