位图一半正确绘制

时间:2015-03-02 08:39:19

标签: android bitmap crop ondraw

我在为自定义imageView制作圆角时遇到了问题。这是我的代码片段和显示我的问题的图像

原始图片original picture

错误的图纸wrong drawing

我的代码:

@Override
protected void onDraw(Canvas canvas) {
    if (mCurrentBitmapDrawable != null) {
        if (mTopLeft == 0 && mTopRight == 0 && mBottomLeft == 0 && mBottomRight == 0) {
            Log.d("CustomImageView-def", "mTopLeft = " + String.valueOf(mTopLeft));
            super.onDraw(canvas);
            return;
        }
        Log.d("CustomImageView-cust", "mTopLeft = " + String.valueOf(mTopLeft));
        mBitmapShader = new BitmapShader(mCurrentBitmapDrawable.getBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        paint.setAntiAlias(true);
        paint.setShader(mBitmapShader);

        mRoundRectShape.resize(getWidth(), getHeight());
        mRoundRectShape.draw(canvas, paint);
    }
}

0 个答案:

没有答案