📄 lattices.dpr
字号:
{*******************************************************************}
{ }
{ Chinese Lattices 16*16 Component Library }
{ Lattices.dll }
{ Version 1.0 }
{ }
{ Develop by 诸葛白痴、xwing、cqbaobao }
{ }
{ Support: hzg115@sina.com }
{ 如果您有更新这个版本,别忘了给我一份 }
{*******************************************************************}
library Lattices;
{
字模简介:
字模现有分成汇编字模和C格式字模之分,在此仅有C格式字模,根据点阵大小可分成12*12、
16*16、24*24等,在此仅讨论16*16
16*16的点阵中,格子大小为16*16,共有16行和16列,每一行一列总共有16个点,
每个点表示一个bit,一行共有16个位,共2位字节,一个16*16点阵的汉字用32个字节表示,
传统的取字模从hzk16等字库中直接取得其中的字模,但此种方法较为生硬,如遇到简繁体
中文问题就得换个字库文件,现用最方便是的在一个背景上画出文字,然后扫描其阵格,并
记录转换成字节;
取模又可分成横向、纵向取模,并且有左高位,右高位及上或下高位等分别
横向取模是指从阵格的左至右,从上至下取点,将每一行生成相邻的两个字节
_____X___X______
0000010001000000 如果是右高位的话排列将是0010 0000(左字节) 0000 0010(右字节),组合
字节就是$2002(字模的第一字节为20,第二字节为02)
如果是左高位的话排列将是0000 0100(左字节) 0100 0000(右字节),组合
字节就是$0440
纵向取模是指从阵格的上至下,从左至右取点,将每一列生成两个对称的字节
_
_ 0000010000000000 如果是下高位的排列将是0010 0000(上字节) 0000 0000(下字节),
_ 此处的字节不再向横向取模是相连的,字模的第一个字节为20,第17位字节为00
_ 如果是上高位的排列将是0000 0100(上字节) 0000 0000(下字节),
_ 此处的字节不再向横向取模是相连的,字模的第一个字节为04,第17位字节为00
X
_
_
_
_
_
_
_
_
_
_
以上的横纵取模是从下面这个文字中取得的:
0x04,0x40, _____X___X______
0x04,0x40, _____X___X______
0x7F,0xFC, _XXXXXXXXXXXXX__
0x04,0x40, _____X___X______
0x04,0x40, _____X___X______
0xFF,0xFE, XXXXXXXXXXXXXXX_
0x01,0x00, _______X________
0x1F,0xF0, ___XXXXXXXXX____
0x11,0x10, ___X___X___X____
0x1F,0xF0, ___XXXXXXXXX____
0x11,0x10, ___X___X___X____
0x11,0x10, ___X___X___X____
0x1F,0xF0, ___XXXXXXXXX____
0x08,0x20, ____X_____X_____
0x10,0x18, ___X_______XX___
0x60,0x08, _XX_________X___
}
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Graphics;
{$R *.res}
function GetChineseLattice(ChineseText: String; out LatticeData: array of char; Style: Integer): Boolean; stdcall;
{
Style: 0表示横向取模,从左至右,从上至下,字模排列顺序为高位在右,低位在左
1表示纵向取模,从上至下,从左至右,字模排列顺序为高位在下,低位在上
}
const
ary_i: array[0..15] of Integer = ($01,$02,$04,$08,$10,$20,$40,$80,
$100,$200,$400,$800,$1000,$2000,$4000,$8000); //存储点阵相关
var
bmp_Text: TBitmap;
c_temp: char;
w_temp: Word;
i,j: Integer;
cb:Byte;
begin
bmp_Text := TBitmap.Create; //创建背景扫描图
with bmp_Text do
begin
PixelFormat := pf8bit;
Width := 16;
Height := 16;
Canvas.Font.Name := '宋体';
Canvas.Font.Size := 12;
Canvas.Font.Color := clBlack;
Canvas.TextRect(Rect(0,0,16,16),0,0,ChineseText);
for i := 0 to 15 do //开始扫描
begin
w_temp := 0;
c_temp := char(0);
for j := 0 to 15 do
begin
if Style = 0 then //横向取模
cb := pbyte(Integer(ScanLine[i]) + j)^
else if Style = 1 then //纵向取模
cb := pbyte(Integer(ScanLine[j]) + i)^;
if cb = $00 then //$ff 取反
w_temp := ord(w_temp) or ary_i[j];
end;
if Style = 0 then
begin
c_temp := char(w_temp and $FF);
LatticeData[i * 2] := c_temp;
c_temp := char(w_temp shr 8);
LatticeData[i * 2 + 1] := c_temp;
end
else if Style = 1 then
begin
c_temp := char(w_temp and $FF);
LatticeData[i] := c_temp;
c_temp := char(w_temp shr 8);
LatticeData[16 + i] := c_temp;
end;
end;
Free;
end;
Result := true;
end;
exports
GetChineseLattice;
begin
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -