|
FAQ: TBarCode DLL | | | | | | FAQ TBarCode DLL: How to use Custom Drawing (Callback) in VB, drawing to bitmap-DC and scaling to screen-DC, QR code Kanji Compaction Mode... | | |
Callback Functions | | I would like to have a memory zone, who contains the whole pixel map of the barcode.Instead of drawing directly you can build your own data structure (e.g. a Pixel map) during Callback. You can pass a custom pointer to the Callback function and use this pointer to add the pixel pattern to your structure (in a format as desired).
First set the pointer to your structure or memory block with this function:
BCSetCBData(t_BarCode* pBarCode, LPVOID customData)
This pointer is handled to you in the Callback function:
ERRCODE CALLBACK CustomDrawRow(VOID* customData, t_BarCode* barcode,
HDC drawDC, HDC targetDC, DOUBLE x, DOUBLE y, DOUBLE width, DOUBLE height);
Now you can store the pattern info (row by row) into your own structure or memory block. After drawing has been finished you have it all in your structure. | |
Visual Basic Code Sample | | How to Use Custom Drawing (Callback) in VBTBarCode V6
'callback function
Public Function MyDrawRow ( ByRef pMyData As Long,
ByVal pBarCode As UIntPtr, ByVal hDC As IntPtr,
ByVal hTargetDC As IntPtr,
ByRef pRect As Rectangle) As UInt32
Dim strTempo As String
strTempo = TBC6.BCGetMetaData(pBarCode)
Return Convert.ToUInt32(0)
End Function
'setting the address of the callback function
Public cb As TBC6.Callback
cb = AddressOf MyDrawRow
eCode = TBC6.BCSetFuncDrawRow(hBarcode, cb, pData)
'required declarations
Declare Ansi Function BCDrawCB Lib "TBarCode6.ocx" ( _
ByRef hBarcode As UIntPtr, _
ByVal hDC As IntPtr, _
ByRef pRect As Rectangle, _
ByVal func As Callback, _
ByVal func As Callback, _
ByVal pData As IntPtr ) As Int32
Declare Ansi Function BCGetMetaData Lib "TBarCode6.ocx" ( _
ByVal hBarcode As UIntPtr ) As String
| |
C++ Code Sample | | Drawing to Bitmap-DC and Scaling to Screen-DC
DrawBarcode (HDC hDC, long xpos, long ypos)
{
RECT hRect;
long lHRHeight = 0;
ypos += GetFullHeight();
hRect.left = xpos;
hRect.top = ypos;
hRect.right = hRect.left + width;
hRect.bottom = hRect.top + height;
HDC memDC;
HBITMAP memBMP, oldBMP;
int width, height;
RECT draw;
width = abs(hRect.right - hRect.left);
height = abs (hRect.bottom - hRect.top);
draw.left = 0;
draw.bottom = height;
draw.top = 0;
draw.right = width;
memDC = CreateCompatibleDC(hDC);
memBMP = CreateCompatibleBitmap(hDC, width, height);
oldBMP = (HBITMAP) SelectObject(memDC, memBMP);
if (S_OK = BCDraw(pBarcode, memDC, &draw))
{
// scale / copy to target DC
BitBlt(hDC, hRect.left, hRect.top, width,
height, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, oldBMP);
}
DeleteObject(memBMP);
DeleteDC(memDC);
}
| |
Delphi | | Change Barcode Font Style in DelphiCreate a LOGFONT structure and set it with the BCSetLogFont function.
Function BCSetLogFont
(
const pBarCode:t_BarCode; // IN : Ptr To Barcode-Definition
lf:LOGFONT // IN : TLogFont (TFont) structure
):TErrCode;
external 'TBarCode8.dll';
Here is a sample of a LOGFONT structure. To adjust the font size, you must change the parameter lfHeight in the structure.
var
lf:TLogFont;
begin
lf.lfHeight := 24; {char height in pixels }
lf.lfWidth := 12; {char width in pixels }
lf.lfEscapement := 0; {orientation of next char }
lf.lfOrientation := 0; {orientation of first char}
lf.lfWeight := FW_NORMAL; {normal thickness }
lf.lfItalic := 0; {not italic characters }
lf.lfUnderline := 0; {not underlined characters}
lf.lfStrikeOut := 0; {not strikeout characters }
lf.lfCharSet := OEM_CHARSET;{OEM character set }
lf.lfOutPrecision := 0; {default output precision }
lf.lfClipPrecision := 0; {default clipping precision}
lf.lfQuality := DEFAULT_QUALITY; {default scaling quality}
lf.lfPitchAndFamily := FF_SCRIPT;{default pitch,
script font family }
lstrcpy(lf.lfFaceName,'Arial'+chr(0)); {script typeface}
For more information about LOGFONT visit http://msdn.microsoft.com/en-us/library/ms533931(VS.85).aspx | |
QR-Code | | Encoding Kanji Characters in QR Code Compaction ModeData for QR-Code can be treated either as a sequence of Bytes or as a sequence of SHIFT JIS characters.
Beside SHIFT JIS so-called “ECIs” can be used to switch to different Code-Pages - but ECIs are often unsupported by decoder software.
The default character set of QR-Code is Shift JIS according to AIM International ITS/97-001 QR Code Symbology Specification. In order to use the QR-Code Kanji Compaction Mode, the input for the encoder must be in a specific character set:
TBarCode DLL, TBarCode/X Library Version 7
Input must be in Multi Byte Character Set Format SHIFT JIS (not UTF-8, not Unicode!).
- Single Bytes characters are encoded according to JIS X 0201.
- Double Byte characters are encoded according to Shift JIS X 0208.
TBarCode DLL, TBarCode/X Library Version 8
Input must be in Unicode (UTF-16 in Windows Version and UTF-32/UCS-4 in Linux/UNIX Version).
Double Byte characters contained in the Shift JIS X 0208-1990 table can be compacted in QR-Code 13-Bit Mode. To enable the compaction in the TBarCode Library you have to call the function BCSet_QR_KanjiChineseCompaction ()
Only characters in the range of 0x8140 - 0x9ffc and 0xe040 - 0xeaa4 in the JIS X 0208 table can be compacted. Shift JIS would also support the Code Pages (High Byte) ED-EE / FA-FC, but this range is not supported by QR-Code compaction - these codes will be treated as normal Bytes.
Here are some links to background information about Kanji and Unicode:
| |
|
|
© TEC-IT Datenverarbeitung GmbH, Austria ++43(0)7252/72720 office@tec-it.com |
|
|