Android image compression example code
Sort out the documents, search out an example code of Android image compression, sort out and simplify it a little, and share it@ H_ 403_ 2@
Detailed explanation: @ h_ 403_ 2@
1. Get the local picture file, get the bitmapfactory.options object, calculate the width height ratio of the original picture to the target picture, and calculate the output picture width height @ H_ 403_ 2@
2. Calculate the options.insamplesize value according to the aspect ratio (scaling scale if set to a value > 1, requests the decoder to subsample the original image, returning a small image to save memory) to obtain the bitmap. Obtain a new output bitmap object bitmap. Createscaledbitmap (bitmap SRC, int dstwidth, int dstheight, Boolean filter) create a new bitmap according to the bitmap object, scaled from an existing bitmap,whenpossible. @H_ 403_ 2@
3. Obtain the picture direction adjustment, loss compression picture and keep it below 1024KB @ H_ 403_ 2@
Compression scale conversion: @ h_ 403_ 2@
Set scaling -- generate new bitmap @ h_ 403_ 2@
reference resources: https://github.com/guizhigang/LGImageCompressor @H_ 403_ 2@
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@ H_ 403_ 2@