Android Example Create Personalised QR Codes

Discussion in 'Tutorials & Examples' started by Johan Schoeman, Jul 16, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    See attached project that you can use to make personalized QR codes with. Image that is superimposed over the QR code should preferably have a transparent background. You can do things like this:

    pic2.png

    All the additional library files that were used for this project are in the /files folder of the attached B4A project. The code module inside the B4A project has the code that creates the QR Codes. No internet connections are required to create the QR codes with.

    Scan the above codes with something like NeoReader, i-nigma, or QRCPV4. It will take you to the applicable B4X websites.

    Enjoy!
     

    Attached Files:

    Last edited: Jul 17, 2015
  2. DonManfred

    DonManfred Expert Licensed User

    Thank you for sharing this :)
     
    Johan Schoeman likes this.
  3. zoujoo

    zoujoo Member Licensed User

    Good, thank you:cool:
     
  4. Shalu Samtani

    Shalu Samtani Member Licensed User

    can use in B4j?
     
  5. Star-Dust

    Star-Dust Expert Licensed User

    Thanks for sharing it, I've been looking for code for creating QR all in B4A.
     
    Johan Schoeman likes this.
  6. Johan Schoeman

    Johan Schoeman Expert Licensed User

  7. freedom2000

    freedom2000 Well-Known Member Licensed User

    nice job Johan !
     
    Johan Schoeman likes this.
  8. Procesor

    Procesor New Member Licensed User

    Error:

    "The following libraries are missing:
    stringfunctions
    rsimageprocessing"
     
  9. DonManfred

    DonManfred Expert Licensed User

    Search the forum for them. stringfunctions is part of B4A installation.
    rsimage* is a Library. Search for it.
     
    Last edited: Nov 11, 2017
    Procesor likes this.
  10. Johan Schoeman

    Johan Schoeman Expert Licensed User

    StringUtils is part of the B4A installation. StringFunctions is a library by @margret. Attached are the files....
     

    Attached Files:

    Procesor and DonManfred like this.
  11. DonManfred

    DonManfred Expert Licensed User

    You are right. Sorry, my fault!
     
    Johan Schoeman likes this.
  12. Star-Dust

    Star-Dust Expert Licensed User

    however, some features used by RSImageProcessing can also be obtained without using this library.

    For example, resize the image:
    Code:
    Sub CreateScaledBitmap(Original As Bitmap, NewWidth As Int, NewHeight As Int) As Bitmap
        
    Dim r As Reflector
        
    Dim b As Bitmap

        b = r.RunStaticMethod(
    "android.graphics.Bitmap""createScaledBitmap", _
            
    Array As Object(Original, NewWidth, NewHeight, true), _
            
    Array As String("android.graphics.Bitmap""java.lang.int""java.lang.int""java.lang.boolean"))
        
    Return b
    End Sub
     
    Last edited: Nov 11, 2017
    DonManfred and Johan Schoeman like this.
  13. Star-Dust

    Star-Dust Expert Licensed User

    The roundCorner could also be created.

    A similar thing I got with the following code:

    Code:
    Sub CreateBitmap As Canvas
       
    Dim bmp As Bitmap
       bmp.InitializeMutable(
    200dip200dip)
       
    Dim cvs As Canvas
       cvs.Initialize2(bmp)
       
    Dim r As Rect
       r.Initialize(
    00, bmp.Width, bmp.Height)
       cvs.DrawRect(r, 
    Colors.Transparent, True0)
       
    Dim p As Path
       p.Initialize(
    00)
       
    Dim jo As JavaObject = p
       
    Dim x = 100dip, y = 100dip, radius = 100dip As Float
       jo.RunMethod(
    "addCircle"Array As Object(x, y, radius, "CW"))
       cvs.ClipPath(p)
       
    Return cvs
    End Sub

    Sub DrawRoundBitmap (bmp As BitmapAs Bitmap
       
    Dim r As Rect
       
    Dim cvs As Canvas = CreateBitmap
       
       r.Initialize(
    00, cvs.Bitmap.Width, cvs.Bitmap.Height)
       cvs.DrawBitmap(bmp, 
    Null, r)
       
    Return cvs.Bitmap
    End Sub
    But I'm not sure they do the same thing, it's true :p
     
    Last edited: Nov 11, 2017
  14. freedom2000

    freedom2000 Well-Known Member Licensed User

    An idea to @Johan Schoeman our "QR king"

    I do enjoy rounded multicolor QR codes (have a look to my avatar !)
    It seems to me that you are very close now to get such beautiful results.
    I found this python lib : https://github.com/davidszotten/prettyqr which seems to do it
    output.jpg

    Aren't you tempted (just a challenge not a need) ?
     
    Johan Schoeman likes this.
  15. Johan Schoeman

    Johan Schoeman Expert Licensed User

    freedom2000 and Rantor777 like this.
  16. Rantor777

    Rantor777 Member Licensed User

    More QRCode options, Great!
     
  17. freedom2000

    freedom2000 Well-Known Member Licensed User

    How fast you are ...

    Great :)

    BTW : I played a little with QR codes to convert one into CNC Mill path. Need some manual tuning but may work --> carving a QR code into a wooden part or burn it with a laser cutter...
     
    Johan Schoeman likes this.
Loading...