在下一个活动中发送图像字符串,并使用AQuery加载图像

时间:2016-03-18 13:08:01

标签: android image image-processing aquery

  • 最初我使用位图来处理图像事件

  • 我可以将位图传递给活动,也可以加载图像

  • 但是当我测试时,我发现某些设备位图崩溃

  • 我做了什么

- 用于图像选择和传递:

private void selectImage() {
    final CharSequence[] items = {"Choose from Library"};
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Add Photo!");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int item) {
            /*if (items[item].equals("Take Photo")) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, IntentConst.REQUEST_CAMERA);
            } else*/
            if (items[item].equals("Choose from Library")) {
                Intent intent = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                intent.setType("image/*");
                startActivityForResult(
                        Intent.createChooser(intent, "Select File"),
                        IntentConst.SELECT_FILE);
            }
        }
    });
    builder.show();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == this.RESULT_OK) {

        if (requestCode == IntentConst.SELECT_FILE) {
            Uri selectedImageUri = data.getData();
            String[] projection = {MediaStore.MediaColumns.DATA};
            Cursor cursor = this.managedQuery(selectedImageUri,
                    projection, null, null, null);
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
            cursor.moveToFirst();
            selectedImagePath = cursor.getString(column_index);

            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(selectedImagePath, options);
            final int REQUIRED_SIZE = 200;
            int scale = 1;
            while (options.outWidth / scale / 2 >= REQUIRED_SIZE
                    && options.outHeight / scale / 2 >= REQUIRED_SIZE)
                scale *= 2;
            options.inSampleSize = scale;
            options.inJustDecodeBounds = false;
            setimg = BitmapFactory.decodeFile(selectedImagePath, options);

            Log.e("image path",selectedImagePath);

            ivProImage.setImageBitmap(setimg);
        }

        if (requestCode == RESULT_SEND) {
            Intent intent = new Intent(getApplicationContext(), ActivityCardLogo1.class);
            startActivity(intent);
        }
    }
}

- 我想要的是,将图像字符串发送到下一个活动并使用AQuery加载图像

0 个答案:

没有答案