主题:作图模式下任何显示12*12汉字
52free
[专家分:0] 发布于 2005-09-06 04:34:00
谢谢jtchang老师提供作图模式下显示16*16汉字,但是使用上12*12比16*16结构更美观
我使用jtchang老师提供的HZK12汉字库,依照16*16的代码改写 但是不能显示出12*12的汉字,请教12*12是不是还有什么技巧,最好能提供算法,先谢谢了``
相关帖子:
http://www.programfan.com/club/showbbs.asp?id=14025
回复列表 (共2个回复)
沙发
jtchang [专家分:5370] 发布于 2005-09-06 11:26:00
(* UCDOS 12*12 fonts display demo.
Need file: HZK12 to run.
display Chinese in graphics mode.
programmed by jtchang.
*)
program chinese;
uses crt,graph;
Label aaa;
var
gd,gm,q,w,x,y,ErrCode:integer;
s:string;
ch:char;
function inttostr(n:integer):string;
var
s:string;
begin
s:='';
repeat
s:=chr(ord('0')+n mod 10)+s;
n:=n div 10;
until n=0;
inttostr:=s;
end;
procedure putone(x,y:integer;s:string;color:integer);
type
chinesep=array[1..24] of byte;
var
a:chinesep;
f:file of chinesep;
i,j,x0,y0,p:integer;
k:byte;
q,w:longint;
begin
q:=ord(s[1])-160;
w:=ord(s[2])-160;
q:=(q-1)*94+(w-1);
assign(f,'HZK12') ;
reset(f);
if (q<0) or (q>=filesize(f)) then
begin
close(f);
exit;
end;
seek(f,q);
read(f,a);
close(f);
y0:=y;
x0:=x;
for i:=1 to 24 do
begin
k:=a[i];
if i mod 2=1 then p:=8 else p:=4;
for j:=1 to p do
begin
if k and 128 <> 0 then putpixel(x0,y0,color);
x0:=x0+1;
k:=k shl 1;
end;
if i mod 2=0 then
begin
x0:=x;
y0:=y0+1;
end;
end;
end;
procedure outchinese(x,y:integer;s:string;blank:integer; color:integer);
var
temps:string;
k:integer;
begin
k:=1;
while k<length(s) do
begin
temps:=s[k]; k:=k+1;
temps:=temps+s[k]; k:=k+1;
putone(x+(k div 2-1)*(13+blank),y,temps,color);
end;
end;
begin
gd:=detect;
initgraph(gd,gm,'');
ErrCode:=graphresult;
if ErrCode<>grOK then
begin
Writeln('Graphics error: ', GraphErrorMsg(ErrCode));
exit;
end;
setbkcolor(blue);
outchinese(205,150,'汉字显示演示程序',3,RED+8);
outchinese(120,200,'演示中按任意键继续,按ESC退出',4,RED+8);
outchinese(280,350,'jtchang编程',0,RED+8);
ch:=readkey;
cleardevice;
x:=10; y:=5;
for q:=1 to 89 do
for w:=1 to 94 do
begin
if w=1 then setcolor(RED+8)
else setcolor(7);
s:=inttostr(q div 10)+inttostr(q mod 10);
s:=s+inttostr(w div 10)+inttostr(w mod 10);
moveto(x,y+6);
outtext(s);
s:=chr(q+160)+chr(w+160);
outchinese(x+40,y,s,0,yellow);
x:=x+70;
if x>580 then
begin
x:=10;
y:=y+30;
end;
if y+16>479 then
begin
ch:=readkey;
if ch=#27 then goto aaa;
x:=10;y:=5;
cleardevice;
end;
end;
ch:=readkey;
cleardevice;
outchinese(200,200,'所有汉字显示完毕!',8,RED+8);
ch:=readkey;
aaa:
closegraph;
end.
板凳
52free [专家分:0] 发布于 2005-09-07 03:01:00
明白了,谢谢老师!
我来回复