Android Question Add logo image inside QR Code

Tasyo28

Member
Licensed User
Hi,

May i ask how to add image in side QR Code as per this below QR Code generator by Erel?


Thank you.

Regards,
Tasyo
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
1625380971159.png


B4X:
    Dim qrbmp As B4XBitmap = qr.Create(sb.ToString)
    Dim bmp As B4XBitmap = DrawLogoInMiddle(qrbmp, xui.LoadBitmap(File.DirAssets, "logo.png"))
    ImageView2.SetBitmap(bmp)


Sub DrawLogoInMiddle(bmp As B4XBitmap, logo As B4XBitmap) As B4XBitmap
    Dim cvs As B4XCanvas
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, bmp.Width, bmp.Height)
    cvs.Initialize(p)
    cvs.DrawBitmap(bmp, cvs.TargetRect)
    Dim r As B4XRect
    r.Initialize(cvs.TargetRect.Width * 2 / 5, cvs.TargetRect.Height * 2 / 5, cvs.TargetRect.Width * 3 / 5, cvs.TargetRect.Height * 3 / 5)
    cvs.DrawBitmap(logo, r)
    Dim res As B4XBitmap = cvs.CreateBitmap
    cvs.Release
    Return res
End Sub
 
Upvote 0
Top