An update - it has DataMatrix, QRcode, and AztecCode. Library (jar) can be used in B4J and B4A. Copy the attached jar to your B4A and/or B4J library folder(s).
[CODE lang="b4x" title="B4J code"]#Region Project Attributes
#MainFormWidth: 800
#MainFormHeight: 800
#End Region
#AdditionalJar: OkapiJHS
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Canvas1 As Canvas
Private Canvas2 As Canvas
Private Canvas3 As Canvas
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'it holds the Canvas that we will draw the DataMatrix on
MainForm.Show
'****** DATAMATRIX ************
Dim dm As JavaObject
dm.InitializeNewInstance("uk.org.okapibarcode.backend.DataMatrix" , Null) 'initialize a new instance of DataMatrix using B4A / B4J JavaObject
'******************************************************************************************************************************************************
'THIS IS THE STRING THAT WILL BE CONVERTED INTO A DATAMATRIX 2D BARCODE
dm.RunMethod("setContent", Array("Hello B4J/B4A - This is Okapi DataMatrix. It is one of the range of 1D and 2D barcodes that can be created with OkapiBarcode"))
'*********************************************************************************************************************************************************
Dim rec As List = dm.RunMethod("getRectangles", Null) 'get the List of rectangles that need to be drawn of the Canvas
For i = 0 To rec.Size - 1
Log(rec.Get(i)) 'Log the entries in the list
Next
Dim maxsize As Int = 2500 'this will allow 2500 entries in the list that will hold X, Y, WIDTH, HEIGHT values
Dim coordx(maxsize) As Int
Dim coordy(maxsize) As Int
Dim wdth(maxsize) As Int
Dim hght(maxsize) As Int
For i = 0 To maxsize - 1
coordx(i) = -1
coordy(i) = -1
wdth(i) = -1
hght(i) = -1
Next
For i = 0 To rec.Size - 1
Dim str As String = rec.Get(i)
str = str.Replace("Rectangle[", "")
str = str.Replace("]", "")
Dim components(4) As String = Regex.Split("," , str)
components(0) = components(0).Replace("x=", "")
components(1) = components(1).Replace("y=", "")
components(2) = components(2).Replace("width=", "")
components(3) = components(3).Replace("height=", "")
Dim xpos, ypos, modw, modh As Int
xpos = components(0).As(Int)
ypos = components(1).As(Int)
modw = components(2).As(Int)
modh = components(3).As(Int)
coordx(i) = xpos
coordy(i) = ypos
wdth(i) = modw
hght(i) = modh
Next
Dim barwidth As Double = 5dip
Dim lft As Double = 50dip
Dim tp As Double = 50dip
For i = 0 To maxsize - 1
If coordx(i) <> -1 Then
lft = lft + coordx(i) * barwidth
tp = tp + coordy(i) * barwidth
Canvas1.DrawRect(lft, tp, barwidth * wdth(i), barwidth * hght(i), fx.Colors.Black, True, 0)
lft = 50dip
tp = 50dip
End If
Next
'****** QRCODE ************
Dim qr As JavaObject
qr.InitializeNewInstance("uk.org.okapibarcode.backend.QrCode" , Null) 'initialize a new instance of DataMatrix using B4A / B4J JavaObject
'******************************************************************************************************************************************************
'THIS IS THE STRING THAT WILL BE CONVERTED INTO A QR 2D BARCODE
qr.RunMethod("setContent", Array("Hello B4J/B4A - This is Okapi QR Code. It is one of the range of 1D and 2D barcodes that can be created with OkapiBarcode"))
'*********************************************************************************************************************************************************
Dim rec As List = qr.RunMethod("getRectangles", Null) 'get the List of rectangles that need to be drawn of the Canvas
For i = 0 To rec.Size - 1
Log(rec.Get(i)) 'Log the entries in the list
Next
Dim maxsize As Int = 2500 'this will allow 2500 entries in the list that will hold X, Y, WIDTH, HEIGHT values
Dim coordx(maxsize) As Int
Dim coordy(maxsize) As Int
Dim wdth(maxsize) As Int
Dim hght(maxsize) As Int
For i = 0 To maxsize - 1
coordx(i) = -1
coordy(i) = -1
wdth(i) = -1
hght(i) = -1
Next
For i = 0 To rec.Size - 1
Dim str As String = rec.Get(i)
str = str.Replace("Rectangle[", "")
str = str.Replace("]", "")
Dim components(4) As String = Regex.Split("," , str)
components(0) = components(0).Replace("x=", "")
components(1) = components(1).Replace("y=", "")
components(2) = components(2).Replace("width=", "")
components(3) = components(3).Replace("height=", "")
Dim xpos, ypos, modw, modh As Int
xpos = components(0).As(Int)
ypos = components(1).As(Int)
modw = components(2).As(Int)
modh = components(3).As(Int)
coordx(i) = xpos
coordy(i) = ypos
wdth(i) = modw
hght(i) = modh
Next
Dim barwidth As Double = 5dip
Dim lft As Double = 50dip
Dim tp As Double = 50dip
For i = 0 To maxsize - 1
If coordx(i) <> -1 Then
lft = lft + coordx(i) * barwidth
tp = tp + coordy(i) * barwidth
Canvas2.DrawRect(lft, tp, barwidth * wdth(i), barwidth * hght(i), fx.Colors.Black, True, 0)
lft = 50dip
tp = 50dip
End If
Next
'****** AZTEC ************
Dim az As JavaObject
az.InitializeNewInstance("uk.org.okapibarcode.backend.AztecCode" , Null) 'initialize a new instance of DataMatrix using B4A / B4J JavaObject
'******************************************************************************************************************************************************
'THIS IS THE STRING THAT WILL BE CONVERTED INTO A AZTEC 2D BARCODE
az.RunMethod("setContent", Array("Hello B4J/B4A - This is Okapi Aztec Code. It is one of the range of 1D and 2D barcodes that can be created with OkapiBarcode"))
'*********************************************************************************************************************************************************
Dim rec As List = az.RunMethod("getRectangles", Null) 'get the List of rectangles that need to be drawn of the Canvas
For i = 0 To rec.Size - 1
Log(rec.Get(i)) 'Log the entries in the list
Next
Dim maxsize As Int = 2500 'this will allow 2500 entries in the list that will hold X, Y, WIDTH, HEIGHT values
Dim coordx(maxsize) As Int
Dim coordy(maxsize) As Int
Dim wdth(maxsize) As Int
Dim hght(maxsize) As Int
For i = 0 To maxsize - 1
coordx(i) = -1
coordy(i) = -1
wdth(i) = -1
hght(i) = -1
Next
For i = 0 To rec.Size - 1
Dim str As String = rec.Get(i)
str = str.Replace("Rectangle[", "")
str = str.Replace("]", "")
Dim components(4) As String = Regex.Split("," , str)
components(0) = components(0).Replace("x=", "")
components(1) = components(1).Replace("y=", "")
components(2) = components(2).Replace("width=", "")
components(3) = components(3).Replace("height=", "")
Dim xpos, ypos, modw, modh As Int
xpos = components(0).As(Int)
ypos = components(1).As(Int)
modw = components(2).As(Int)
modh = components(3).As(Int)
coordx(i) = xpos
coordy(i) = ypos
wdth(i) = modw
hght(i) = modh
Next
Dim barwidth As Double = 5dip
Dim lft As Double = 50dip
Dim tp As Double = 50dip
For i = 0 To maxsize - 1
If coordx(i) <> -1 Then
lft = lft + coordx(i) * barwidth
tp = tp + coordy(i) * barwidth
Canvas3.DrawRect(lft, tp, barwidth * wdth(i), barwidth * hght(i), fx.Colors.Black, True, 0)
lft = 50dip
tp = 50dip
End If
Next
End Sub
[/CODE]