主题:如何将运行pascal 得到的图象例如太极图保存到文本文件
mingtongling
[专家分:0] 发布于 2009-08-25 12:32:00
请高手指点,如何把pascal运行得到的图象(例如在Graph window Application 中显示的静态图像)保存下来,存放到文本文件中。动态图像又该如何保存。谢谢!
下边是我运行的太极图,如何修改才能把运行得到的太极图保存到(文本)文件
中。
uses graph,math;
procedure GraphIni;
var Gd, Gm: Integer;
begin
Gd := Detect;
InitGraph(Gd, Gm, ' ');
if GraphResult <> grOk then
Halt(1);
end;
function f(t,r:extended):extended;
begin
exit((cos(t-r)-sin(t)) * (r**4-2*r**2*cos(2*t+2.4)+0.9)+(0.62*r)**1000);
end;
var
i,j,Gd,Gm:integer;
t,r:extended;
begin
graphini;
setcolor(white);
for i:=0 to 1000 do
for j:=0 to 1000 do
begin
t:=(2*pi)*i/1000;
r:=2*j/1000;
if f(t,r)<0 then
PutPixel(round(cos(t)*r*100)+300,round(sin(t)*r*100)+200,15)
end;
readln;
CloseGraph;
end.
最后更新于:2009-08-27 17:52:00
7 楼
小田甜 [专家分:3910] 发布于 2009-08-31 22:51:00
我没看懂你的**是什么意思(FP编译器没过)
如果可以,你参考一下我的[url=http://bbs.pfan.cn/post-286315.html]天津麻将[/url]中的SCRPRINT.PAS
这个仅限16色的屏幕,我不知道再FP下会出现什么情况。
procedure ScreenPrint(path:string);
const
FileHead:array [1..118] of byte=(
$42,$4D,$76,$58,$02,$00,$00,$00,$00,$00,$76,$00,$00,$00,$28,$00,
$00,$00,$80,$02,$00,$00,$E0,$01,$00,$00,$01,$00,$04,$00,$00,$00,
$00,$00,$00,$58,$02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$80,$00,$00,$80,
$00,$00,$00,$80,$80,$00,$80,$00,$00,$00,$80,$00,$80,$00,$80,$80,
$00,$00,$80,$80,$80,$00,$C0,$C0,$C0,$00,$00,$00,$FF,$00,$00,$FF,
$00,$00,$00,$FF,$FF,$00,$FF,$00,$00,$00,$FF,$00,$FF,$00,$FF,$FF,
$00,$00,$FF,$FF,$FF,$00);
colortable:array [0..15] of byte
=($0,$4,$2,$6,$1,$5,$3,$8,$7,$C,$A,$E,$9,$D,$B,$F);
var
f:file of byte;
i,j:word;
c1,c2:byte;
begin
setcolor(7);
assign(f,path);rewrite(f);
for i:=1 to 118 do write(f,filehead[i]);
for i:=0 to 479 do begin
for j:=0 to 639 do begin
c1:=getpixel(j,getmaxy-i);c1:=colortable[c1];
c2:=getpixel(j+1,getmaxy-i);c2:=colortable[c2];
j:=j+1; c1:=c1*16+c2;
write(f,c1);
end;
end;
close(f);
end;