【问题标题】:Flutter how to take a photo with custom width and heightFlutter 如何拍摄具有自定义宽度和高度的照片
【发布时间】:2021-07-12 05:54:21
【问题描述】:

是否可以使用颤振相机插件来拍摄自定义宽度 x 高度的照片?如果这是不可能的,是否有任何裁剪插件可以作为组合来实现?

谢谢。

【问题讨论】:

    标签: flutter camera


    【解决方案1】:

    如果作物将由用户处理,您可以使用image_cropper 插件

    你可以显示一张图片,然后你可以截图it from the code, see this article for details.

      Future<Uint8List> _capturePng() async {
        try {
          print('inside');
          RenderRepaintBoundary boundary =
              _globalKey.currentContext.findRenderObject();
          ui.Image image = await boundary.toImage(pixelRatio: 3.0);
          ByteData byteData =
              await image.toByteData(format: ui.ImageByteFormat.png);
          var pngBytes = byteData.buffer.asUint8List();
          var bs64 = base64Encode(pngBytes);
          print(pngBytes);
          print(bs64);
          setState(() {});
          return pngBytes;
        } catch (e) {
          print(e);
        }
      }
    

    【讨论】:

      猜你喜欢
      • 2016-08-12
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多