简体   繁体   中英

Bitmap.compress compression ratio based on the parameters

我正在使用Bitmap.compress方法,是否有任何方法可以根据所选参数来预先确定输出文件的大小?

Bitmap.compress() includes the compression algorithm parameters. If you need to change sizes for reducing memory allocation for your image, you exactly need to use scaling of your image using Bitmap.Options, computing bitmap bounds at first and then decoding it to your specified size.

like this :

BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap preview_bitmap=BitmapFactory.decodeStream(is,null,options);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM