B4J Question Looking for an example to add text to an image in b4j

microbox

Active Member
Licensed User
Longtime User
Can anyone share a link to add custom text(color and size) to an image?
 

TILogistic

Expert
Licensed User
Longtime User
Very simple:

see:


or

 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
My demo program is based in UI (project), the code below was created using B4xPage.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets,"c2.png")
    ImageView1.SetBitmap(bmp)
    pnDraw = xui.CreatePanel("")
    Root.AddView(pnDraw, ImageView1.Left, ImageView1.Top, ImageView1.Width, ImageView1.Height)
    mCanvas.Initialize(pnDraw)
    mRect.Initialize(0, 0, ImageView1.Width+10, ImageView1.Height+10)

    mCanvas.DrawBitmap(ImageView1.Snapshot, mRect)
    
    mCanvas.ClearRect(mCanvas.TargetRect)
    mCanvas.DrawBitmap(ImageView1.Snapshot, mRect)
    mCanvas.DrawText("Hello Test Message", 5, ImageView1.Height - 5 , xui.CreateDefaultFont(20), xui.Color_Blue, "LEFT")
End Sub
'
How can I convert this line of code..
Root.AddView(pnDraw, ImageView1.Left, ImageView1.Top, ImageView1.Width, ImageView1.Height) - gives error (undeclared variable Root)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…