1

I am using janmuller android library to perform rotation of an image . On rotating it 90 degrees to the left or right the image is rotated , however it gets de centred on the screen . This is the code I have used from janmuller library

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

This is the rotateImage function

    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;
}
Royce Raju Beena
  • 711
  • 4
  • 20

1 Answers1

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

I wonder why you have so much code. Especially i wonder that after having used rotateImage() on the bitmap you dont put it back in the imageview. There is so much code with rotate (why is that needed?) and reset base (what does that?) that it is difficult to say who is to blame when things go wrong. Better try with a normal ImageView first before you blame janmuller. More like this:

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

mImageView.setImageBitMap(mBitmap);
} 

That should be enough to test;

The function rotateImage() looks ok.

greenapps
  • 11,154
  • 2
  • 16
  • 19