BitmapFactory Decode大小的时候需要获取所有的流文件吗?
thread {
val str = "http://192.168.31.163/http/img/15H743-001.JPG"
val url = URL(str)
val option = BitmapFactory.Options()
option.inJustDecodeBounds = true
val rect = Rect()
val stream = url.openStream()
BitmapFactory.decodeStream(stream, rect, option)
stream.close()
println("option.outWidth${option.outWidth}rect=$rect")
}
通过以上代码可以解析一张网络图的大小,因为只要读大小,所以我想不会取整张图的流吧!
于是通过抓包工具去check,结果真的不用请求整张图,应该是图片文件里的头文件里有宽高吧
11-11 21:39:50.054 3446-3651/com.seekting.kotlin2017 I/System.out: option.outWidth5760rect=Rect(0, 0 - 0, 0)
以上是log
再看抓包工具