你可以吗 ?如何反别名SurfaceView在Android的? [英] Can u ? How to anti alias for SurfaceView in android?

查看:196
本文介绍了你可以吗 ?如何反别名SurfaceView在Android的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个测试项目,表面观和视图,

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

ü可以从这里下载源: http://sharpidea.co.cc/GifViewTest.rar

u can download the source from here: http://sharpidea.co.cc/GifViewTest.rar

任何人能告诉我怎么抗混在surfaceView?

any one can tell me how to anti alias in surfaceView ?

推荐答案

您需要使用 p.setFilterBitmap(真)做你想做的。

You need to use p.setFilterBitmap(true) to do what you want.

这篇关于你可以吗 ?如何反别名SurfaceView在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆