在长尺寸 >2048px 的图像上 Fresco自动应用调整大小 https://frescolib.org/docs/troubleshooting.html:
Android 无法显示任一维度长度超过 2048 像素的图像。这超出了OpenGL渲染系统的能力。如果超过此限制,Fresco 将调整您的图像大小。
据我了解,这是作为解决方法OpenGL Android 限制 https://stackoverflow.com/questions/10271020/bitmap-too-large-to-be-uploaded-into-a-texture,但是有什么办法可以控制吗?
Here is an example of how Fresco is rendering a 750x2440 image with the default settings:
And here is the same image on Picasso with the default settings:
我已经尝试使用 Fresco 的调整大小/下采样但没有成功。
上图中使用的代码要点 https://gist.github.com/mmazzarolo/9fe9a142fe6259400c6fe3b19108f5e3
P.S.:
我只能使用以下方法来实现此目的isResizeAndRotateEnabledForNetwork() https://frescolib.org/javadoc/reference/com/facebook/imagepipeline/core/ImagePipelineConfig.html#isResizeAndRotateEnabledForNetwork()来自图像管道配置 https://frescolib.org/javadoc/reference/com/facebook/imagepipeline/core/ImagePipelineConfig.html类,我不需要调整下采样。
初始化Fresco时需要添加一个额外的步骤(在Application类中);经过配置 https://frescolib.org/docs/configure-image-pipeline.html图像管道。
MyApplication 类如下所示:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ImagePipelineConfig pipelineConfig = ImagePipelineConfig.newBuilder(this)
.setResizeAndRotateEnabledForNetwork(false)
.build();
Fresco.initialize(this, pipelineConfig);
}
}
因此,不用初始化 FrescoFresco.initialize(this)
,添加一个 ImagePipeline 类,将其配置为禁用调整来自网络的图像大小.setResizeAndRotateEnabledForNetwork(false)
,然后将配置好的管道类传递给Fresco。
当它设置为 false 时:
然后当它设置为 true (很可能是默认值)时:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)