[??????]????????????????????????????????????,????????????ImageView???

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[??????]????????????????????????????????????,????????????ImageView???相关的知识,希望对你有一定的参考价值。

?????????

 

????????????????????????????????????,????????????ImageView???

???????????? ?????????????????????

startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), 0);

????????????????????????,?????????????????? ??????????????????????????????

                    Intent intent = new Intent(
                    Intent.ACTION_GET_CONTENT);

                    intent.putExtra("return-data", true);
                    intent.setType("image/*");
                    // TODO ??????
                    intent.putExtra("crop", "circleCrop");
                    // TODO ????????????
                    intent.putExtra("aspectX", 1);
                    intent.putExtra("aspectY", 1);
                    // TODO ????????????
                    intent.putExtra("outputX", 240);
                    intent.putExtra("outputY", 240);
                    startActivityForResult(intent, 1);

????????????startActivityForResult?????????????????????????????? ?????????onActivityForResult???

        if (requestCode == 0 || requestCode == 1) {
        if (data != null) {
            LogUtils.printLog("RedWolf", "??????????????????????????? data+" + data.toString());
            //????????????????????????????????????
            LogUtils.printLog("RedWolf", "??????????????????????????? data+" + data.getExtras());

            Bitmap mBitmap = (Bitmap) data.getExtras().get("data");


            File localimg = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), "srcs");
            if (!localimg.exists()) {
                localimg.mkdirs();
            }
            File iconfile = new File(localimg.getAbsolutePath() + "/usericon.jpg");
            if (iconfile.exists()) {
                iconfile.delete();
            }
            OutputStream out = null;
            try {
                out = new FileOutputStream(iconfile);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            //2???????????????
            mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
            //3?????????ImageView???
            mImageView.setImageBitmap(mBitmap);

????????????????????????????????????,????????????ImageView???

以上是关于[??????]????????????????????????????????????,????????????ImageView???的主要内容,如果未能解决你的问题,请参考以下文章

Python 操作Redis

python爬虫入门----- 阿里巴巴供应商爬虫

Python词典设置默认值小技巧

《python学习手册(第4版)》pdf

Django settings.py 的media路径设置

Python中的赋值,浅拷贝和深拷贝的区别