1

这是 Surface 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);
}

在表面视图中:(丑陋-_-!!)

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 中消除别名?

4

1 回答 1

0

你需要用来p.setFilterBitmap(true)做你想做的事。

于 2011-01-30T22:54:23.307 回答