android - 如何使用抗锯齿有效地调整图像大小?

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

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

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);

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

enter image description here

我可以做些什么来提高 android 下的抗锯齿质量?

最佳答案

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

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

最后在 Canvas 上涂抹颜料:

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

关于android - 如何使用抗锯齿有效地调整图像大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46239959/

相关文章:

android - 如何垂直对齐不同高度的 3 个 View

Android canvas - 在点之间绘制圆弧并从路径中删除圆弧

android - 多个矩形不在 Canvas 上绘制

android - 如何制作星形并在android中制作动画?

java - 磁盘上的图像文件大小?

android导航组件向上按钮,箭头显示但popTo不起作用

android - Edittext下划线不会消失

android - 我们可以画一个使用 Path 对象的圆吗? [在参数中,如 drawPath()]

android - 在圆弧上画一个圆形的空心拇指