Closed alphaDroid89 closed 8 years ago
I have done this with Camera (in one of my apps) and it has worked for me. Could you let me know the size of the bitmap that is loaded? I am currently resizing the camera image to around 1280x760 and loading in the cropper view and it seems to work.
Image size is 1280x851; but the same image is worked fine when its selected from Cropper App, images from other activity can't able to do zoom and crop. Sorry to ask may i know, did you clear on this issue.
I am trying to figure out what the issue could be. What do you mean by "images from other apps"? So to make it clear, the issue is, you are unable to zoom/crop image when you are obtaining the image from the camera. But it works fine if you select it from the gallery. Could you post some more code if possible?
Hi, added the my working sample and video in the following link plz refer it. https://www.dropbox.com/sh/ambx6fk1x1zy0cw/AABNvPY2UaQ7XnT8ab268gHoa?dl=0
this will help me address my issue exactly.
I updated my previous comments its not Apps actually its other Activity.
@SkyNite Yeah, it's a bug. Since you're loading image in onCreate(), the cropperview is not measured properly and hence there are some unforeseen issues. I'll resolve this issue in some time. Meanwhile, if you want to solve this, use a handler with delay or use a background thread (optimal solution) to load bitmap.
Sure, I used AsyncTask for loading the image, its working fine. please let me know if good/proper solution other than this.
thanks for your quick response :)
@SkyNite It turns out that this issue was related to the sample. In the sample, it was setting max zoom as 0 and hence the issue. I have updated the sample.
private void loadNewImage(String filePath) {
mBitmap = BitmapFactory.decodeFile(filePath);
Log.i(TAG, "bitmap: " + mBitmap.getWidth() + " " + mBitmap.getHeight());
int maxP = Math.max(mBitmap.getWidth(), mBitmap.getHeight());
float scale1280 = (float)maxP / 1280;
if (mImageView.getWidth() != 0) {
mImageView.setMaxZoom(mImageView.getWidth() * 2 / 1280f);
} else {
ViewTreeObserver vto = mImageView.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mImageView.getViewTreeObserver().removeOnPreDrawListener(this);
mImageView.setMaxZoom(mImageView.getWidth() * 2 / 1280f);
return true;
}
});
}
mBitmap = Bitmap.createScaledBitmap(mBitmap, (int)(mBitmap.getWidth()/scale1280),
(int)(mBitmap.getHeight()/scale1280), true);
mImageView.setImageBitmap(mBitmap);
}
This should fix the problem.
@jayrambhia Great thanks yar :+1:
Hi,
Thanks for sharing this library.
I'm facing a issue in the following scenario,
For your ref, i added the code snipped what i had done,
public class BaseActivity extends Activity {
}