francistao / LearningNotes

Enjoy Learning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitmap的分析与使用中有错误

panda222 opened this issue · comments

//这里我们为什么要寻找 与ratio最接近的2的倍数呢?
//原因就在于API中对于inSimpleSize的注释:最终的inSimpleSize应该为2的倍数,我们应该向上取与压缩比最接近的2的倍数。
以上为错误
根据google官方文档
int inSampleSize
If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1. Note: the decoder uses a final value based on powers of 2, any other value will be rounded down to the nearest power of 2.
最后一句的意思为inSimpleSize应该为2的幂(比如说2,4,8.....),当不是2的幂的时候将会取小于它最近的2的幂(比如说3取2,6取4)。而非文中所说的2的倍数