Can u ? How to anti alias for SurfaceView in android?

会有一股神秘感。 提交于 2019-12-22 00:25:56

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/4846115/can-u-how-to-anti-alias-for-surfaceview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!