简体   繁体   English

Android中裁剪后的图片大小不变

[英]Cropped Image size in Android is constant

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. 由于我使用的是outputX = 200,因此无论放大或缩小多少,每个裁剪图像的宽度和高度都分别为200和200。

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. 这样我就得到了真实的裁剪图像的宽度和高度(在每种情况下不是200)。

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. 确保将参数scale设置为false。 It defaults to true. 默认为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. PS由于Android是开源的,而camera + crop应用程序是OS的一部分,所以我要做的就是阅读源代码。 The file you should be looking at is here . 您应该查看的文件在这里 Check out variable mScale to see how the parameter is being used. 检出变量mScale,以了解如何使用该参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM