相机相册

相机

 String path = Environment.getExternalStorageDirectory()+"/zxc.png";
 Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(path)));
                        startActivityForResult(intent,1000);

相册

Intent intent=new Intent(Intent.ACTION_PICK);
                        intent.setType("image/*");
                        startActivityForResult(intent,2000);
if (requestCode==2000 & resultCode==RESULT_OK){
            Uri uri = data.getData();
            Intent intent=new Intent("com.android.camera.action.CROP");
            intent.setDataAndType(uri,"image/*");
            intent.putExtra("crop",true);
            intent.putExtra("aspactX",1);
            intent.putExtra("aspactY",1);
            intent.putExtra("outputX",250);
            intent.putExtra("outputY",250);
            intent.putExtra("return-data",true);
            startActivityForResult(intent,3000);
        }else if (requestCode==1000 & resultCode==RESULT_OK){

            Intent intent=new Intent("com.android.camera.action.CROP");
            intent.setDataAndType(Uri.fromFile(new File(path)),"image/*");
            intent.putExtra("crop",true);
            intent.putExtra("aspactX",1);
            intent.putExtra("aspactY",1);
            intent.putExtra("outputX",250);
            intent.putExtra("outputY",250);
            intent.putExtra("return-data",true);
            startActivityForResult(intent,3000);
        }

        if (requestCode==3000 & resultCode==RESULT_OK){

            Bitmap bitmap = data.getParcelableExtra("data");
            String path=saveImage("crop", bitmap);

            initData2(path);

            mydatafragment_simple_myimage.setImageBitmap(bitmap);

        }
发布了18 篇原创文章 · 获赞 2 · 访问量 1901
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览