Android Question code39 b4x

Uniko Sistemi srl

Active Member
Licensed User
hello everyone, is there the possibility of creating a code39 barcode with b4x with some library? do you have any advice? I saw that in the past there was a library, but it needs internet connection and it's not for me. thanks a lot to everyone
 

BlueVision

Active Member
Licensed User
Longtime User
La risposta in italiano? Sono confuso. Non c'è di che. Il merito va al genio di Johan Schoemann, non a me.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
hello everyone, is there the possibility of creating a code39 barcode with b4x with some library? do you have any advice? I saw that in the past there was a library, but it needs internet connection and it's not for me. thanks a lot to everyone
See:
Multiple barcode generators, cross-platform.
I personally created a class with all barcodes, which I use in B4i, B4A and B4J
and

My Sample:
 
Last edited:
Upvote 0

Uniko Sistemi srl

Active Member
Licensed User

great, I try to watch. thank you
 
Upvote 0

Uniko Sistemi srl

Active Member
Licensed User
excuse a question, in the first link it takes me to an example, however, in b4j. how do i find something to adapt to b4i? thank you
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Test 1:
Default setting:
background color is transparent
pattern color is black
padding is zero



Test 2:
Default setting:
background color is white
pattern color is black
padding is 10

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
test color:

B4X:
    BarCode39.BackgroundColor = xui.Color_Yellow 'default Tranparent
    BarCode39.PatternColor = xui.Color_Blue 'default black
    BarCode39.Padding = 10 'default 0

 
Upvote 0

Jan Vrielink

Member
Licensed User
Here is b4a-code for generating code39-barcode.

PaintBarCode(Canvas1, 5dip, 1dip, 100dip, "ABCDEF", 2)

Simple b4x/b4a code for generating code39:
Public Sub PaintBarCode( xCanvas As Canvas, xLeft As Int,  xTop As Int, xHeight As Int, xCode As String, xThicknes As Float)
Dim intercharacterGap As String = "0"
Dim str As String
Dim alphabet39 As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"
Dim coded39Char() As String = Array As String("000110100", "100100001", "001100001", "101100000", "000110001", "100110000", _
  "001110000", "000100101", "100100100", "001100100", "100001001", "001001001", _
  "101001000", "000011001", "100011000", "001011000", "000001101", "100001100", _
  "001001100", "000011100", "100000011", "001000011", "101000010", "000010011", _
  "100010010", "001010010", "000000111", "100000110", "001000110", "000010110", _
  "110000001", "011000001", "111000000", "010010001", "110010000", "011010000", _
  "010000101", "110000100", "011000100", "010101000", "010100010", "010001010", _
  "000101010", "010010100")

  If xCode = "" Then
        Return
    End If
  str = "*" & xCode.ToUpperCase & "*"

  For i = 0 To xCode.Length - 1
        If alphabet39.IndexOf( xCode.CharAt(i)) = -1 Or xCode.CharAt(i) = "*" Then
        Return
    End If
  Next

  Dim encodedString As String = ""

    For i  = 0 To str.Length - 1
    If i > 0 Then
            encodedString = encodedString & intercharacterGap
    End If
   encodedString = encodedString & coded39Char(alphabet39.IndexOf(str.CharAt(i)))
  Next

  Dim encodedStringLength As Int = encodedString.Length
    Dim wideToNarrowRatio As Float = 3

    Dim x As Float = 0
    Dim wid As Float = 0

  x = xLeft
  For i = 0 To encodedStringLength - 1
    If encodedString.CharAt(i) = "1" Then
            wid = wideToNarrowRatio * xThicknes
    Else
            wid = xThicknes
    End If

        Dim d2 As Rect
        d2.Initialize(  x, xTop,  x+ wid,  xHeight)
        xCanvas.DrawRect(d2, IIf(i Mod 2 = 0, Colors.Black, Colors.WHITE), True, wid)
    x = x + wid
  Next


 End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…