你可以吗?如何在android中为SurfaceView消除锯齿?
这是Surface View和View中抗锯齿的测试项目,
在View中:(抗锯齿非常好)
@Override
protected void onDraw(Canvas canvas) {
Paint p = new Paint();
p.setColor(Color.WHITE);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG));
canvas.drawColor(Color.BLACK);
Matrix mMatrix = new Matrix();
mMatrix.postScale(0.34f, 0.34f);
canvas.drawBitmap(mBitmap, mMatrix, p);
canvas.drawText("View Anti alias", 100, 300, p);
}
在Surface View中:(丑陋-_-!!)
public void doDraw(Canvas canvas) {
Paint p = new Paint();
p.setColor(Color.WHITE);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
canvas.drawColor(Color.BLACK);
Matrix mMatrix = new Matrix();
mMatrix.postScale(0.34f, 0.34f);
canvas.drawBitmap(mBitmap, mMatrix, p);
canvas.drawText("Surface View Anti alias", 100, 300, p);
}
你可以从这里下载源代码: http://sharpidea.co.cc/GifViewTest.rar
任何人都可以告诉我如何反SurfaceView 中的别名?
This is a test project for antialias in Surface View and View,
in the View : ( it's very good for antialias )
@Override
protected void onDraw(Canvas canvas) {
Paint p = new Paint();
p.setColor(Color.WHITE);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG));
canvas.drawColor(Color.BLACK);
Matrix mMatrix = new Matrix();
mMatrix.postScale(0.34f, 0.34f);
canvas.drawBitmap(mBitmap, mMatrix, p);
canvas.drawText("View Anti alias", 100, 300, p);
}
in the Surface View : ( ugly -_-!!)
public void doDraw(Canvas canvas) {
Paint p = new Paint();
p.setColor(Color.WHITE);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
canvas.drawColor(Color.BLACK);
Matrix mMatrix = new Matrix();
mMatrix.postScale(0.34f, 0.34f);
canvas.drawBitmap(mBitmap, mMatrix, p);
canvas.drawText("Surface View Anti alias", 100, 300, p);
}
u can download the source from here:
http://sharpidea.co.cc/GifViewTest.rar
any one can tell me how to anti alias in surfaceView ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
p.setFilterBitmap(true)
来执行您想要的操作。You need to use
p.setFilterBitmap(true)
to do what you want.