EDIT: updated to version 0.12 (see below)
Hi all,
please find attached a barcode generation library entirely based on B4A code.
Current version is alpha so it is limited to a couple of symbologies (EAN/UPC).
I'm using it as a test-bed for a more general solution where the strict adherence to each symbology's tech specifications should be a must.
The lib interface is not final, so please read release notes when updating to a newer version.
A simple example about dgBarcode usage to display a barcode:
A second example, useful to generate a barcode without displaying it :
And finally an example on how to use a few optional properties
Feel free to suggest improvements and alternative design strategies. Enjoy.
Umberto
Version 0.12
- added method GenerateBitmap to return a bitmap ready to be saved in a file or DB
Version 0.11
- added support for UPC-A symbology
- added method IsCodeValid to check for code integrity
- added catch-all drawing for invalid codes (a light color rectangle with two crossing dark color lines)
Version 0.10
initial version; support for EAN symbology only
Hi all,
please find attached a barcode generation library entirely based on B4A code.
Current version is alpha so it is limited to a couple of symbologies (EAN/UPC).
I'm using it as a test-bed for a more general solution where the strict adherence to each symbology's tech specifications should be a must.
The lib interface is not final, so please read release notes when updating to a newer version.
A simple example about dgBarcode usage to display a barcode:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim bc As cls_barcode
bc.Initialize
Dim img1 As ImageView
img1.Initialize("")
Activity.AddView(img1,0dip,20dip,bc.CodeWidth(bc.Symbologies.EAN13),bc.CodeHeight(bc.Symbologies.EAN13))
bc.DrawBarCode(bc.Symbologies.EAN13,"7617027005456",img1)
End Sub
A second example, useful to generate a barcode without displaying it :
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim bc As cls_barcode
bc.Initialize
Dim bm1 As Bitmap
bm1.Initialize3(bc.GenerateBitmap(bc.Symbologies.EAN13,"7617027005456"))
end sub
And finally an example on how to use a few optional properties
B4X:
'let's check the validity of a pair of codes
Log(bc.IsCodeValid(bc.Symbologies.UPCA,"614141012343")) 'valid
Log(bc.IsCodeValid(bc.Symbologies.UPCA,"614151012343")) 'wrong (check digit doesn't match)
'Let's compute the check digit for a given code
Log(bc.ComputeCheckDigit(bc.Symbologies.EAN13,"761702700545")) 'returns 6
'Let's modify colors to draw the code and its scale factor
bc.SetDrawingColors(Colors.Cyan,Colors.Yellow) 'very poor contrast
bc.ScaleFactor = 2.0 'maximum scale factor
Feel free to suggest improvements and alternative design strategies. Enjoy.
Umberto
Version 0.12
- added method GenerateBitmap to return a bitmap ready to be saved in a file or DB
Version 0.11
- added support for UPC-A symbology
- added method IsCodeValid to check for code integrity
- added catch-all drawing for invalid codes (a light color rectangle with two crossing dark color lines)
Version 0.10
initial version; support for EAN symbology only
Attachments
Last edited: