RSS Feed  August 28th, 2008

Paint.NET - Barcode Plugin

Added: March 15th, 2007 (tagged with: coding, paintdotnet)

Sepcot.com Encoded with Code 39
'Sepcot.com' Encode with Code 39

Version 1.0.0 of my Paint.NET Barcode Plugin is completed. Note: I do not have access to a barcode reader and have not checked the validity of the barcodes, but they should be accurate =)

Also, barcodes are rectangular. You will not get very good results if you use this plugin in non-rectangular selections.

Screen Shots

Barcode Configuration Dialog v1.0.0 Barcode Configuration Dialog with Error v1.0.0

Features

Supported Characters

Code 39 and Code 39 mod 43 support the use of the following characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%

Full ASCII Code 39 supports the use of all ASCII (control and printable) characters.

Text Validation Code:

public static bool validateText(String text, int encoding)
{
    bool passedInspection = true;

    if (encoding == Barcode.CODE_39 || encoding == Barcode.CODE_39_MOD_43)
    {
        passedInspection = Regex.Match(text.ToUpperInvariant(), "^[A-Z0-9-\\.\\$/\\+%\\s]+$").Success;
    }
    else if (encoding == Barcode.FULL_ASCII_CODE_39 && 0 != text.Length)
    {
        for (int lcv = 0; lcv < text.Length; lcv++)
        {
            if ((int)text[lcv] < 0 && (int)text[lcv] > 127)
            {
                passedInspection = false;
            }
        }
    }
    else
    {
        passedInspection = false;
    }

    return passedInspection;
}

For Code 39 and Code 39 mod 43, we have a short set of valid characters. To ensure text validity, I perform a Regular Expression match to see if the text is valid.

For Full ASCII Code 39, control and printable characters are in the valid character set. To ensure validity, I check to see if the integer value of each character falls within the 0-127 range.

Files (v1.1.x)

Resources

Related Posts

© 2006 - 2008 Michael J. Sepcot - michael (dot) sepcot (at) gmail (dot) com