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

load(bitmap) 输出只有Bitmap.CompressFormat.JPEG格式,后面checker 头的时候也会把png图片也当成JPEG #27

Open
louis-lzt opened this issue Nov 22, 2021 · 0 comments

Comments

@louis-lzt
Copy link

// 建议这么修改
fun load(bitmap: Bitmap) = loadGeneric(bitmap) {
val os = ByteArrayOutputStream()
if (bitmap.config == Bitmap.Config.RGB_565 || !bitmap.hasAlpha()){
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os)
}else{
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os)
bitmap.density
}
bitmap.recycle()
ByteArrayInputStream(os.toByteArray())
}

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

1 participant