-
Notifications
You must be signed in to change notification settings - Fork 0
/
ALL2BMP.PAS
150 lines (132 loc) · 4.14 KB
/
ALL2BMP.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
program LNtoBMP;
uses bmp, crt, graph, dos;
var
device : integer;
mode : integer;
ch : char;
bmpfile : string;
lnfile : string;
xsize : integer;
ysize : integer;
lineoftext: string[80];
dir : searchrec;
{--------------------------------------------------------------------------}
procedure graph_init(var gdriver,gmode:integer;gpath:string);
var
error : integer;
begin
writeln;
DetectGraph(gdriver,gmode);
gdriver:=vga;
gmode:=vgahi;
initgraph(gdriver,gmode,gpath);
error:=graphresult;
if not(error=grOK)then
begin
writeln('Graphics initialization error!');
writeln('Program cannot continue. Press enter.');
readln;
halt(1);
end;
end;
{--------------------------------------------------------------------------}
function GetLNSizeX(dosname:string):integer;
var
pasfile : text;
size : integer;
col : integer;
color : integer;
length : integer;
begin
size:=0;
assign(pasfile,dosname);
reset(pasfile);
readln(pasfile,lineoftext);
if(lineoftext='FORMAT=LINE')then
while not eoln(pasfile) do
begin
read(pasfile,color);
read(pasfile,ch);
read(pasfile,length);
if not eoln(pasfile) then read(pasfile,ch);
size:=size + length;
end;
close(pasfile);
getlnsizex:=size;
end;
{--------------------------------------------------------------------------}
function GetLNSizeY(dosname:string):integer;
var
pasfile : text;
size : integer;
begin
size:=0;
assign(pasfile,dosname);
reset(pasfile);
readln(pasfile,lineoftext);
if(lineoftext='FORMAT=LINE')then
while not eof(pasfile) do
begin
readln(pasfile);
size:=size + 1;
end;
close(pasfile);
getlnsizey:=size;
end;
{--------------------------------------------------------------------------}
procedure DRAWPICTUREBYLINE(beginx,beginy:integer;dosname:string);
{dosname = name of the file, including extention
beginx, beginy = the coordinates of where the upper left hand corner
of where the picture will be.}
var
pasfile : text;
row : integer;
col : integer;
color : integer;
length : integer;
begin
assign(pasfile,dosname);
reset(pasfile);
readln(pasfile,lineoftext);
if(lineoftext='FORMAT=LINE')then
begin
row:=beginy;
col:=beginx;
while not eof(pasfile) do
begin
while not eoln(pasfile) do
begin
read(pasfile,color);
read(pasfile,ch);
read(pasfile,length);
if not eoln(pasfile) then
read(pasfile,ch);
setcolor(color);
line(col,row,(col+length),row);
col:=col + length;
end;
readln(pasfile);
row:=row + 1;
col:=beginx;
end;
end;
close(pasfile);
end;
{--------------------------------------------------------------------------}
begin
findfirst('*.ln1',0,dir);
while (doserror=0) do
begin
lnfile:=dir.name;
bmpfile:='OUT\'+copy(lnfile,1,pos('.',lnfile))+'BMP';
xsize:=getlnsizex(lnfile);
ysize:=getlnsizey(lnfile);
graph_init(device,mode,'c:\tp\bgi');
cleardevice;
DRAWPICTUREBYLINE(1,1,lnfile);
save_bmp(1,1,xsize,ysize,bmpfile,1);
closegraph;
findnext(dir);
end;
findclose(dir);
end.