使用Janmuller库旋转图像偏心图像

罗伊斯·拉朱·比昂(Royce Raju Beena)

我正在使用janmuller android库执行图像的旋转。向左或向右旋转90度时,图像旋转,但是图像在屏幕上居中。这是我从janmuller库中使用的代码

    public void onRotateRight(View v) {
    mBitmap = Util.rotateImage(mBitmap, 90);
    RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
    mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
    mRunFaceDetection.run();
    }

这是rotateImage函数

    public static Bitmap rotateImage(Bitmap src, float degree) {
    // create new matrix
    Matrix matrix = new Matrix();
    // setup rotation degree
    matrix.postRotate(degree);
    Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    return bmp;
}
绿色应用
public void onRotateRight(View v) {
mBitmap = Util.rotateImage(mBitmap, 90);
RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
mRunFaceDetection.run();
}

我想知道为什么您有这么多代码。尤其是我不知道在位图上使用了rotateImage()之后,是否再将其放回imageview中。旋转有很多代码(为什么需要?)和重置基数(这是什么?),所以很难说出出错时应该归咎于谁。在责怪詹姆勒之前,最好先尝试使用普通的ImageView。更像这样:

public void onRotateRight(View v) {
mBitmap = Util.rotateImage(mBitmap, 90);

mImageView.setImageBitMap(mBitmap);
} 

那应该足以测试;

函数rotateImage()看起来不错。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章