Android BitmapFactory与BufferedInputStream

杰西·霍尔(Jess Holle)

是否BitmapFactory.decodeStream(InputStream)已经阅读了大量的内容,还是应该确保将其传递BufferedInputStream给原始阅读器而不是原始阅读器InputStream

我要问的是,是否BitmapFactory尚未在较大的块中进行IO,那么在传递输入流之前,应该明确地将缓冲应用于输入流。但是,如果它已经在大块中工作,则应用缓冲实质上只是添加了不必要的一组memcpy()操作。

如果那些编写采用APIInputStreamOutputStream参数的API在Javadoc中清楚地了解这些事情,那将是非常不错的。

目前,我正在应用缓冲,除非InputStream是的一个实例AssetManager.AssetInputStream,因为我注意到在的情况下对此情况进行了特殊处理decodeStream()

扎克

如果您看一下实现,则可能有两种解码Stream调用的方法。

  • nativeDecodeAsset(),当我浏览类时似乎没有显示实现

  • encodeStreamInternal(),根据()16 * 1024的大小判断一次读取字节DECODE_BUFFER_SIZE

    (id发布了代码,但是格式似乎现在被破坏了)

所以我认为使用BitmapFactory.decodeStream()是一个安全的选择

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Android:BitmapFactory解码速度缓慢

如何使用 Android BitmapFactory.Options.inBitmap?

为什么Android BitmapFactory.decodeFile()需要4倍的内存?

当BitmapFactory.nativeDecodeStream()耗尽android应用程序的内存时

Android BitmapFactory.decodeResource占用过多内存

Android 5.0不支持BitmapFactory.Options inPurgeable

来自Assets的BitmapFactory.decodeStream在Android 7上返回null

如果多次使用,则Android BitmapFactory.decodeResource内存不足

BitmapFactory.decodeFile() 返回 null xamarin.android

Android BitmapFactory.decodeFile(path)始终返回null

Android Studio Kotlin:BitmapFactory.decodeStream()返回null

Android中的BitmapFactory.decodeFile和ImageView奇怪的东西

BitmapFactory.decodeResource在Android 2.2上为null

在android.graphics.BitmapFactory.nativeDecodeAsset(本地方法)

BitmapFactory.decodeResource在Android 2.2中返回可变的位图,在Android 1.6中返回不可变的位图

为什么BufferedInputStream.read()在用于返回0的Android Nougat中返回-1?

BufferedInputStream的用法

BufferedInputStream 的体积?

使用GZIP文件上的BitmapFactory.DecodeStreamAsync将URL流传输到Android.Graphics.Bitmap

BitmapFactory:无法解码流:java.io.FileNotFoundException:打开失败:EACCES(拒绝)对Android Q的

Android BitmapFactory.decodeByteArray获取比iOS UIImage交换的照片宽度/高度

在Android Nougat上拍摄照片后,BitmapFactory无法从Uri解码位图

来自Assets的BitmapFactory.decodeStream有时在Android 7上失败

在Android中,BitmapFactory.decodeByteArray返回带有inJustDecoteBounds = true的null

Android无法解码流:bitmapFactory.decodeFile()的java.io.FileNotFoundException

ImageDecoder与BitmapFactory

从 BufferedInputStream 捕获 404 错误

如何正确关闭BufferedInputStream

BufferedInputStream和阻塞