Click here to Skip to main content
12,550,449 members (45,158 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


13 bookmarked

BarcodeLib – ported to Compact Framework

, 28 Apr 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
CodeProject: Barcode Image Generation Library ported to Compact Framework

I got a request for a barcode image generator for Windows Mobile. Fortunately there are some libs out there including the source code and I decided to test to port barcodelib by Brad Barnhill hosted at the famous CodeProject site here.

How Was It Done

I downloaded the code, started a new SmartDevice Class Library project in VS2005 and copied the source files into the project dir and started adding the existing code files. I did not start with the original project files, as they were created with VS2008 and used the full framework in version 3.5.

After some builds, code changes, adding conditional compiles and one cfhelper class, the class compiled fine for Compact Framework 2. I had to remove (conditional compile options) most of the BarcodeXML stuff, as these are not? portable that easily to CF2.

            using (Pen pen = new Pen(ForeColor, iBarWidth))
#if !WindowsCE
                pen.Alignment = PenAlignment.Right;
                while (pos < Encoded_Value.Length)
                    if (Encoded_Value[pos] == '1')
#if !WindowsCE
                        g.DrawLine(pen, new Point(pos * iBarWidth + shiftAdjustment, 0), 
			new Point(pos * iBarWidth + shiftAdjustment, Height));
                        cfHelper.myDrawLine(g, pen, new Point(pos * iBarWidth + 
			shiftAdjustment, 0), new Point(pos * iBarWidth + 
			shiftAdjustment, Height));

and here is my helper:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace BarcodeLib
    static class cfHelper
        public static void myDrawLine(Graphics g, Pen p, Point p1, Point p2)
            g.DrawLine(p, p1.X, p1.Y, p2.X, p2.Y);

Then I added a BarcodeLibTest smart device Windows Application project using the new BarcodeLib and was able to get barcodes printed on screen and save the images to files.

<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionRe: about the QR barcode generator Pin
steve7g12-Jan-12 15:58
membersteve7g12-Jan-12 15:58 
AnswerPhone 7 compatibilty Pin
hjgode12-Jan-12 17:46
memberhjgode12-Jan-12 17:46 
QuestionWill this work on Windows Phone 7? Pin
Rohan Madtha26-Dec-10 20:39
memberRohan Madtha26-Dec-10 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 28 Apr 2010
Article Copyright 2010 by hjgode
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid