1、自定义一个mView extended ImageView,重写他的ondraw函数   把一个原始drawable资源decode成bitmap,缩小为0.667   然后直接用canvas.drawbitmap绘制出来,效果非常差,画笔设置了paint.setAntiAlias(true);   但是如果把他绘制在一个ARGB_8888的bitmap上,再绘制这个bitmap,效果很好   求解释
2、还是上面这个mView   把一个112px(宽度为准)左右的图片,放大到130px左右,再旋转15度   直接用canvas.drawbitmap绘制出来,效果奇差   画笔设置了paint.setAntiAlias(true);   求解决办法

解决方案 »

  1.   

    drawbitmap时设置下Paint的setDither试试
     Paint p = new Paint();
     p.setDither(true);
    把mView类贴上来看一下
      

  2.   


    设置了setDither也没用,至少说效果没有显著提高下面这个是代码:
    public class RotateView extends ImageView { Paint mPaint;
    Bitmap userBmp;
    Matrix matrix;
    public RotateView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    mPaint=new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mPaint.setDither(true);
    }
    @Override
    public void setImageBitmap(Bitmap bmp) {
    // TODO Auto-generated method stub
    userBmp=bmp;
    invalidate();
    }
    @Override
    protected void onDraw(Canvas canvas) {
    if(userBmp!=null)
    {
    matrix=new Matrix();
    float xScale=75f/userBmp.getWidth();
    float yScale=75f/userBmp.getHeight();

    if(userBmp.getHeight()<userBmp.getWidth())
    {
    matrix.postScale(xScale, yScale);
    }
    else
    {
    matrix.postScale(xScale, xScale);
    }
    matrix.postScale(1.75f, 1.75f);
    matrix.postRotate(15);
    matrix.postTranslate(50, 4);
    canvas.drawBitmap(userBmp, matrix, mPaint);
    matrix=null;
    }
    }
    }
      

  3.   

    试了下没看出什么问题 你用setImageBitmap传进来的Bitmap对象有没问题 怎么生成的Bitmap?
      

  4.   

    你先不要加那么多效果,
                matrix.postScale(1.75f, 1.75f);
                matrix.postRotate(15);
                matrix.postTranslate(50, 4);
    把效果都单独试试看会不会太差,或者不加效果看看,太差的话就不是代码的问题了
      

  5.   

    还有一种方法,你将你的canvas也设置一下消除锯齿,代码:
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG));
      

  6.   

    MARK  ,好像字太少了,