jayrambhia / CropperNoCropper

Instagram Style Image Cropper for Android (Library)
http://www.jayrambhia.com/project/nocropper-library
Apache License 2.0
475 stars 99 forks source link

Imageview or Bitmap Rotate From Center Using replaceBitmap(mBitmap) #14

Closed hardz closed 8 years ago

hardz commented 8 years ago

@jayrambhia Hello,

Yes, it's work fine when you wants to rotate bitmap with setBitmap(rotateBitmap(mOrigBitmap)), but when you scale image then do rotate, it's reassign bitmap to CropperView, so i like to use replaceBitmap(rotatedBitmap) for avoiding reassign bitmap, then i figured out it wan't rotate from center point as it has to.

How to get rid of this strange rotate behavior ?

Flow for this.

  1. cropper.setImageBitmap(mOrigBitmap);
  2. scaling CropperView Image
  3. Bitmap rotatedBitmap= rotateBitmap(mOrigBitmap); -> Applying rotate using rotateBitmap?
  4. cropper.replaceBitmap(rotatedBitmap); -> it's assign bitmap like it's rotate from top-left corner !

Desire result is rotatedBitmap should be replace with reference to center points of scaled bitmap with latest matrix.

jayrambhia commented 8 years ago
  1. replaceBitmap is not possible for rotating non-square bitmaps.
  2. Rotate is not a feature that this cropper provides
  3. Cropper doesn't have any idea about skew or rotation of the image matrix. And cropper sometimes resets the matrix so manually setting it also won't be helpful.
  4. replaceBitmap is especially used if you just want to replace the bitmap after some processing. eg. brightness-contrast, etc. And is not intended to be used for rotation.

So when you use repalceBitmap, cropper assumes that nothing has changed about the bitmap (size, rotation, etc).

With that said, if you have any suggestions how to go about it (Make cropper aware of rotation of bitmap?), please let me know. PRs are much appreciated.