ColorMatrix错误并出现句柄0x4422f8仍被锁定

| 我想测试ColorMatrix,我的代码是:
    public class testColorMatrix extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new SampleView(this));
    }

    private static class SampleView extends View{

        BitmapFactory.Options options;
        Bitmap grayscale;
        Bitmap alpha;
        Paint grayToAlpha;
        Canvas alphaCanvas;
        float[] matrix;
        public SampleView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            // TODO Auto-generated constructor stub
            init();
        }

        public SampleView(Context context, AttributeSet attrs) {
            super(context, attrs);
            // TODO Auto-generated constructor stub
            init();
        }

        public SampleView(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
            init();
        }
        public void init(){
             options = new BitmapFactory.Options();
            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
            options.inScaled = false;

            // Load source grayscale bitmap
             grayscale = BitmapFactory.decodeResource(getResources(), R.drawable.a2, options);
            // Place for  alpha mask. It\'s specifically ARGB_8888 not ALPHA_8, 
            // ALPHA_8 for some reason didn\'t work out for me. 
             alpha = Bitmap.createBitmap(grayscale.getWidth(), grayscale.getHeight(),
                    Bitmap.Config.ARGB_8888);
             matrix = new float[] {
                    5, 0, 0, 0, 10,
                    0, 5, 0, 0, 10,
                    0, 0, 5, 0, 0,
                    0, 0, 0, 1, 0};
             grayToAlpha = new Paint();

        }

        @Override
        protected void onDraw(Canvas canvas) {

            grayToAlpha.setColorFilter(null);
            canvas.drawBitmap(grayscale, 0, 0, grayToAlpha); 
            grayToAlpha.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(matrix)));
        //    alphaCanvas = new Canvas(alpha);
            // TODO Auto-generated method stub
            //super.onDraw(canvas);
        // Make sure nothing gets scaled during drawing
         alphaCanvas.setDensity(Bitmap.DENSITY_NONE);
         // Draw grayscale bitmap on to alpha canvas, using color filter that
         // takes alpha from red channel
         alphaCanvas.drawBitmap(grayscale, 0, 0, grayToAlpha);
         // Bitmap alpha now has usable alpha channel!

        }
    }
}
但是它无法运行,ddms它给了我:
05-26 02:46:18.582: ERROR/AndroidRuntime(924): ERROR: thread attach failed

05-26 02:46:29.121: ERROR/gralloc(52): [unregister] handle 0x4422f8 still locked (state=40000001)
您能提供一些建议来发现错误吗?     
已邀请:
我也解决了我的问题:修改如下
@Override
    protected void onDraw(Canvas canvas) {

        grayToAlpha.setColorFilter(null);
        canvas.drawBitmap(grayscale, 0, 0, grayToAlpha); 
        canvas.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(matrix)));
    //    alphaCanvas = new Canvas(alpha);
        // TODO Auto-generated method stub
        //super.onDraw(canvas);
    // Make sure nothing gets scaled during drawing
     canvas.setDensity(Bitmap.DENSITY_NONE);
     // Draw grayscale bitmap on to alpha canvas, using color filter that
     // takes alpha from red channel
     canvas.drawBitmap(grayscale, 0, 0, grayToAlpha);
     // Bitmap alpha now has usable alpha channel!

    }
    

要回复问题请先登录注册