Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

压缩图片抛InvalidMarkException #19

Open
IdioticMadman opened this issue Aug 16, 2021 · 3 comments
Open

压缩图片抛InvalidMarkException #19

IdioticMadman opened this issue Aug 16, 2021 · 3 comments

Comments

@IdioticMadman
Copy link

IdioticMadman commented Aug 16, 2021

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

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

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

@forJrking
Copy link
Owner

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

@IdioticMadman
Copy link
Author

IdioticMadman commented Aug 23, 2021

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

@IdioticMadman
Copy link
Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants