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.