Android: pixel quality reduction in Images loaded in WebView

前端 未结 2 2012
南笙
南笙 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:14

    The question is old so probably few things changed, but if you are having image quality issues with WebView then consider converting your image into PNG format.

    Somehow when I load the jpeg version of the image the quality is low, while loading the png image with the same resolution the quality is high.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题