Sub MakeTextBitmap(S As String)
Log("MakeTextBitmap " & S)
Dim B As Bitmap
B.InitializeMutable(300,300)
Dim C As Canvas
C.Initialize2(B)
Dim R As Rect
R.Initialize(0, 0, 300, 300)
C.DrawRect(R, Colors.ARGB(64,128,128,64),True,0)
Dim TextWidth As Float = C.MeasureStringWidth(S,Typeface.SANS_SERIF, 15)
Dim TextHeight As Float = C.MeasureStringHeight(S, Typeface.SANS_SERIF, 15)
Log(TextWidth & " " & TextHeight)
C.DrawText(S, 5, 5+TextHeight, Typeface.SANS_SERIF, 15, Colors.Yellow, "LEFT")
Dim MinX As Int = 9999
Dim MaxX As Int = -9999
Dim MinY As Int = 9999
Dim MaxY As Int = -9999
Dim BlankPixel As Int = B.GetPixel(0, 0)
For X = 0 To B.Width - 1
For Y = 0 To B.Height - 1
If B.GetPixel(X, Y) <> BlankPixel Then
If X < MinX Then MinX = X
If X > MaxX Then MaxX = X
If Y < MinY Then MinY = Y
If Y > MaxY Then MaxY = Y
End If
Next
Next
Log (MinX & " " & MinY & " " & MaxX & " " & MaxY)
R.Initialize(MinX - 2, MinY - 2, MaxX + 2, MaxY + 2)
C.DrawRect(R, Colors.Red, False, 1)
Dim IV As ImageView
IV.Initialize("")
IV.Bitmap = B
IV.Visible = True
Activity.AddView(IV,100, 100, B.Width, B.Height)
End Sub