1

I have a project that will draw a line on a bitmap based on pixel coordinate and preview it with ImageView. The purpose of the line is to get degree from the line and then the degree will be use to rotate that bitmap. Is there any way to get the degree from the line that has been draw? Please give me suggestion how to do this.

Best Regards

user1290932
  • 207
  • 1
  • 6
  • 19

1 Answers1

0

This might help you, by this you can rotate your bitmap to 90 degrees actually

Matrix matrix = new Matrix();

matrix.postRotate(90);

Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmapOrg,width,height,true);

Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWidth(), scaledBitmap .getHeight(), matrix, true);

then you can set the rotated image as

imageView.setImageBitmap(rotatedBitmap);

You can use similar technique to get degree of bitmap

Hassaan Rabbani
  • 2,469
  • 5
  • 30
  • 55
  • thanks for your reply, in your code, we can rotate the bitmap with the given degree, but why I need the degree from a line like I said in my post before, because the give degree in matrix.postRotate(90) is dynamic. not static like your code that you have given 90 as the degree.Do you have an idea how to do this? – user1290932 Feb 24 '14 at 09:53
  • Actually i have never tried it. but i came across a link right now, you can check this out, but this the problem is this do not tell you how to get angle from line drawn but it will help you rotate bitmap dynamically http://stackoverflow.com/questions/8712652/rotating-image-on-a-canvas-in-android – Hassaan Rabbani Feb 24 '14 at 10:00