Menu

#119 Maxicode with scale less than 1.0

2.0
closed
None
2020-04-01
2018-08-27
No

Maxicode with scale less than 1.0 doesn't work because of this line in the function "plot_raster_maxicode" in "raster.c":

hexagon_size = (int)scaler * 10;

the cast to int rounds off the variable before multiplying it. If changed the maxicode is generated correctly, but the position of the bullseye is still incorrect. The function "draw_bullseye" probably needs to be improved to be more general.

The problem is probably related to this earlier observation:

https://sourceforge.net/p/zint/mailman/message/25964225/

Discussion

  • Harald Oehlmann

    Harald Oehlmann - 2018-11-02
    • assigned_to: Robin Stuart
     
  • Robin Stuart

    Robin Stuart - 2019-03-16

    I have made the obvious fix for this so that at least something plots if the scale is less than 1.0. I think, however, that trying to plot these symbols in so few pixels is just asking for trouble and really should be discouraged.
    A better solution is either to increase the resolution (I would suggest at least 600dpi) or to use a vector format such as SVG.

     
  • codemonkey82

    codemonkey82 - 2019-03-16

    Hi Robin. Thanks for the fix.

    I'm printing this symbol with 203 dpi, with the scale of 0.667 - there is much ancient equipment out there... (203 dpi is the lowest resolution still being used widely in label printing.)

    Here is my fix for the bullseye problem. It works like before for scales >= 1.0, but additionally supports scale 0.667 when scale < 1.0

    It should be possible to generalize this function for other scales less than 1.0 after some cleanup.

    draw_bullseye(pixelbuf, image_width, image_height, (2 * xoffset), (2 * yoffset), scaler * 10);
    
    void draw_bullseye(char *pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) {
        /* Central bullseye in Maxicode symbols */
        float FactorX = 14.5 * scaler;
        float FactorY = 15.0 * scaler;
        if(scaler < 10) // Support scale 0.667
        {
            FactorX = 16.0 * scaler;
            FactorY = 16.5 * scaler;
        }
    
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (4.571 * scaler) + 1, '1');
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (3.779 * scaler) + 1, '0');
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (2.988 * scaler) + 1, '1');
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (2.196 * scaler) + 1, '0');
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (1.394 * scaler) + 1, '1');
        draw_circle(pixelbuf, image_width, image_height, (FactorX) + xoffset, (FactorY) + yoffset, (0.602 * scaler) + 1, '0');
    }
    
     

    Last edit: codemonkey82 2019-03-16
  • Harald Oehlmann

    Harald Oehlmann - 2019-08-30
    • status: open --> closed
     
  • Harald Oehlmann

    Harald Oehlmann - 2019-08-30

    Apparently, something was done.
    The line is now:

    hexagon_size = (int)(scaler * 10);
    

    I close the bug.
    Come back if issue persists.

     
  • codemonkey82

    codemonkey82 - 2019-09-01

    Hi Harald,

    we additionally need to change the draw_bullseye function to support resolutions less than 1.0

    Change the function call to:

    draw_bullseye(pixelbuf, image_width, image_height, (2 * xoffset), (2 * yoffset), scaler * 10);

    and the implementation to:

    void draw_bullseye(char pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) {
    / Central bullseye in Maxicode symbols */
    float x = 14.5 * scaler;
    float y = 15.0 * scaler;
    if(scaler < 10)
    {
    x = 16.0 * scaler;
    y = 16.5 * scaler;
    }
    
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (4.571 * scaler) + 1, '1');
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (3.779 * scaler) + 1, '0');
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.988 * scaler) + 1, '1');
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (2.196 * scaler) + 1, '0');
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (1.394 * scaler) + 1, '1');
    draw_circle(pixelbuf, image_width, image_height, x + xoffset, y + yoffset, (0.602 * scaler) + 1, '0');
    }
    

    and it will work. The 1.0 scale seems to target 12 pixels resolution. I need 8 pixels resolution and therefore I use the scale 0.667

    The implementation I included supports this, but I don't know if it will work for other resolutions like 10 or 6 etc.

     
  • Harald Oehlmann

    Harald Oehlmann - 2019-09-02
    • status: closed --> pending
     
  • Harald Oehlmann

    Harald Oehlmann - 2019-09-02

    Committed. Is this ok ?
    Thank you,
    Harald

     
  • REMID

    REMID - 2019-09-04

    Hello Harald,

    This is not ok.

    using command line :

    zint -o toto.png --esc --filetype=PNG -b 57 --primary='070940000840090' -d '[)>\R01\G961Z92338169\GUPSN\G1729X7\R07ZV./1Q% \G8B'\''A-ACTH/ HL+%"2J,\rTVMOZ(YZ42&K3$S\r\R\E'

    I got segmentation error.

    During the build we got warning on draw_bullseye() function

    char *pixelbuf ; the star is missing

    Regards,

    Rémi

     
  • Robin Stuart

    Robin Stuart - 2020-03-29

    This seems to now work without issue. Can this ticket be closed?

     
  • codemonkey82

    codemonkey82 - 2020-03-30

    Yes, it works fine for me. The ticket can be closed. Thanks!

     
  • Robin Stuart

    Robin Stuart - 2020-04-01
    • status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB