-
Notifications
You must be signed in to change notification settings - Fork 4
/
rwaqb.pas
85 lines (72 loc) · 1.81 KB
/
rwaqb.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
unit rwaqb;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,LazFileUtils,rmcodegen,rmxgfcore;
Function WriteAQBBitMapCodeToFile(x,y,x2,y2 : integer;filename:string):word;
Function WriteAQBBitMapCodeToBuffer(Var F : Text;x,y,x2,y2 : integer;imagename:string):word;
function nColorsToBitPlanes(nColors : integer) : integer;
implementation
function nColorsToBitPlanes(nColors : integer) : integer;
var
BP : integer;
begin
BP:=0;
Case nColors of 2:BP:=1;
4:BP:=2;
8:BP:=3;
16:BP:=4;
32:BP:=5;
64:BP:=6;
128:BP:=7;
256:BP:=8;
end;
nColorsToBitPlanes:=BP;
end;
Function WriteAQBBitMapCodeToBuffer(Var F : Text;x,y,x2,y2 : integer;imagename:string):word;
var
width,height : integer;
Depth : integer;
size : longword;
mc : CodeGenRec;
i,j : integer;
PixelColor : integer;
begin
MWInit(mc,F);
MWSetLan(mc,BasicLan);
MWSetValuesPerLine(mc,20);
MWSetValueFormat(mc,ValueFormatHex);
width:=x2-x+1;
height:=y2-y+1;
depth:=nColorsToBitPlanes(GetMaxColor+1);
Size:=width*height;
MWSetValuesTotal(mc,Size);
writeln(F,#39,' Amiga AQB BitMap Image, Size= ', Size,' Width= ',width,' Height= ',height, ' Depth= ',depth);
writeln(F,#39,' ',Imagename);
For j:=0 to height-1 do
begin
for i:=0 to width-1 do
begin
PixelColor:=GetPixel(i,j);
MWWriteByte(mc,PixelColor);
end;
end;
writeln(f);
WriteAQBBitMapCodeToBuffer:=IORESULT;
end;
Function WriteAQBBitMapCodeToFile(x,y,x2,y2 : integer;filename:string):word;
var
F : Text;
Imagename : string;
begin
SetCoreActive;
Imagename:=ExtractFileName(ExtractFileNameWithoutExt(filename));
Assign(F,filename);
{$I-}
Rewrite(F);
WriteAQBBitMapCodeToBuffer(F,x,y,x2,y2,imagename);
Close(F);
{$I+}
WriteAQBBitMapCodeToFile:=IORESULT;
end;
end.