Chapter 7. Developing Application with QRCode Fonts & Encoder

Morovia QRCode Fontware & Writer SDK provides two distinct approaches when integrating with your application - a Windows encoder DLL and an image-based ActiveX. Depending on your programming environment, you may find one way easier than the other.

7.1. Common Issues

7.1.1. Color Types

The software supports RGB color space, with each component expressed in a byte. Windows programmers often deal with two types of color values: COLORREF and OLE_COLOR. The first type uses a 32-bit integer with the leading byte always empty. The second one use the most significant bit to indicate whether it is a system color and conversion is required. The two color types use the lower three bytes for B, G and R components respectively - note that the Red component is in the last byte.

Other platforms typically place the component values in the order of Red, Green and Blue. We adopts this format in our DLL interface. Therefore, the value of 0xff0000 indicates red color in our DLL, but blue to Windows if no translation is performed.

In QRCodeActiveX control, the color is represented as OLE_COLOR format, therefore no translation is required.

7.1.2. Version

In DLL and ActiveX Control, you can specify the size desired by setting a value to Version. If the value is 0, the program chooses the value that produces the smallest barcode possible. If the value specified is too small to encode all the data, the program increases the value automatically.

7.1.3. Error Codes

Error may occur during encoding process - for example, the data may exceed the maximum capacity allowed, and malformed structural append block or Kanji block may exist in the input. QRCode ActiveX control and encoder DLL return error code in COM-compliant way - with this code consisting of any information such as facility code.

Table 7.1. Error Codes

ValueHRESULTDescription
50x83290005Input is too long
60x83290006Invalid characters in input data
90x83290009Encoding problem. Try run again
100x8329000aFile access denied
110x8329000bOut of memory
120x8329000cOutput buffer size is too small
300x832901eInvalid length string
500x83290032Missing field in Structural Append block
520x83290034Invalid Sequence in Structural Append block
530x83290035Invalid TotalNum in Structural Append block
800x83290050Invalid Kanji block
810x83290051Invalid FNC1 second position block

DLL client can call exported function QRCodeGetErrorMessage to retrieve a text description on the error message.

COM client can retrieves IErrorInfo interface to the Error object, following the standard COM error protocol.

7.2. Windows Native DLL Interface

the file name of this dll is MoroviaQRCodeFontEncoder.dll, installed by default in the system directory c:\windows\system32. The Encoder GUI and Word AddIn calls this dll at the background for encoding.

Using DLL is convenient in many occasions because you do not need to register it. Instead it, just place the dll under the same directory as you exe.

7.3. ActiveX Control Interface (COM)

Writing a client application that creates and manipulates COM objects is quite straightforward and supported in many programming environments. We have included coding examples in C++, C# and Visual Basic 6. Investigate the examples we provided if you decide to use this approach.