簡體   English   中英

如何在 android 應用程序中使用高分辨率(4k)圖像

[英]How to use high resolution(4k) image in android app

我從 API 獲取高分辨率圖像並將它們顯示在我的應用程序上。 我不熟悉處理高分辨率圖像或一般圖像,所以當我看到我的應用程序上的圖像模糊時我很驚訝。

1)可以做些什么來以高分辨率顯示

2)可以做些什么來減輕分辨率的損失?

我正在使用線圈庫將圖像加載到 android 上可組合的圖像中。

在谷歌像素 3a 上進行測試。

這是顯示圖像的應用程序和顯示另一個圖像的瀏覽器之間的差異的示例: 在此處輸入圖像描述

在此處輸入圖像描述

我的可組合看起來像這樣:

Image(
      painter = rememberImagePainter(
                    imageUrl,
                    builder = { allowHardware(false) }
                ),
      contentDescription = "",
      modifier = Modifier
                    .fillMaxWidth()
                    .aspectRatio(1f),
      contentScale = ContentScale.Fit,
     )

更新:

  1. 我嘗試使用 ImageView 而不是可組合的,但我仍然得到相同的結果。

builder中,將圖像大小(以像素為單位)強制為您喜歡的大小。

Image(
    painter = rememberImagePainter(
        imageUrl,
        builder = {
            allowHardware(false)
            size(image.width, image.height)
        }
    ),
    contentDescription = "",
    modifier = Modifier
        .fillMaxWidth()
        .aspectRatio(1f),
    contentScale = ContentScale.Fit,
)

請注意,當指定非常高分辨率時,它會導致崩潰RuntimeException: Canvas: trying to draw too large bitmap

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM