I need some custom bitmaps to show the google map marker titles of all markers automatically without tapping. The created bitmap should just be large enough to show entire text.
I'm facing two problems with following code:
1. B4XCanvas expects a view which I can't provide; the created bitmaps will be shown as part of google map marker icons.
2. I couldn't make the bitmap's background transparent.
A few threads in the forum mention "TextToBitmap" which might be what I need; unfortunately I couldn't find out which library it belongs to.
Could someone help me create a bitmap, from text, for use as google map marker icon, and/or locate "TextToBitmap" function/library, please?
TIA
I'm facing two problems with following code:
1. B4XCanvas expects a view which I can't provide; the created bitmaps will be shown as part of google map marker icons.
2. I couldn't make the bitmap's background transparent.
following code block creates a bitmap with text provided:
'''''''''''''''''''''''''''''''''''''''
Sub Globals
Dim cvs As B4XCanvas
Private ImageView1 As ImageView
End Sub
sub CreateBitMap
cvs.Initialize(ImageView1)
Dim text As String="hello"
Dim Fnt As B4XFont
Fnt=xui.CreateDefaultFont(28)
Dim centerX As Int=100
Dim centerY As Int=60
Dim r As B4XRect = cvs.MeasureText(text, Fnt)
'ImageView1.Background=BackGround(Colors.Transparent) 'this line makes bitmap invisible
ImageView1.Width=r.Width
ImageView1.Height=r.Height
Dim BaseLine As Int = centerY - r.Height / 2 - r.Top
cvs.DrawText(text, centerX, BaseLine, Fnt, Colors.red, "CENTER")
Dim bmp As Bitmap=cvs.CreateBitmap
'to do: code to save the created bitmap
end sub
Sub BackGround(Color As Int) As ColorDrawable
Dim cdb As ColorDrawable
cdb.Initialize(Color, 5dip)
Return cdb
End Sub
A few threads in the forum mention "TextToBitmap" which might be what I need; unfortunately I couldn't find out which library it belongs to.
Could someone help me create a bitmap, from text, for use as google map marker icon, and/or locate "TextToBitmap" function/library, please?
TIA