Swelio on GitHub

The source code of Swelio library – the freeware Belgian eID cards access library is available now on GitHub:

https://github.com/perevoznyk/swelio-sdk

Advertisements

C# Zip library

After the announcement about closing Codeplex, I moved my C# Zip library to GitHub: https://github.com/perevoznyk/karna-compression

Many of today’s applications require the capability of extracting certain files from a ZIP archive, either onto the hard disk or into memory.

Info-ZIP is an Open Source version of Phil Katz’s “deflate” and “inflate” routines used in his popular file compression program, PKZIP. Info-ZIP code has been incorporated into a number of third-party products as well, both commercial and freeware. It offers two dynamic link libraries: one for zipping, and one for unzipping.

The Info-ZIP DLLs are free to use and distribute, but they are designed to be used in C/C++ projects, so they’re not really .NET-friendly. Also, the Info-ZIP package contains almost no documentation showing how to use the Info-ZIP DLLs.

Therefore, I decided to write a small C# wrapper that provides all the required data types and functions in order to give the possibility to work with the Info-ZIP API.

More information about the Info-ZIP project can be found on Info-ZIP’s home site: www.info-zip.org.

 

Swelio 1.5 – Freeware Belgian eID card SDK

The new release of Swelio – freeware Belgian eID card SDK is available for download.

Whats new in this release:

* Fixed some bugs in C++ code
* Updated C++ documentation
* Added Delphi documentation
* Added Microsoft .NET binding

The C# source code of the .NET binding included. The library supports AnyCPU, x86 and x64 projects. It is compatible with .NET Framework 2.0 – 4.5 and tested with all Windows versions starting from Windows XP.
The provided assembly was compiled for .NET Framework 2.0 using Microsoft Visual Studio 2008, but the project can be easily upgraded to the more recent versions of the .NET Framework and Visual Studio. It was done to cover more possible configuration, because the downgrade of the Visual Studio project is not possible. The sample project is also provided.

Please leave your comments or write a review to help me improve the quality and functionality of the Swelio SDK. If you found a bug – please report it to me using the contact form. The future requests from the active testers will be treated with higher priority.

Download Swelio SDK

EIDNative library version 3.0 is released

EIDNative – the Belgian eID card access library version 3.0 is available for download: http://sdrv.ms/1jsEPAc
Now it supports x64 and x32 Windows and can be used from Windows XP to Windows 8. This is the last release of the EIDNative library and it will be not updated in the future, because I made the new more advanced and powerful library for reading electronic id cards and the new library will replace EIDNative.

Quricol 2.0 – QR Code generator

The version 2.0 of Quricol – the open source freeware QR code generator library is available for download. 

Downloadhttp://users.telenet.be/ws36637/download/quricol.zip 

  • Based on qrencode library version 3.4.2
  • Added Visual Studio project file and external libraries for easy rebuild of quricol.dll. This was asked by Carlos Gutierrez
  • Added possibility to specify the background and foreground colors of the image
  • Removed reference to qrencode.h from quricol.h header file. Now you have to include only one header file to your C++ project
  • Updated Delphi library, included new demo project
  • Compatible with Ansi and Unicode Delphi versions
  • Can be used with 32 and 64 bit Delphi projects
  • Updated Delphi documentation

Krento becomes Open Source

The time has come for KRENTO to be released as open source.You can find the source code on Google Code site: https://github.com/perevoznyk/krento
After 4 years of hard work I understood that I can’t continue the development of such a big project alone. I hope that other developers will show the interest of giving the boost to this project.
More information about Krento project is available on http://users.telenet.be/serhiy.perevoznyk/krento.html

Quricol – QR code generator library

Quricol is an open source freeware QR code generator library for C++, Microsoft .NET and Delphi based on qrencode – QR Code encoder by Kentaro Fukuchi.The library contains methods to save the generated image to Bitmap or PNG file or generate images on-fly and save it to the stream. Both 32 and 64 bits compiled versions available along with source code.

Download: http://users.telenet.be/ws36637/download/quricol.zip

A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional code).

Update 11.09.2013:

Quricol 2.0 is available for download. More information about this version on http://delphi32.blogspot.com/2013/09/quricol-20-qr-code-generator.html

Generate Excel files without using Microsoft Excel (Part 2)

After publishing my article on CodeProject I received a lot of questions how to change the font, alignment or color of the cells in the resulting Excel file. I improved the code of the ExcelWriter library and added the possibility to format cells. You can download the new release of the ExcelWriter library here: http://users.telenet.be/serhiy.perevoznyk/download/XLSExportDemo.zip

Update from 31 Jan. 2012:
This code is provided to show the possibility of easy export of the information to Excel files, not to manipulate existing Excel files or performing the complex formatting operations. The aim of this demo is to make the export easy and simple. In case if you do more complex tasks I can recommend to use another library, for example http://www.smartxls.com/index.htm. I do not have any plans to extend the provided code in the future.

namespace XLSExportDemo
{
class Program
{
static void Main(string[] args)
{

ExcelDocument document = new ExcelDocument();
document.UserName = "Perevoznyk";
document.CodePage = CultureInfo.CurrentCulture.TextInfo.ANSICodePage;

document.ColumnWidth(0, 120);
document.ColumnWidth(1, 80);

document[0, 0].Value = "ExcelWriter Demo";
document[0 ,0].Font = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold);
document[0, 0].ForeColor = ExcelColor.DarkRed;
document[0, 0].Alignment = Alignment.Centered;
document[0, 0].BackColor = ExcelColor.Silver;

document.WriteCell(1, 0, "int");
document.WriteCell(1, 1, 10);

document.Cell(2, 0).Value = "double";
document.Cell(2, 1).Value = 1.5;

document.Cell(3, 0).Value = "date";
document.Cell(3, 1).Value = DateTime.Now;
document.Cell(3, 1).Format = @"dd/mm/yyyy";

FileStream stream = new FileStream("demo.xls", FileMode.Create);

document.Save(stream);
stream.Close();
}
}
}

Code 39 barcode in C#

Some time ago I published the EAN 13 barcode generator source code. Now in addition to it made I simple Code 39 generator.

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

namespace Karna.Barcode
{
public class Code39
{
static readonly string star = "*";
private Image image;
private string barcodeId;
private int width;
private int height;


public Code39(Image image)
{
this.image = image;
this.width = 210;
this.height = 146;
}

public int Width
{
get { return this.width; }
set { this.width = value; }
}

public int Height
{
get { return this.height; }
set { this.height = value; }
}

public string BarcodeId
{
get { return barcodeId; }
set
{
if (value == null)
return;

if (!value.StartsWith(Code39.star))
{
value = Code39.star + value;
}

if (!value.EndsWith(Code39.star))
{
value = value + Code39.star;
}

barcodeId = value;

char encChar;

StringBuilder sb = new StringBuilder();

for (int i = 0; i < value.Length; i++)
{
if (sb.Length > 0)
{
sb.Append('0');
}

encChar = value[i];

switch (encChar)
#region Char Table
{
case '0': sb.Append("101001101101");
break;
case '1': sb.Append("110100101011");
break;
case '2': sb.Append("101100101011");
break;
case '3': sb.Append("110110010101");
break;
case '4': sb.Append("101001101011");
break;
case '5': sb.Append("110100110101");
break;
case '6': sb.Append("101100110101");
break;
case '7': sb.Append("101001011011");
break;
case '8': sb.Append("110100101101");
break;
case '9': sb.Append("101100101101");
break;
case 'A': sb.Append("110101001011");
break;
case 'B': sb.Append("101101001011");
break;
case 'C': sb.Append("110110100101");
break;
case 'D': sb.Append("101011001011");
break;
case 'E': sb.Append("110101100101");
break;
case 'F': sb.Append("101101100101");
break;
case 'G': sb.Append("101010011011");
break;
case 'H': sb.Append("110101001101");
break;
case 'I': sb.Append("101101001101");
break;
case 'J': sb.Append("101011001101");
break;
case 'K': sb.Append("110101010011");
break;
case 'L': sb.Append("101101010011");
break;
case 'M': sb.Append("110110101001");
break;
case 'N': sb.Append("101011010011");
break;
case 'O': sb.Append("110101101001");
break;
case 'P': sb.Append("101101101001");
break;
case 'Q': sb.Append("101010110011");
break;
case 'R': sb.Append("110101011001");
break;
case 'S': sb.Append("101101011001");
break;
case 'T': sb.Append("101011011001");
break;
case 'U': sb.Append("110010101011");
break;
case 'V': sb.Append("100110101011");
break;
case 'W': sb.Append("110011010101");
break;
case 'X': sb.Append("100101101011");
break;
case 'Y': sb.Append("110010110101");
break;
case 'Z': sb.Append("100110110101");
break;
case '-': sb.Append("100101011011");
break;
case '.': sb.Append("110010101101");
break;
case ' ': sb.Append("100110101101");
break;
case '$': sb.Append("100100100101");
break;
case '/': sb.Append("100100101001");
break;
case '+': sb.Append("100101001001");
break;
case '%': sb.Append("101001001001");
break;
case '*': sb.Append("100101101101");
break;
default:
break;
}
#endregion
}

string drawString = sb.ToString();

Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
Graphics canvas = Graphics.FromImage(bitmap);
canvas.Clear(Color.White);

canvas.SmoothingMode = SmoothingMode.HighQuality;
canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
canvas.PixelOffsetMode = PixelOffsetMode.HighQuality;
canvas.CompositingQuality = CompositingQuality.HighQuality;

int length = drawString.Length;
int start = 0;
int final = 0;
int count = 0;

while (start < length)
{

while (final < length)
{
if (drawString[final] == '1')
{
final++;
}
else
{
break;
}
}

count = final - start;

if (count > 0)
{
RectangleF bounds = new RectangleF(0, 0, bitmap.Width, bitmap.Height);
RectangleF rect = bounds;
rect.X += bounds.Width * start / length;
rect.Width = bounds.Width * count / length;
canvas.FillRectangle(Brushes.Black, rect);
}

while (final < length)
{
if (drawString[final] == '0')
{
final++;
}
else
{
break;
}
}

start = final;
}

if (image != null)
{
Graphics g = Graphics.FromImage(image);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
g.DrawImage(bitmap, 0, 0, image.Width, image.Height);
g.Dispose();
}

canvas.Dispose();
}
}
}
}