Resize image after capture it from native camera but before save it to SD card

孤者浪人 提交于 2019-12-11 09:28:33

问题


I am opening a default Camera in my app on button click.when i click on button ,it works fine.But it capture the image of default size and I want to re-size the image before save it in SD card after capture it from default camera.


回答1:


Use the following piece of code to set proper width and height for camera intent.

            Intent intent = new Intent( Intent.ACTION_PICK,
            MediaStore.Images.Media.INTERNAL_CONTENT_URI );
    intent.putExtra("outputX",
            width_of_output_image);
    intent.putExtra("outputY",
            height_of_output_image);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra( "scale", true );
            startActivityForResult( intent, 1 );



回答2:


use this link, that can help you

Android take photo and resize it before saving on sd card




回答3:


I think this must help you:-

Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter);



回答4:


    BitmapFactory.Options optionsSignature = new BitmapFactory.Options();

    final Bitmap bitmapSignature = BitmapFactory.decodeFile(
            fileUriSignature.getPath(), optionsSignature);

    Bitmap resizedSignature = Bitmap.createScaledBitmap(
            bitmapSignature, 256, 128, true);

    signature.setImageBitmap(resizedSignature);


来源:https://stackoverflow.com/questions/12780375/resize-image-after-capture-it-from-native-camera-but-before-save-it-to-sd-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!