Interleaved 2 of 5 Barcode Creator

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,495
edited 2015-01-15 in Download section
Interleaved 2 of 5 Barcode Creator
Barcode is generated to ostream, so can be used as a picture in reports. No fonts needed - data is written directly as a bitmap.
BMP header is simplified - can be adjusted depending on your needs (look BMP specs).

Use at your own risk :)

http://www.mibuso.com/dlinfo.asp?FileID=1185

Discuss this download here.

Comments

  • lyotlyot Member Posts: 202
    Hi,

    I think this is a wonderful solution! =D>
    No more hassle with fonts, automation, external programs, ...

    Since I'm using the bmp piece of code myself for other barcodes, I was wondering if there's a solution to scale the bmp?
  • Igor_PchelnikovIgor_Pchelnikov Member Posts: 25
    Hey,
    for the scale - you might check wiki link and adjust all the stuff you need. This code is very simplified, w/o any pro stuff, so you can do whatever you want there :D
    Use BMP header adjustment and also manual scaling for BMP bars writing (in repeat clause).
    (Don't forget about height/width proportions for barcodes, for example 128 barcode height should be at least 15% of it's width and so on, all this stuff is also available in this example and easy to adjust).

    This basis can be also used for other barcodes implementation, such as 128,39,93 and so on. Just use it's logic and fill up bigtext variable with 0/1 (space/bar) and vuala :whistle:

    Igor
  • lyotlyot Member Posts: 202
    I'm almost there (I guess..)
    What do the 2 lines do who are marked with the comment '//?' ?
    charInf := 'B' ;
    poutBmpHeader.WRITE(charInf, 1);
    charInf := 'M' ;
    poutBmpHeader.WRITE(charInf, 1);
    poutBmpHeader.WRITE(54 + pintRows * pintCols * 3 , 4); //SIZE BMP
    poutBmpHeader.WRITE(0, 4); //APPLICATION SPECIFIC
    poutBmpHeader.WRITE(54, 4); //OFFSET DATA PIXELS
    poutBmpHeader.WRITE(40, 4); //NUMBER OF BYTES IN HADER FROM THIS POINT
    poutBmpHeader.WRITE(pintCols, 4); //WIDTH PIXEL
    poutBmpHeader.WRITE(pintRows, 4); //HEIGHT PIXEL
    poutBmpHeader.WRITE(65536 * 24 + 1, 4); //?
    poutBmpHeader.WRITE(0, 4); //NO. OF COLOR PANES & BITS PER PIXEL
    poutBmpHeader.WRITE(0, 4);  //?
    poutBmpHeader.WRITE(2835, 4); //HORIZONTAL RESOLUTION
    poutBmpHeader.WRITE(2835, 4); //VERTICAL RESOLUTIONETTE
    poutBmpHeader.WRITE(0, 4); //NO. OF COLORS IN PALETTE
    poutBmpHeader.WRITE(0, 4); //IMPORTANT COLORS
    
  • Igor_PchelnikovIgor_Pchelnikov Member Posts: 25
    First is the color depth of the image:
    65536*24 + 1 = 180001 (Hex) -> that means 1 plane is used and 24 bits per pixel.
    Second is the size of BMP data - that's not FILE SIZE. Can be left blank (header is simplified, but it's better to calculate it), but you can also calculate it pvRows * pvCols * 3.

    Hope it helps.
    Igor
  • lyotlyot Member Posts: 202
    This is the result when I increase the size x5 (takes about 5 sec to build :| ):


    This is the result when I increase the size x2


    Any idea when the 2nd one looks so crooked?
  • Igor_PchelnikovIgor_Pchelnikov Member Posts: 25
    Hello,
    that depends where have you increased the size :) As from picture I can see that there are difference in bytes (tail bytes are not filled properly), You have somewhere mistake in repeat clause.
    Paste the source here, and what is the barcode type here?
    Also why d'you need such big barcodes? :)

    Igor
  • lyotlyot Member Posts: 202
    Found it!
    It were indeed the trail bytes.

    The reason I want to scale the barcodes is to use in reports.
    There I import the resulting Blob in a picturebox.
    Since the bmp is shown in the resolution it was made, it can apear pretty small in some reports where it needs to be for example 1/2 of the page.

    Once again many thanx and thumbs up for the brilliant idea!
    =D>
  • markborgesmarkborges Member Posts: 136
    Hello,

    I just wanted to congratulate the developer Igor Pchelnikov for this wonderful solution. I'm here in Argentina, doing the Electronic Invoice and they require this exactly standard.

    I implemented this on my system and it's working perfectly!

    Congratulations again!

    Best regards, =D> =D> =D>
    Marcelo Borges
    New York, NY, U.S.A.
    Dynamics NAV Consultant
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Guys, Thanks for sharing this solution.

    Can you please update this thread with the detailed solution for scaling? As an ERP developer I am not realy used to bits and bytes.

    Thanks again.
  • zannaleerzannaleer Member Posts: 5
    Thank you for this wonderful solution.
    It works perfectly.

    I had a little problem with this codeunit when I've called it twice or more.
    The bitmap growed with every call. I've solved it with this code
    CLEAR(gvBinary);
    
    in the function CreateBarcode.
  • lyotlyot Member Posts: 202
    zannaleer wrote:
    Thank you for this wonderful solution.
    It works perfectly.
    My pleasure
    zannaleer wrote:
    I had a little problem with this codeunit when I've called it twice or more.The bitmap growed with every call. I've solved it with this code
    Strange, I don't have that problem...
    zannaleer wrote:
    CLEAR(gvBinary);
    
    in the function CreateBarcode.
    This line makes NAV crash... I supose you mean CreateBarcodedetail?
  • jordi79jordi79 Member Posts: 272
    First of all, Great Solution, and thanks to Igor Pchelnikov.

    However, in NAV2013R2, the generated barcode bmp is grey and black and not white and black.

    I did try in NAV2009, and I got the barcode correctly in white and black.

    I compared the bmp file created in NAV2009 and NAV2013R2, and they are different. Somehow NAV2013R2 must have written the text file in a different format resulting in a different bmp file.

    Jordi
  • jordi79jordi79 Member Posts: 272
    Somehow for NAV2013R2, the RGB code for white is not 255, it is 160. Just replace the RGB code of 255 with 160 to get White.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Anyone using it now in production? do you have an example with scaling?

    If you are not using it because of problems or are not sure how it would work in production, what do you use?
  • Rikt-ItRikt-It Member Posts: 37
    We are using it in production for more than one year. In Nav2013 and it's white and gray, we have to adjust that...
    Regards
    Christer in Stockholm, Sweden
  • jordi79jordi79 Member Posts: 272
    We are going to use it for production. Not sure what you mean by scaling.
  • HI,aapr7g34v4mo.png
    i am using the same code unit .
    but my barcode is printing in black and gray.
    how can i change it in to black and white ..?
  • danielbouwmeesterdanielbouwmeester Member Posts: 22
    Hi all, I'm using this code to print barcodes to product labels, but now a specific label is needed on which the barcode is rotated 90 degrees. Is this possible?! Thanks in advance!
    "Make it idiot-proof and someone will invent a better idiot..."
Sign In or Register to comment.