【问题标题】:How to save captured image to a imageview in andother directory? [closed]如何将捕获的图像保存到另一个目录中的图像视图? [关闭]
【发布时间】:2016-03-18 09:48:07
【问题描述】:

我的应用是基于android studio的, 我非常感谢您的帮助和考虑:) 谢谢你:)

【问题讨论】:

    标签: android android-studio directory save android-camera


    【解决方案1】:

    用于将捕获的图像[从相机]设置为图像视图:

     Intent getImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(getImageIntent, 1);
    
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (requestCode == 1) {
                if (resultCode == Activity.RESULT_OK) {
                    imageCounter++;
                    takePicture(data);
                } else if (resultCode == Activity.RESULT_CANCELED) {
    
                }
            }
        }
    
        protected void takePicture(Intent data) {
            Bundle b = data.getExtras();
            Bitmap pic = (Bitmap) b.get("data");
            if (pic != null) {
                ImageView img = new ImageView(this);
                ((LinearLayout) findViewById(R.id.captured_image_layout))
                .addView(img);
                img.setLayoutParams(new LinearLayout.LayoutParams(0,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 0.33f));
                img.setPadding(5, 5, 5, 5);
                img.setImageBitmap(pic);
            }
        }
    

    【讨论】:

    • 谢谢shubham :) 我真的很感激!它有效 :D 非常感谢 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    相关资源
    最近更新 更多