Android的:在图像的像素质量下降的WebView加载 [英] Android: pixel quality reduction in Images loaded in WebView

查看:176
本文介绍了Android的:在图像的像素质量下降的WebView加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立的Javascript应用程序的移动浏览器(不包,因为本机应用程序)。

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

我注意到的Andr​​oid(2.3测试仿真器和Galaxy S的设备)降低加载的图像的质量如果图像尺寸超过一定的阈值(宽度高于1400像素左右)。这使得不可能没有质量会不可用装载大的位图图像(2000×2000像素)。

I noticed that Android (tested 2.3 emulator and Galaxy S device) reduces the quality of loaded images if the image dimensions exceed certain threshold (width above 1400 px or so). This make it impossible to load big bitmap images (2000 x 2000 px) without the quality going unusable.

我在

  • 加载一个大的图像,并绘制它的 - 我像素垃圾出。如果我用画了lineTo()网格线,他们有完善的质量,所以不好必须在图像像素数据

  • Loading one big image and drawing it on the - I got pixel garbage out. If I draw grid lines using lineTo() on they have perfect quality, so the bad must be in the image pixel data

切片的大图像100×100片,并将其绘制在画布 - 这是我发现造成无质量降低的唯一方法。然而,切片很麻烦,增加了额外的步骤,以preprocess图片和页面加载时间遭受

Slicing the big image to 100 x 100 slices and drawing them to a canvas - this is the only method I found resulting no quality reduction. However, slicing is cumbersome, adds extra step to preprocess images and page loading times suffers

我测试特林加载图像与新的图像()对象,标签和CSS背景:从质量下降遭受的一切,所以我怀疑万阿英,蒋达清是图像加载器本身

I tested tring to load image with new Image() object, tag and CSS background: everything suffers from the reduced quality, so I suspect the probelm is the image loader itself

我也试过一切与CSS图像渲染<一href="https://developer.mozilla.org/En/CSS/Image-rendering">https://developer.mozilla.org/En/CSS/Image-rendering - 没有运气

I also tried everything with CSS image-rendering https://developer.mozilla.org/En/CSS/Image-rendering - no luck

视口标签似乎已经到图像加载任何影响 - 该数据已经是垃圾,当你试图去触摸装载的像素数据。我试图在Android的SDK文档<建议的所有可能的值href="http://developer.android.com/reference/android/webkit/WebView.html">http://developer.android.com/reference/android/webkit/WebView.html

Viewport tag seems to have no effect to the image loading - the data is already garbage when you try to touch the loaded pixel data. I tried all possible values suggested in Android's SDK documentation http://developer.android.com/reference/android/webkit/WebView.html

测试也火狐移动,桌面浏览器,iOS的:一切都很好有

Tested also Firefox mobile, desktop browsers, iOS: everything is good there.

那么,到底是怎么回事 - 安卓的WebView根本无法负荷大的图像?

So, what is going on - Android WebView simply can't load big images?

(在这里挂的Andr​​oid机器人的笑脸)

(smiley of hung Android robot here)

推荐答案

Android的无条件重新采样图像和降低质量,如果内存的使用有一定的阈值被超过。

Android unconditionally resamples images and reduces quality if a certain threshold of memory usage is exceeded.

<一个href="http://android.git.kernel.org/?p=platform/external/webkit.git;a=blob;f=WebCore/platform/graphics/android/ImageSourceAndroid.cpp">http://android.git.kernel.org/?p=platform/external/webkit.git;a=blob;f=WebCore/platform/graphics/android/ImageSourceAndroid.cpp

有没有办法访问一部开拓创新的图像数据完整无缺。

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

我贴的问题regardging这对Android的开发商谷歌集团,并亲切地询问是否可能提供某种标志来选择退出此行为。

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

同时,如果你正在考虑开发HTML5的Web应用程序,你可以使用大的图像,您只需preprocess他们在服务器端进行切片,发送较小的图像的设备,然后reconstuct的一部开拓创新的形象使用或者将多个标签的容器元素中。

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 orignal image using or putting many tags inside a container element.

另一种选择手动进行负载形象写一个PNG去codeR直接加载图像,绕过ImageSourceAndroid类。

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

这篇关于Android的:在图像的像素质量下降的WebView加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆