裁剪图像安卓机器人 [英] Crop image android android

查看:138
本文介绍了裁剪图像安卓机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的图像裁剪我发现了一些pretty的有用的,但不知何故就像缺少的变暗未被选中的区域,所以我想知道做任何人都知道怎么样?或者使我朝着正确的方向?在线教程中,我发现显示了就会变暗所选择的区域,但是当我使用它,它不会。请帮帮我非常感谢和抱歉的英语我不好命令。

I want to do cropping of image i found some pretty useful ones but somehow is like lacking of the darken the unselected areas so I wondering do anyone know how? or lead me to the right direction? The online tutorial i found shows that is will darken the selected area but when I use it, it won't. Please help me thanks alot and sorry for my bad command of english.

链接到我使用的教程。

<一个href="http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/">Crop图片教程1

裁剪图片教程2

我希望它是这样的。

editButton.setOnClickListener(new Button.OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent goEdit;
            goEdit = new Intent(PreviewActivity.this, CropImage.class);
            goEdit.putExtra("image-path", path);
            goEdit.putExtra("scale", true);
            goEdit.putExtra("fileName", nameFromPath);
            //finish();
            checkEdit = true;
            startActivityForResult(goEdit,0);

        }
});

修改 我用这个按钮,监听器调用的类CropImage活动来调用到cropImage文件。这是一个自定义的意图不是内的Andr​​oid作物功能,但我认为它的副本,以便让所有的版本都支持,但是当我打电话到其选定的区域心不是照亮我唐诺哪里出了问题,谁能指导我?谢谢 这是我使用的库<一href="https://github.com/chemalarrea/CropImage/tree/master/src/com/droid4you/util/cropimage">drioid4you裁剪图片

EDIT I use this button listener to call into the cropImage file by calling to the class CropImage activity. This is a custom intent not the crop feature inside android but I think is the copy of it so that make it support for all versions but when I call into it the selected area isnt brighten and I donno where is the problem can anyone guide me? Thanks This is the library I'm using drioid4you crop image

推荐答案

您可以使用默认的Andr​​oid裁切功能?

Can you use default android Crop functionality?

下面是我的code

private void performCrop(Uri picUri) {
    try {

        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        // indicate image type and Uri
        cropIntent.setDataAndType(picUri, "image/*");
        // set crop properties
        cropIntent.putExtra("crop", "true");
        // indicate aspect of desired crop
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        // indicate output X and Y
        cropIntent.putExtra("outputX", 128);
        cropIntent.putExtra("outputY", 128);
        // retrieve data on return
        cropIntent.putExtra("return-data", true);
        // start the activity - we handle returning in onActivityResult
        startActivityForResult(cropIntent, PIC_CROP);
    }
    // respond to users whose devices do not support the crop action
    catch (ActivityNotFoundException anfe) {
        // display an error message
        String errorMessage = "Whoops - your device doesn't support the crop action!";
        Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}

申报:

final int PIC_CROP = 1;

在上面。

在onActivity结果的方法,下面令状code:

In onActivity result method, writ following code:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PIC_CROP) {
        if (data != null) {
            // get the returned data
            Bundle extras = data.getExtras();
            // get the cropped bitmap
            Bitmap selectedBitmap = extras.getParcelable("data");

            imgView.setImageBitmap(selectedBitmap);
        }
    }

}

这是pretty的容易让我实现,也显示变暗的区域。

It is pretty easy for me to implement and also shows darken areas.

这篇关于裁剪图像安卓机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆