KLuban icon indicating copy to clipboard operation
KLuban copied to clipboard

压缩图片抛InvalidMarkException

Open IdioticMadman opened this issue 3 years ago • 3 comments

型号:魅族 PRO6 版本号:Flyme 7.3.0.0A android版本 7.1.1

//不加载进内存
options.inJustDecodeBounds = true
 //不加载进内存解析一次 获取宽高
BitmapFactory.decodeStream(srcStream.rewindAndGet(), null, options)

在这之后,markPos变成-1。想不通,为啥这个decodeStream会读取整个文件流导致超出marklimit。 这个文件流是一个大图片

IdioticMadman avatar Aug 16 '21 11:08 IdioticMadman

必现么,可以把图片地址抛一下,我周末修复一下

forJrking avatar Aug 19 '21 11:08 forJrking

应该和系统版本有关系。同一张图片。不同的系统调用BitmapFactory行为可能不同. 图片太大,图床上不去

IdioticMadman avatar Aug 23 '21 09:08 IdioticMadman

我改了一下,在使用BitmapFactory获取宽高的时候,使用了裸流。没有使用优化的

        //此处OOM
        var bitmap = srcStream.openInternal().use { inputStream ->
            BitmapFactory.decodeStream(inputStream, null, options)
                ?: throw IOException("decodeStream error")
        }

IdioticMadman avatar Aug 23 '21 09:08 IdioticMadman