android - 能否禁用/调整 Fresco 对大图像(>2048 像素)的自动调整大小?

标签 android image fresco

在具有 >2048 像素长尺寸的图像上 Fresco automatically applies a resizing :

Android cannot display images more than 2048 pixels long in either dimension. This is beyond the capability of the OpenGL rendering system. Fresco will resize your image if it exceeds this limit.

我知道这是作为 OpenGL Android limit 的变通方法完成的,但是有什么办法可以控制吗?

以下是 Fresco 如何使用默认设置渲染 750x2440 图像的示例: enter image description here

这里是 Picasso 上使用默认设置的相同图像: enter image description here

我已经尝试使用 Fresco 的调整大小/缩减采样但没有成功。

Gist of the code used in the images above

附注:Here's the URL of the image used in my testing

最佳答案

我可以仅使用 isResizeAndRotateEnabledForNetwork() 来实现这一目标来自 ImagePipelineConfig类,我不需要调整下采样。<​​/p>

需要在初始化 Fresco 时增加一个额外的步骤(在 Application 类中);通过 configuring图像管道。

这是 MyApplication 类的样子:

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        ImagePipelineConfig pipelineConfig = ImagePipelineConfig.newBuilder(this)
                .setResizeAndRotateEnabledForNetwork(false)
                .build();
        Fresco.initialize(this, pipelineConfig);
    }
}

所以,不是用 Fresco.initialize(this) 来初始化 Fresco ,添加一个 ImagePipeline 类,将其配置为禁用使用 .setResizeAndRotateEnabledForNetwork(false) 调整来自网络的图像的大小,然后将配置的管道类传递给 Fresco。

设置为false时:

resize_is_false

然后当它设置为 true 时(很可能是默认值):

resize_is_true

关于android - 能否禁用/调整 Fresco 对大图像(>2048 像素)的自动调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53769797/

相关文章:

java - 在 libgdx 中绘制透明的 ShapeRenderer

android - Android MediaRecorder到AudioTrack,录制和播放

android - 资源条目 com.crashlytics.android.build_id 已定义 - Android Studio

r - addImage {ReporteRs} 高度和宽度命令不起作用

android - 从服务器正确下载和显示图像

java - 监听我自己的应用程序制作的 LogCat Entires

javascript - 在 jQuery 中预缓存不同数量的图像,如果所有图像都已加载则回调

javascript - 带控件的 jQuery 图像数组循环

android - 在Gradle上运送多个APK

android - 共享元素过渡和 Fresco 无法正常工作