Skip to content

fix: bitmap scaling integer division crash on high-DPI devices#150

Open
mostafizurhimself wants to merge 2 commits into
mitsuharu:mainfrom
999itsolutions:main
Open

fix: bitmap scaling integer division crash on high-DPI devices#150
mostafizurhimself wants to merge 2 commits into
mitsuharu:mainfrom
999itsolutions:main

Conversation

@mostafizurhimself

Copy link
Copy Markdown

Problem

On high-DPI Android devices (2×/3× screen density), printBitmapBase64 and
printBitmapBase64Custom crash with an IllegalArgumentException from
Bitmap.createScaledBitmap.

Root cause: Integer division truncation.

// Before — pixelWidth / w rounds to 0 when imageWidth > pixelWidth
val image = Bitmap.createScaledBitmap(decodedBitmap, pixelWidth, pixelWidth / w * h, false)

Mostafiz added 2 commits June 10, 2026 09:15
…screens

pixelWidth / w * h uses integer division which rounds to 0 when imageWidth > pixelWidth
(e.g. ViewShot on 2x/3x DPI device captures wider than target pixelWidth).
Bitmap.createScaledBitmap with height=0 throws IllegalArgumentException.

Fix: use long arithmetic (pixelWidth.toLong() * h / w).toInt() to preserve precision.
…compatibility

- Remove 'prepare' script (bob build fails without yarn in git-dep install)
- Remove lib/ from .gitignore so built output ships with the package
- Add ignoreDeprecations 6.0 and exclude __tests__ from tsconfig.build.json
- lib/commonjs, lib/module, lib/typescript all committed
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

Successfully merging this pull request may close these issues.

1 participant