My Samsung J7 Neo phone updated the android to 8.1.
Now the "CreateBitmapWithAlpha" routine does not work right. It's locking.
Can someone help me?
B4X:
Private Sub CreateBitmapWithAlpha(myOriginalBitmap As Bitmap, newAlpha As Int) As Bitmap
Dim canvas1 As Canvas
Dim myNewBitmap As Bitmap
myNewBitmap.initializeMutable(myOriginalBitmap.Width,myOriginalBitmap.Height)
canvas1.initialize2(myNewBitmap)
Dim CanvJO As JavaObject = canvas1
CanvJO = CanvJO.GetField("canvas")
Dim J As JavaObject
J.initializeContext()
J.Runmethod("alphatize",Array(CanvJO, myOriginalBitmap, newAlpha))
Return(myNewBitmap)
End Sub
Tested. If you add some measurements to your code you will find that the time is not lost in "CreateBitmapWithalpha", but on "DrawFirework"
Modify your TimeR_Tick routine
B4X:
Private Sub Timer_Tick
Dim t0 As Long = DateTime.now '<--- Added
For fIdx = 0 To nFires - 1
DrawFireWork(fIdx)
Next
Dim t1 As Long =DateTime.now
Dim bmp As Bitmap = CreateBitmapWithAlpha(ivFireW.Bitmap, 245)
Dim tFinal As Long = DateTime.now '<--- Added
Log("DrawFirework took "&(t1-t0)&"msec. CreateBitmapWithAlpha took:"&(tFinal -t1)&"msec") '<--- Added
ivFireW.Bitmap = bmp
gv.Invalidate
End Sub
When the fires start, the logs say
B4X:
...
DrawFirework took 0msec. CreateBitmapWithAlpha took:6msec
DrawFirework took 0msec. CreateBitmapWithAlpha took:6msec
DrawFirework took 0msec. CreateBitmapWithAlpha took:6msec
...
But after some time, perhaps when the fireworks do Booommmmm!!!!!, these are the logs
B4X:
...
DrawFirework took 33msec. CreateBitmapWithAlpha took:5msec
DrawFirework took 288msec. CreateBitmapWithAlpha took:6msec
DrawFirework took 281msec. CreateBitmapWithAlpha took:5msec
DrawFirework took 567msec. CreateBitmapWithAlpha took:7msec
DrawFirework took 571msec. CreateBitmapWithAlpha took:5msec
DrawFirework took 599msec. CreateBitmapWithAlpha took:6msec
...
...(and increasing)
hi Erel,
Image sparks is small, 300x300px.
Application runs on all versions of android, except on 8.1.
The problem only happens in Canvas.DrawBitmap ().
If I change to Canvas.DrawCircle () it works perfectly.
hi Erel,
Image sparks is small, 300x300px.
Application runs on all versions of android, except on 8.1.
The problem only happens in Canvas.DrawBitmap ().
If I change to Canvas.DrawCircle () it works perfectly.