Cropped Image size in Android is constant

牧云@^-^@ 提交于 2019-12-22 00:58:12

问题


I am cropping an image in circular fashion and using below code while creating the intent

    intent.setData(mImageCaptureUri);
    intent.putExtra("outputX", 200);
    intent.putExtra("outputY", 200);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);

Since I am using outputX = 200, I am getting width and height of every cropped image as 200 and 200 , no matter how much I zoom-in or zoom out.

Below shown both images have different zoom ratio but still return same height and width.

 width  = bitmap.getWidth(); 

Can someone please tell me what parameter should I use in line

intent.putExtra("outputX", 200);

so that I get the TRUE width and height(not the 200 in each case) of cropped image.


回答1:


Didn't know this was the issue when I answered the your earlier question. I believe the answer you are looking for should be:

intent.setData(mImageCaptureUri);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", false);

Make sure you set the parameter scale to false. It defaults to true.

PS Since Android is open source and the camera + crop app is a part of the OS, all I am doing is reading the source. The file you should be looking at is here. Check out variable mScale to see how the parameter is being used.



来源:https://stackoverflow.com/questions/19699496/cropped-image-size-in-android-is-constant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!