【问题标题】:Android Canvas DrawBitmap poor qualityAndroid Canvas DrawBitmap 质量差
【发布时间】:2016-05-05 00:07:54
【问题描述】:

我正在扩展 SurfaceView 以创建全屏水平滚动背景。

我的问题是位图的质量。在绘制调用中用作

canvas.drawBitmap(bitmap, 0, 0, paint);

它的质量比原来的差很多。我没有做任何缩放。

BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image, options);

Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setFilterBitmap(true);

不确定图片是否清楚地显示出来,它们是平板电脑的屏幕截图。好的是一个 ImageView,它的 src 作为可绘制对象。

画布有这种横向条纹效果,在现实中非常重要。这种效果也是垂直的。每当渐变略有变化时。好像画布的位图的颜色要少得多..

我确定有解决方案,但我找不到任何解决方案。

Poor quality example

Real quality example

【问题讨论】:

    标签: android android-canvas surfaceview android-bitmap


    【解决方案1】:

    看起来像颜色量化。 SurfaceView 的默认颜色格式为 16 位 RGB_565。在onCreate() 上将其更改为 32 位:

    mSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
    

    Some examples 使用PixelFormat.TRANSLUCENT。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-24
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多