Sub LoadBitmapWithColorAndAlphaFactor(fileName As String, myColor As Int, alphaFactor As Float) As Bitmap
Dim fc As B4XBitmap = LoadBitmap(File.DirAssets,fileName)
Dim bmpc As BitmapCreator
bmpc.Initialize(fc.Width, fc.Height)
bmpc.CopyPixelsFromBitmap(fc)
Dim myARGB As ARGBColor
myARGB.Initialize
myARGB.r = Bit.And(0xFF, Bit.ShiftRight(myColor, 16))
myARGB.g = Bit.And(0xFF, Bit.ShiftRight(myColor, 8))
myARGB.b = Bit.And(0xFF, myColor)
Dim ARGB_final As ARGBColor
ARGB_final.Initialize
Dim c,r As Int
For c=0 To fc.Width-1
For r=0 To fc.Height-1
Dim ARGB As ARGBColor
bmpc.GetARGB(c,r,ARGB) ' <-- here is where the crash happens
If ARGB.a<>0 Then
ARGB_final.a = ARGB.a * alphaFactor
ARGB_final.r = myARGB.r
ARGB_final.g = myARGB.g
ARGB_final.b = myARGB.b
bmpc.SetARGB(c,r,ARGB_final)
End If
Next
Next
Return bmpc.Bitmap
End Sub