如何改变android中的图像质量

时间:2015-05-11 16:12:40

标签: android camera size crop

我制作了一个可以从画廊或相机拍摄照片的Android应用程序。

一切都很好,但是当我裁剪图像时,它的尺寸变为160px * 160px。

我很困惑为什么它改变了我的照片的大小....

private void doCrop() {

    final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>();

    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");

    List<ResolveInfo> list = getActivity().getPackageManager().queryIntentActivities(intent, 0);

    int size = list.size();

    if (size == 0) {
        Toast.makeText(getActivity(), "no app for crop", Toast.LENGTH_SHORT).show();

        return;
    } else {
        intent.setData(mImageCaptureUri);
      //  intent.putExtra("crop", "false");
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra("outputX", 800);
        intent.putExtra("outputY", 800);


        intent.putExtra("scale", false);
        intent.putExtra("return-data", true);

        if (size == 1) {
            Intent i = new Intent(intent);
            ResolveInfo res = list.get(0);

            i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));


            startActivityForResult(i, CROP_FROM_CAMERA);


            //  mUploadMessage.onReceiveValue( mImageCaptureUri);
        } else {
            for (ResolveInfo res : list) {
                final CropOption co = new CropOption();

                co.title = getActivity().getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo);
                co.icon = getActivity().getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo);
                co.appIntent = new Intent(intent);

                co.appIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));

                cropOptions.add(co);
            }

            CropOptionAdapter adapter = new CropOptionAdapter(getActivity().getApplicationContext(), cropOptions);

            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle("app for crop?");
            builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    startActivityForResult(cropOptions.get(item).appIntent, CROP_FROM_CAMERA);
                }
            });




            AlertDialog alert = builder.create();

            alert.show();
        }
    }
}

0 个答案:

没有答案