-2

我正在尝试旋转图像。旋转效果很好,但是当我把旋转后的图像拿回来时,会得到一些空白。我应该怎么做才能删除那个空白?

我试过这段代码:

public static Bitmap RotateBitmap(Bitmap source, float angle) {
        Matrix matrix = new Matrix();
        matrix.setRotate(90, 0, 0);
        matrix.postTranslate(source.getHeight(), 0);
        // matrix.postRotate(angle);
        return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    }

Utility.tempBitmap = RotateBitmap(Utility.tempBitmap, -90);
4

1 回答 1

2

我通过根据我的要求更改视图集位图的一些更改来解决我的问题。使用此代码:

我之前使用的代码(给我空白)

 public static Bitmap RotateBitmap(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.setRotate(90, 0, 0);
    matrix.postTranslate(source.getHeight(), 0);
    // matrix.postRotate(angle);
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}

Utility.tempBitmap = RotateBitmap(Utility.tempBitmap, -90);

解决方案代码在这里:

public int setBitmap(final Bitmap bitmap) 
{
changeBitmapContrastBrightness(1, 50);
gapRect = new RectF();
dest = new Rect();
setBackgroundColor(Color.GRAY);
if (bitmap.getWidth() > bitmap.getHeight()) {
this.mbitmap = bitmap;
invalidate();
return 0;
}
this.mbitmap = bitmap;
 invalidate();
 return 1;
于 2016-08-23T11:37:23.653 回答