Android压缩图片,程序崩溃
高洛峰
高洛峰 2017-04-17 16:56:44
0
3
392
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
左手右手慢动作

image.compress() This method will not reduce the size of the Bitmap at all, and it cannot achieve image compression. So your baos and isBm both occupy less memory space. It’s better to use inSampleSize directly for compression

PHPzhong

According to the way you write it, the insamplesize of a 2000*1400 photo will be set to 1, and the memory required for decoding will soar very high.
If there are no special requirements for clarity, there is no need to set the image width and height to For mainstream screen sizes, targetsize can be set to half of the high value to display clearly
In addition, available memory can be dynamically monitored in real time to dynamically adjust insamplesize

小葫芦

Since both of your methods receive a Bitmap的参数,那么在调用时,你肯定已经将图片读取到内存中了。造成内存飙升是肯定的。
如果要进行图片压缩,那么最好接受图片的存储位置,在读取的时候进行压缩,这里可以通过Optionsthis class to set and then save.
Regarding image compression, try not to load the original image into the memory. If an instance of the original image has been created, the memory will easily explode.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template