Detailed explanation of how to avoid oom in Android image processing

1. Compress by setting the sampling rate

Res resource picture compression coderesource

Uri picture compression codestream

Local file URL image compression

Calculate the samplesize according to the size of the displayed picture

Call method:

2. Quality compression: the specified picture is reduced to less than XKB

3. Simply obtain the width and height of the picture to avoid oom

The itmapfactory.options class has a field called injustdecodebounds. The description of this member in the SDK is as follows: if set to true, the decoder will return null (no bitmap), but the out

In other words, if we set it to true, bitmapfactory.decodefile (string path, options OPT) will not really return a bitmap to you. It will only get its width and height back to you, so that it will not occupy too much memory and oom will not occur so frequently.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>