Android:通过相机活动裁剪图像的问题

发布于 2024-11-28 02:50:47 字数 710 浏览 5 评论 0原文

我制作了一个应用程序,其中我从相机捕获了图像,并显示一个矩形来裁剪选定的区域。但我面临两个大问题:

  1. 当我们改变矩形的尺寸时,它看起来很大 用于裁剪图像,而不是显示裁剪后的图像文件 它会重新启动相机活动?而我也做了同样的事情 从图库中获取图像并且它正在工作。

  2. 长宽比不适用于从相机活动拍摄的图像?

相机活动代码:

public void onClick(DialogInterface dialog, int item)
{
        Intent intent = new Intent();
        intent.putExtra("crop", "true"); 
        intent.putExtra("aspectX", 774);
        intent.putExtra("aspectY", 1115);
        intent.putExtra("outputX", 774);
        intent.putExtra("outputY", 1115);

        if(item==0)
        {
            intent.setAction("android.media.action.IMAGE_CAPTURE");
        startActivityForResult(intent, PICK_FROM_CAMERA);
    }

I have made an App in which I have captured an image from camera and a rectangle is shown to crop the selected area. But I'm facing two big problems in it:

  1. when we change the dimensions of rectangle appeared to large size
    for cropping the image then instead of showing cropped image file
    it restart camera activity?while the same thing I have done in
    taking image from gallery and it is working.

  2. aspect ratio is not working for image taken from camera activity?

Code for camera activity:

public void onClick(DialogInterface dialog, int item)
{
        Intent intent = new Intent();
        intent.putExtra("crop", "true"); 
        intent.putExtra("aspectX", 774);
        intent.putExtra("aspectY", 1115);
        intent.putExtra("outputX", 774);
        intent.putExtra("outputY", 1115);

        if(item==0)
        {
            intent.setAction("android.media.action.IMAGE_CAPTURE");
        startActivityForResult(intent, PICK_FROM_CAMERA);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文