Following function crashes with java.lang.reflect.InvocationTargetException / Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.setHasAlpha(boolean)' on a null object reference
FYI, the bitmap passed in the function is valid, the log shows "(Bitmap): 1080 x 1920"...
B4X:
Sub CreateScaledBitmap(Original As Bitmap, Width As Int, Height As Int, keepRatio As Boolean, filter As Boolean) As Bitmap
Dim jo As JavaObject
Dim newHeight As Int
newHeight = Height
If keepRatio Then
Dim CalcRatio As Int
CalcRatio = Original.Width / Original.Height
newHeight = Width / CalcRatio
End If
jo.InitializeStatic("android.graphics.Bitmap")
Log(Original)
Return jo.RunMethod("createScaledBitmap", Array (Original, Width, newHeight, filter))
End Sub
FYI, the bitmap passed in the function is valid, the log shows "(Bitmap): 1080 x 1920"...