开发者

Can u ? How to anti alias for SurfaceView in 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);
}

u can download the source from he开发者_开发知识库re: http://sharpidea.co.cc/GifViewTest.rar

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜