Android: pixel quality reduction in Images loaded in WebView

前端 未结 2 2019
南笙
南笙 2020-12-18 07:50

I am building Javascript application for mobile browsers (not wrapped-as-native app).

I noticed that Android (tested 2.3 emulator and Galaxy S device) reduces the q

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 08:32

    Android unconditionally resamples images and reduces quality if a certain threshold of memory usage is exceeded.
    https://android.googlesource.com/platform/external/webkit/+/android-3.2.4_r1/WebCore/platform/graphics/android/ImageSourceAndroid.cpp

    There is no way to access the original image data in intact.

    I posted a question regarding this to android-developers Google Group and kindly asking to maybe provide some kind of flag to opt-out from this behavior.

    Meanwhile, if you are considering developing HTML5 web apps and you might use big images, you simply need to preprocess them on the server-side by slicing, send in smaller images to the device and then reconstuct the original image using or putting many tags inside a container element.

    Another option would be load image "manually" by writing a PNG decoder which directly loads the image to , bypassing ImageSourceAndroid class.

提交回复
热议问题