android-imagecropview
android-imagecropview copied to clipboard
x and y offset is not giving correct values.
Hi,
I am trying to get the x and y offset when i cropped the image, the value what i am getting from CropInfo Class is different than the actual result.
First i am getting the CropInfo object and getting all the values, and then i am using your same formula to calculate x and y i-e this float x = Math.abs(viewImageLeft - cropLeft) / scale; float y = Math.abs(viewImageTop - cropTop) / scale;
I think this x and y values is giving me the result for scaled bitmap, how can i get the original x and y offset after cropping??
Please help me.
hello @O-liverQueen
Too large bitmap can't load on memory. so I resize original image just before crop
https://github.com/naver/android-imagecropview/blob/master/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/model/CropInfo.java#L33-L35
If your image under 4000 * 4000, module doesn't resize.(same original bitmap)
please check bitmap width https://github.com/naver/android-imagecropview/blob/master/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/model/CropInfo.java#L47
thank you :)
Hello @helloyako
I got the requirement to crop the image and send the image with x and y offset,
I was able to select and crop image, but the x & y offset position was not correct, the values which i was getting was of the cropped image, which is returned in getCroppedImage() method of CropView Class.
After doing all the calculation, i came up with this this formula, which gives you the exact x and y offset of the original image, not for the cropped image.
FOR X-AXIS: float xAxis = (originalImageWidth / info.getViewBitmapWidth()); xAxis= Math.abs(xAxis* (info.getViewImageLeft() - info.getCropLeft())) / info.getScale();
FOR Y-AXIS: float yAxis = (imageHeights / info.getViewBitmapHeight()); yAxis= Math.abs(yAxis* (info.getViewImageTop() - info.getCropTop())) / info.getScale();
where info is your CropInfo Object.
@O-liverQueen any solution? i have also same issue