Skip to content Skip to sidebar Skip to footer

Bitmap Size Exceeds 32bits

I am scaling a Bitmap by using a seekbar. Whenever i increase the progress of seekbar, image scaling fails by giving error 'Bitmap size exceeds 32bits'. If i scale the image with d

Solution 1:

Which value are you passing into the density argument of your dpToPx(int,int) method?

Your method declares density as int, which leads me to believe you may be passing in DisplayMetrics.densityDpi, a three-digit int number. What you meant to use DisplayMetrics.density, a single digit float number. This will have pushed your image dimension outside 32 bits:

threshold 32 bits signedint=2^31 -1         =  2147483647

progressValue = 16bitmapedge=16 * 128     = 2048bitmapsize=2048^2       = 4194304
at 32 bpp     = 4194304 * 32 = 134217728

multiplied bydensityDpi=134217728 * 460 = 61740154880// kaboom
multiplied bydensity=134217728 * 3   =   402653184// ok

Post a Comment for "Bitmap Size Exceeds 32bits"