Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大图缩放消失 #30

Closed
liushiqi9 opened this issue Jul 14, 2019 · 6 comments
Closed

大图缩放消失 #30

liushiqi9 opened this issue Jul 14, 2019 · 6 comments

Comments

@liushiqi9
Copy link

放大一张高清图时会发生黑屏。 一开始可以正常放大, 放大到大约1.2倍之后就会黑屏, 缩放比例恢复后又会恢复显示。
复现步骤:
将demo中的图片路径换成附件的图片, 然后放大。
图片:
high_resolution

@zmtzawqlp
Copy link
Member

估计是内存爆炸了吧。。这种需求。我感觉需要使用插件来压缩你的图片。。flutter里面大图片的问题。蛮多的

@liushiqi9
Copy link
Author

估计是内存爆炸了吧。。这种需求。我感觉需要使用插件来压缩你的图片。。flutter里面大图片的问题。蛮多的

有什么解决方案吗 我们强需求需要放大图后展示要很清晰。

我现在想到的就是是不是可以直接调安卓原生的图片展示功能。

@zmtzawqlp
Copy link
Member

这种要定制吧。。比如直接拿出放大区域的数据进行显示,感觉原生也一样够呛

@liushiqi9
Copy link
Author

这种要定制吧。。比如直接拿出放大区域的数据进行显示,感觉原生也一样够呛

有没有办法直接调高他对内存的容忍, 就是调高显示图片的内存上限, 讲道理7000*9000的图也没多大才对。

@zmtzawqlp
Copy link
Member

Transform.scale(scale: null) 我试了下,用官方的,一样也是这样的,我怀疑是引擎的问题,你可以去官方提一下issue

//import 'package:example/main.dart';
//import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';

class ZoomImageDemo extends StatefulWidget {
  @override
  _ZoomImageDemoState createState() => _ZoomImageDemoState();
}

class _ZoomImageDemoState extends State<ZoomImageDemo> {
  double scale = 1.0;
  @override
  Widget build(BuildContext context) {
    return Material(
        child: Column(children: <Widget>[
      AppBar(
        title: Text("zoom/pan image demo"),
      ),
      Expanded(
        child: GestureDetector(
            onScaleUpdate: (value) {
              setState(() {
                scale = value.scale;
              });
            },
            child: Transform.scale(
              scale: scale,
              child: Image.network(
                "https://user-images.githubusercontent.com/6860451/61188926-e48ab680-a6b8-11e9-9eec-c14c9c3279f9.jpg",
                fit: BoxFit.contain,
                //enableLoadState: false,
//          mode: ExtendedImageMode.Gesture,
//          initGestureConfigHandler: (state) {
//            return GestureConfig(
//                minScale: 0.9,
//                animationMinScale: 0.7,
//                maxScale: 3.0,
//                animationMaxScale: 3.5,
//                speed: 1.0,
//                inertialSpeed: 100.0,
//                initialScale: 1.0,
//                inPageView: false);
//          },
              ),
            )),
      )
    ]));
  }
}

@zmtzawqlp
Copy link
Member

@liushiqi9 你开的issue 有人回复了。。
补充一下你可以通过设置下面代码来显示大图,你可以根据你图片大小来设置这个上限,但是感觉治标不治本

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  const maxBytes = 768  * (1 << 20);
  // Invoke both method names to ensure the correct one gets invoked.
  SystemChannels.skia.invokeMethod('setResourceCacheMaxBytes', maxBytes);
  SystemChannels.skia.invokeMethod('Skia.setResourceCacheMaxBytes', maxBytes);
  runApp(MyApp());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants