如何把汉字及图片转换成点阵数据,放入51系统的单片机中!(200分)

  • 主题发起人 主题发起人 jxpxlee
  • 开始时间 开始时间
J

jxpxlee

Unregistered / Unconfirmed
GUEST, unregistred user!
帮忙如何把汉字及图片转换成点阵数据,放入51系统的单片机中!
如:
;yhi=41--shen
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,32,15,128,0,28,48,252,192;
db 0,30,59,240,224,0,15,63,224,240,0,15,127,243,240,0,31,126,255,240;
db 0,62,241,63,0,0,120,225,60,0,0,129,254,60,0,0,129,206,62,0;
db 1,129,143,30,0,1,192,158,30,0,1,192,30,120,0,1,224,31,240,0;
db 1,224,29,255,0,1,224,15,255,192,0,224,31,255,192,0,192,127,240,0;
db 0,193,255,240,0,0,193,255,240,0,0,197,255,112,0,0,204,255,240,0;
db 0,204,15,254,0,0,204,28,127,192,0,204,28,127,240,0,220,56,115,252;
db 0,252,240,112,126,0,252,224,112,31,0,253,200,112,7,0,124,132,112,0;
db 0,60,6,112,0,0,24,3,240,0,0,8,1,224,0,0,0,1,224,0;
db 0,0,0,224,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0;
;xwi=40--zhen
;yhi=41
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,14,0,32,0,0,15,0,56,0,0,15;
db 0,28,0,0,14,0,28,0,0,14,0,28,0,0,14,0,28,0,0,78,0,31,0,0,140;
db 0,31,140,56,140,0,127,142,124,156,0,255,159,93,28,3,254,30,157,28;
db 15,252,30,158,28,7,248,28,158,28,3,248,29,30,28,1,248,29,28,28;
db 0,56,29,28,24,0,57,30,60,24,0,51,28,60,24,0,127,28,124,24;
db 0,255,28,124,24,3,254,28,120,24,7,248,24,120,28,7,240,56,120,28;
db 7,192,120,48,28,3,128,112,48,28,2,0,112,0,28,0,0,96,0,28;
db 0,0,64,0,28,0,0,0,0,92,0,0,0,0,124,0,0,0,0,124,0,0,0,0,60;
db 0,0,0,0,60,0,0,0,0,24,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0;
 
取点颜色进行判断,今天我刚做一个取字模的.
 
没有颜色之分的,就是个点,不是0就是1的这种。帮忙
 
汉字可以用当年的UCDOS的字库呀,就是HZK16.dat这个文件,就是用点阵存储的,字体大小:16x16,至于读取方法嘛,网上一大堆,我就不用写出来了
图片要复杂一些,肯定要进行取点颜色判断的,因为相当于要把一张彩色图转换成一张黑白图片,才能使用0或1进行存储
 
偶有完整代码!先给分,再在QQ里传给你。
这里给个片段:
case ActivedEditor.SelText[1] of
#$20 : begin
ActivedEditor.CopyToClipboard;
if Clipboard.HasFormat(CF_PICTURE) or
Clipboard.HasFormat(CF_BITMAP) or
Clipboard.HasFormat(CF_METAFILEPICT)
then
begin
Pic := TPicture.Create ;
Pic.Assign(Clipboard) ;
PicX := Round(Pic.Width/Pic.Height*LineHeight.Value) ;
BMP.Canvas.StretchDraw(Rect(0,0,PicX,LineHeight.Value),Pic.Graphic) ;
Pic.Free ;
end ;
end ;
#$21..#$FF : begin
SelText := ActivedEditor.SelText ;
Bmp.Canvas.Font.Style := ActivedEditor.SelAttributes.Style ;
Bmp.Canvas.Font.Name := ActivedEditor.SelAttributes.Name ;
if Abs(ActivedEditor.SelAttributes.Height)<LineHeight.Value
then
Bmp.Canvas.Font.Height := ActivedEditor.SelAttributes.Height
else
Bmp.Canvas.Font.Height := -LineHeight.Value ;
if (Bmp.Canvas.TextHeight(SelText)>LineHeight.Value) and
(Bmp.Canvas.Font.Size>10)
then
Bmp.Canvas.Font.Size := Bmp.Canvas.Font.Size - 1 ;
Bmp.Canvas.TextOut(0,-Offset.Value,SelText) ;
end ;
end ;
 
var hzk16: file of char;
i: array[1..32] of char;
j: longint;
k: string;
count: longint;
n: integer;
sss: string;
stemp: string;
begin
assignfile(hzk16, 'hzk16');
//assignfile(hzk16,'hzk24h');
FileMode := 0;
reset(hzk16);
k := edit1.text;
j := ((ord(k[1]) - 161) * 94 + (ord(k[2]) - 161)) * 32;
seek(hzk16, j);
memo2.text := '';

n := 1;
sss := '';
for count := 1 to 32do
begin
read(hzk16, i[n]);
stemp := inttohex(ord(i[n]), 2) + 'H';
if ((n mod 8) <> 0) then
stemp := stemp + ',';
if stemp[1] > '9' then
stemp := '0' + stemp;
sss := sss + stemp;
if n mod 8 = 0 then
sss := sss + char(13) + char(10);
n := n + 1;
end;
memo2.text := sss;
system.close(hzk16);

end;

HZK16.dat这个文件放到同一目录下
 
多人接受答案了。
 
可以加下我QQ吗? 10257657,深圳的最好!有酬谢
 
这么厉害.....
 
后退
顶部