android - 位图外观不好看,抖动不起作用,在 Android 中

标签 android bitmap dithering

我想在我的应用中使用 coverflow View 。为了获得反射图像部分,我使用了以下代码 - http://www.androidsnippets.com/create-image-with-reflection

我看过很多关于抖动和 tileMode 的论坛/讨论,我已经尝试了所有讨论的内容,但对我没有任何作用。

仅供引用 - 我正在动态创建位图,不在布局中使用任何位图。我附上了图片以显示它有多糟糕:

Reflection image appearance is not looking good

我在下面列出了我尝试解决此问题的方法。

   1. getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, WindowManager.LayoutParams.FLAG_DITHER);

   2. getWindow().setFormat(PixelFormat.RGBA_8888);


   3. BitmapDrawable baseImageDawable = new BitmapDrawable(getResources().openRawResource(imageId));
      baseImageDawable.setDither(true);
      baseImageDawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

      Bitmap originalImage = baseImageDawable.getBitmap();
      int width = originalImage.getWidth();
      int height = originalImage.getHeight();

      Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, 0, width, height, matrix, true);   

但是反射图像还是很丑。

我该如何解决这个问题?

最佳答案

嗯。我“认为”你的问题是你的位图没有被创建为 ARGB_8888 (尽管你的 setFormat 调用)。我会“建议”,而不是使用 openRawResource 创建可绘制的位图,而是使用 BitmapFactory 并确保指定 Bitmap.Config.ARGB_8888。然后从位图中制作你的可绘制对象。只是一个想法——如果不能与 eclipse 同步,很难猜测这个距离。您可能会发现这篇文章很有趣:http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/

编辑:因此,问题显然出在对用于分配反射图像的 createBitmap 的调用中。故事的寓意(恕我直言):永远不要使用不允许您显式指定 Bitmap.Config 的 createBitmap 方法。否则,正如阿甘正传所说,您永远不知道会得到什么。

关于android - 位图外观不好看,抖动不起作用,在 Android 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5991176/

相关文章:

c# - C# 中的图像调整大小 - 确定调整大小尺寸(高度和宽度)的算法

c# - 我的抖动算法 super 慢

swift - Metal 计算-像素依赖于其他像素颜色

屏幕底部的 Android 覆盖

Android FFmpeg : Undefined references to atof, log2 & log2f

android - java.lang.OutOfMemoryError : bitmap size exceeds VM budget on line Drawable. createFromStream(((java.io.InputStream) new URL(url), "") 在android中

c# - 通过以太网发送位图,然后再返回(c# 和 c)

Android View 抖动

javascript - 将 HTML5 PhoneGap App 连接到在线数据库

android - 使用 PagerSnapHelper 在 RecyclerView 中添加空间