VintaSoft Barcode .NET SDK 14.3: Documentation for .NET developer
In This Topic
    How to create an artistic QR barcode?
    In This Topic
    QR code symbology supports error correction algorithm with 4 levels for damaged barcode data recovery:
    Error Correction LevelRecovery Capacity %(approx.)
    L7%
    M15%
    Q25%
    H30%

    The ability to recover the barcode value allows to create artistic QR barcodes, i.e. draw a small image over a barcode region.

    Important! Artistic QR barcode is a "distorted" QR barcode and it has lower recovering capacity than the common one.

    The algorithm below shows how to create an artistic QR barcode with recovery capacity reduced not more than 2 times.



    The algorithm for creation of artistic QR barcode

    Terms used in algorithm:
    1. Logo image - image to draw on the barcode
    2. Cell - cell of the barcode, can be black or white
    3. Cell size - size of the cell, can be got/set with the WriterSettings.MinWidth property
    4. Cell area - area of the cell, cell_area = cell_size * cell_size
    5. Version of QR barcode - version of QR barcode, can be got/set with the WriterSettings.QRSymbol property
    6. Recovery capacity - recovery capacity in percents, see the table above
    7. Assurance factor - assurance factor, available values from 0 to 1, recommended value is 0.2


    Steps of algorithm:
    1. Calculate the area, in cells^2, for the logo image:
          logo_image_area_in_cells = logo_image_width_in_pixels * logo_image_height_in_pixels / cell_area_in_pixels
      

    2. Generate a common QR barcode with necessary data and error correction level (error correction level H is recommended).
      Get the version of generated QR barcode:
          qr_version = value of the WriterSettings.QRSymbol property
      

    3. Calculate the width/height, in cells, of the generated QR barcode:
          qr_barcode_width_in_cells = 21 + (qr_version - 1) * 4
      

    4. Calculate the area, in cells^2, of the QR barcode which cannot be used for the logo image:
          system_qr_barcode_area_in_cells = 9 ^ 2 * 3 = 243
      

    5. Calculate the area, in cells^2, of the QR barcode which can be used for the logo image:
          available_qr_barcode_area_for_logo_image_in_cells = qr_barcode_width_in_cells ^ 2 - system_qr_barcode_area_in_cells
      

    6. Calculate the area, in cells^2, of the QR barcode which can be used for the logo image, the recovery capacity of QR barcode will not be reduced more than 2 times:
          safe_qr_barcode_area_for_logo_image_in_cells = available_qr_barcode_area_for_logo_image_in_cells * (recovery_capacity / 100) * (1 - assurance_factor) * 0.5
      

    7. Increment the qr_version and go to step 3 if logo_image_area_in_cells is less than safe_qr_barcode_area_for_logo_image_in_cells

    8. Draw the logo image on the barcode image in the green or yellow area (see image below)

    9. Read the generated QR barcode using the barcode reader and get the reading quality of barcode:
          reading_quality = value of the IBarcodeInfo.ReadingQuality property
      

    10. Increment the qr_version and go to step 3 if reading_quality is less than 0.5

    11. Artistic QR barcode is generated


    Here is an example that shows how to create an artistic QR barcode with cell size 5x5 pixels and logo image with size 112x65 pixels:
    1. logo_image_area_in_cells = 112 * 65 / (5 * 5) = 292

    2. Barcode text: https://www.vintasoft.com
      Error correction level: H
      qr_version = 3

    3. qr_barcode_width_in_cells = 21 + (3 - 1) * 4 = 29

    4. available_qr_barcode_area_for_logo_image_in_cells = 29 ^ 2 - 243 = 598

    5. safe_qr_barcode_area_for_logo_image_in_cells = 598 * (30 / 100) * (1 - 0.2) * 0.5 = 71

    6. 292 > 71, qr_version = 9 AND go to step 3 of the main algorithm

    7. qr_barcode_width_in_cells = 21 + (9 - 1) * 4 = 53

    8. available_qr_barcode_area_for_logo_image_in_cells = 49 ^ 2 - 243 = 2566

    9. safe_qr_barcode_area_for_logo_image_in_cells = 2566 * (30 / 100) * (1 - 0.2) * 0.5 = 307

    10. 292 < 307, go to step 8 of the main algorithm

    11. Draw the logo image on the barcode image in the green or yellow area (see image below)

    12. reading_quality = 0.66

    13. Artistic QR barcode is generated