开发者

Android - make captured image smaller

I capture image by default camera software and I get saved my image into some directory to local memory. My question is, is there any way how to make this picture smaller? I will need to send it via internet connection to server, that's why it has to be VGA on maximum. I know there is way to write my own photo part of an app, but I thinks it is nice to use default and then some method for making the picture smaller. I just haven't figured开发者_运维百科 out, how. Any ideas?

Thanks


For example:

        InputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory(), "image.tmp"););
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 4; //subsampling

        int compress = 75;
        BitmapFactory.decodeStream(is, null, options).compress(CompressFormat.JPEG, compress, new FileOutputStream(file));

It's dirty example. Use try catch, null check etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜