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

После 4 лет упорной работы я пришел к выводу что дальнейшая разработка Krento силами одного человека становится невозможной. Поэтому я опубликовал исходный код Krento на сайте Google Code: https://code.google.com/p/krento
Я надеюсь, что с помощью энтузиастов этот проект получит дальнейшее успешное развитие.
Дополнительную информацию о проекте можно найти на http://users.telenet.be/serhiy.perevoznyk/krento.html

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://code.google.com/p/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();
}
}
}
}

Windows Magnification API .NET

The Magnification API provides assistive technology vendors with the means for developing screen magnification applications for Windows Vista and later operating systems.The API enables you to display a simple control that magnifies a specified portion of the display by a specified factor. Images as well as text are displayed.
Unfortunately, Microsoft provided only native C++ API functions without .NET equivalent, so I decided to make a simple .NET wrapper in C#.
The full C# source code is available for download: http://users.telenet.be/serhiy.perevoznyk/download/Magnification.zip 

The magnification class is based on native Windows API calls. Here is a small excerpt from the library sources:

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Karna.Magnification
{

internal static class NativeMethods
{

public const string WC_MAGNIFIER = "Magnifier";

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern int GetSystemMetrics(int nIndex);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr SetTimer(IntPtr hWnd, int nIDEvent, int uElapse, IntPtr lpTimerFunc);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool KillTimer(IntPtr hwnd, int idEvent);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetClientRect(IntPtr hWnd, [In, Out] ref RECT rect);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);

[DllImport("user32.dll", EntryPoint = "CreateWindowExW", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public extern static IntPtr CreateWindow(int dwExStyle, string lpClassName, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lParam);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, LayeredWindowAttributeFlags dwFlags);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string modName);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(ref POINT pt);

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InvalidateRect(IntPtr hWnd, IntPtr rect, [MarshalAs(UnmanagedType.Bool)] bool erase);

[DllImport("Magnification.dll", CallingConvention=CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagInitialize();

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagUninitialize();

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagSetWindowSource(IntPtr hwnd, RECT rect);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagGetWindowSource(IntPtr hwnd, ref RECT pRect);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagSetWindowTransform(IntPtr hwnd, ref Transformation pTransform);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagGetWindowTransform(IntPtr hwnd, ref Transformation pTransform);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagSetWindowFilterList(IntPtr hwnd, int dwFilterMode, int count, IntPtr pHWND);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int MagGetWindowFilterList(IntPtr hwnd, IntPtr pdwFilterMode, int count, IntPtr pHWND);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagSetColorEffect(IntPtr hwnd, ref ColorEffect pEffect);

[DllImport("Magnification.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MagGetColorEffect(IntPtr hwnd, ref ColorEffect pEffect);
}
}