【问题标题】:How to efficiently resize image with antialias?如何使用抗锯齿有效地调整图像大小?
【发布时间】:2017-09-15 12:46:38
【问题描述】:

我尝试像这样调整图像的大小:

aPaint.setAntiAlias(true); // Enabling this flag will cause all draw operations that support antialiasing to use it.
aPaint.setFilterBitmap(True); // enable bilinear sampling on scaled bitmaps. If cleared, scaled bitmaps will be drawn with nearest neighbor sampling, likely resulting in artifacts.
apaint.setDither(true); // Enabling this flag applies a dither to any blit operation where the target's colour space is more constrained than the source.
aCanvas.drawBitmap(aBitmap, aJSrcRect, aJDestRectf, apaint);

但是我没有很好的抗锯齿图像(它是抗锯齿的,但不是很好)。这是一张显示我的问题的图片

如何提高android下的抗锯齿质量?

【问题讨论】:

  • 你找到解决办法了吗?

标签: android android-canvas android-graphics android-paint


【解决方案1】:

为了抗锯齿效果,你可以尝试像这样创建一个Paint:

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

最后在画布上使用:

canvas.drawBitmap(mBitmap, 0.f, 0.f, paint)

【讨论】:

  • paint.setAntiAlias(true);只是paint.setFlags(Paint.ANTI_ALIAS_FLAG)的助手; :(正如你在我给出的示例代码中看到的那样,我已经做了:(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-01
  • 1970-01-01
  • 2011-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多