在Android 4.1.2倾斜的图像中的ImageView [英] Skewed images in ImageView on Android 4.1.2

查看:206
本文介绍了在Android 4.1.2倾斜的图像中的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序显示在的ImageView 图像,和我遇到的问题专门为Android 4.1.2。它被证实在三个独立的4.1.2的设备无法正常工作,当工作在2.3.7,4.2.1,4.3和4.4.2。发生了几个不同的图像的误差,但不是全部。似乎有一些关于一些具体的JPEG文件,意图不工作。

I have an app that displays an image in an ImageView, and am experiencing problem specifically for Android 4.1.2. It is confirmed to not work on three separate 4.1.2 devices, while working on 2.3.7, 4.2.1, 4.3 and 4.4.2. The error occurs for several different images, but not all. There seems to be something about some specific JPEG-files that doesn't work as intended.

如何它实际上看起来,它是如何显示在Android 4.1.2:

How it actually looks, and how it shows on Android 4.1.2:

图像的样子 href="http://i.imgur.com/WJbuiAE.png" rel="nofollow">

上面的图像(左)就是这样一个有问题的图像文件。

The above image (left) is one such problematic image file.

背后设置所显示的图像的code的摘要:

A summary of the code behind setting the displayed image is:

Bitmap bitmap, background;
ImageView imageView = (ImageView)findViewById(R.id.imageView);

BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
options.inPurgeable = true;
options.inInputShareable = true;
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.dog, options);

background = bitmap.copy(Bitmap.Config.RGB_565, true);

Canvas canvas = new Canvas(background);
canvas.drawBitmap(bitmap, 0, 0, null);
// Some calls to canvas.drawText(....) here, but doesn't have to happen for the error to occur

imageView.setImageBitmap(background);

我已经想通了,我能够调整并重新保存上面的照片在Photoshop中,使其工作,不知道为什么。因为我有几个我preFER不必这样做。

I've figured that I am able to resize and re-save the above photo in Photoshop to make it work, without knowing why. Since I have several I'd prefer not having to do so.

我想知道这是什么错误在Android 4.1.2的源代码,如果有可能修复它的一些编程方式?

我试着在谷歌认为我的运气扭曲,倾斜,扭曲等类似,但也有极少数提到的它并没有修复。这是所提到的与截图,我发现:

I've tried my luck on Google view "skewed", "tilted", "distorted" and similar, but there are very few mentions of it and no fixes. This is the mention with screenshot I've found:

  • <一个href="http://www.reddit.com/r/Android/comments/1fnii4/anyone_else_getting_distorted_album_art_in_play/"相对=nofollow>任何人都得到扭曲的专辑在播放音乐艺术?(截图

推荐答案

根据的 rupps 我从改变注释

bitmap.copy(Bitmap.Config.RGB_565, true)

要:

bitmap.copy(Bitmap.Config.ARGB_8888, true)

这的确实际上解决问题4.1.2设备,同时保持对所有其他测试设备的功能类似。这不编程解决我的问题。但请注意,它需要两倍的存储器,因为每个像素存储在4个字节,而不是2个字节。

This did in fact solve the problem for 4.1.2 devices, while remaining similar in functionality for all other tested devices. This does programatically solve my issue. Note however that it does require double the memory, as each pixel is stored on 4 bytes instead of 2 bytes.

对于问题的根源,我从的文档 RGB_565 是:

As for the source of the problem, I read from the documentation of RGB_565 that:

这配置可以产生取决于源的配置轻微的视觉假象。

This configuration can produce slight visual artifacts depending on the configuration of the source.

我觉得这主要是涉及到条带/彩色/抖动问题,这并不能说明该版本的具体问题,但也许是为什么这个设置​​很麻烦。

I think this mostly relates to banding/color/dithering issues and this does not explain the version specific problem, but perhaps why this setting is troublesome.

这篇关于在Android 4.1.2倾斜的图像中的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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