2012-08-30 179 views
1

我刚刚在我的应用中根据此示例http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/实施了图像裁剪活动。com.android.camera.action.CROP调整裁剪矩形的大小

我想要实现的是将图像裁剪成具有较小尺寸的原始图像的尺寸的正方形,例如,图像400 x 600会导致裁剪后的图像400 x 400.不幸的是,确定裁剪图像尺寸的矩形不会填充图像,并且无论输入设置为Intent("com.android.camera.action.CROP"),都将保持不变。

 Intent intent = new Intent("com.android.camera.action.CROP"); 
     intent.setType("image/*"); 
     intent.setData(mImageCaptureUri); 
     intent.putExtra("outputX", widthHeight); 
     intent.putExtra("outputY", widthHeight); 
     intent.putExtra("crop", "true"); 
     intent.putExtra("aspectX", 1); 
     intent.putExtra("aspectY", 1); 
     intent.putExtra("noFaceDetection", true); 
     intent.putExtra("return-data", true);  

Example of the cropping rectangle that is NOT scaled to the maximum height

我这是由于Android模拟器我使用或我怎样才能改变这种状况?

第二个问题:任何人都可以告诉我是否可以以某种方式设计此Intent?

非常感谢!

+0

没有人有一个提示为了我? – didhavn

回答

6

方面值定义了尺度scale(x/y)。如果你想要免费尺寸,你应该删除

intent.putExtra("aspectX", 1); 
intent.putExtra("aspectY", 1); 

值。或者如果你想要新的方面大小,你可以为它们分配新的整数。

0

你必须删除4行仅

(1)

intent.putExtra("outputX", widthHeight); 

intent.putExtra("outputY", widthHeight); 

(2)

intent.putExtra("aspectX", 1); 
intent.putExtra("aspectY", 1); 

它将裁剪矩形