【问题标题】:Glide takes time to Load Large image AndroidGlide 需要时间加载大图 Android
【发布时间】:2019-06-17 23:52:14
【问题描述】:
 RequestOptions requestOptions = new RequestOptions();
        requestOptions.error(R.mipmap.ic_launcher);
        requestOptions.diskCacheStrategy(DiskCacheStrategy.ALL);
        requestOptions.dontTransform();
        requestOptions.fitCenter();
        requestOptions.priority(Priority.HIGH);

        Glide.with(context)
                .setDefaultRequestOptions(requestOptions)
                .load(images.get(position))
                .into(holder.pictureView);

图像高度宽度(JPEG 图像,4608 × 3456 像素)

大小:6,149.64 KB(6,297,232 字节)

第一次使用 Glide 4.7.1 加载大图像需要一些时间 请为我提供解决方案。我也尝试过使用 fresco,它比 Glide 花费更多时间。

【问题讨论】:

  • 做某事需要时间不是很自然吗?例如,处理大图像预计需要一些时间。

标签: android android-glide


【解决方案1】:

当您从URL, 获取图像时,只需添加此代码即可减小该图像的大小。

在这里你可以找到你的solution

ByteArrayOutputStream bytes = new ByteArrayOutputStream();

    //save scaled down image to cache dir
    newBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);

    File imageFile = new File(filePath);

    // write the bytes in file
    FileOutputStream fo = new FileOutputStream(imageFile);
    fo.write(bytes.toByteArray());

您可以使用其他 Glide 选项。

Glide.with(context)
                .setDefaultRequestOptions(requestOptions)
                .load(images.get(position))
                .error(R.drawable.no_internet_con)
                .thumbnail(.1f)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(R.drawable.image)
                .into(holder.pictureView);

【讨论】:

  • 在不提供额外信息的情况下链接到较早的解决方案被认为是微不足道的,应该改为评论。
  • @ZUNJAE 我认为这是一条评论,但不幸的是出错了。
  • 请提供简要信息您想说什么?
  • @MihirModi 缩小图片大小然后在滑行中加载
  • 抱歉,我的客户拒绝调整图像质量。在 Web 中,当我使用相同的网络加载该图像时,其最大负载在 10 秒内,而在应用程序中滑行需要比 Web 更多的时间。
【解决方案2】:

这取决于两件事。

01. Your Internet Speed. 
02. Yor photo size.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 2013-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多