home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
c
/
ctkit11.zip
/
SCSTUFF.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-10-05
|
7KB
|
269 lines
Function BitSizeOf (x, y: integer): word;
var
t: integer;
begin
if gd = 1 then
t := (x div 8 + 1)
else
t := (x div 8 + 1) * 2;
BitSizeOf := t * (y+1) + 3;
end;
Procedure SteToBit(var Size: word);
var
Bytes: array [1..2] of byte;
CurBytes: array[1..320] of byte;
x, y, n, b, count, at, g, across, plus, plus2, plus3, CinP, ecnt, ecnt1,
ecnt2, ecnt3, r, width, pig, togo: integer;
ybyte, temp0, temp1, temp2, temp3, tb0, tb1, tb2, tb3: byte;
c, d: cdtype;
tw, tw2: word;
begin
New (TPic);
Move (Pic^, TPic^, Size*2);
if tpic^[1] < 9000 then
begin
Dispose(TPic);
exit;
end;
FillChar (Pic^, SizeOf(Pic^), 0);
Pic^[1] := TPic^[3];
Pic^[2] := TPic^[4];
width := Pic^[1];
plus := width div 8 + 1;
plus2 := plus*2;
plus3 := plus*3;
n := 3;
if (gd = 1) and (gm = 4) then
begin
across := 0;
g := 7;
tw2 := 0;
For CinP := 5 to Size do
begin
tw := TPic^[Cinp];
if tw = 0 then
begin
inc(CinP);
Togo := TPic^[CinP];
Inc(CinP);
Move(TPic^[Cinp],Bytes,2);
end else begin
togo := 1;
Move(tw,Bytes,2);
end;
for tb0 := 1 to togo do
begin
for count := 1 to bytes[1] do
begin
tw2 := tw2 or (1 shl g);
dec(g);
if g = -1 then
g := 15;
inc(Across);
if Across > Width then
begin
Across := 0;
if ((g < 7) or (g=15)) and ((cinp <> size) or (count < bytes[1])) then
g := 15
else
g := 7;
end;
if g = 7 then
begin
Pic^[n] := tw2;
inc(n);
tw2 := 0;
end;
end;
for count := 1 to bytes[2] do
begin
{ tw2 := tw2 or 0; }
dec(g);
if g = -1 then
g := 15;
inc(Across);
if Across > Width then
begin
Across := 0;
if ((g < 7) or (g=15)) and ((cinp <> size) or (count < bytes[2])) then
g := 15
else
g := 7;
end;
if g = 7 then
begin
Pic^[n] := tw2;
inc(n);
tw2 := 0;
end;
end;
end;
end;
Size := (width div 16 + 1)*(Pic^[2]+1)+3;
Dispose (TPic);
exit;
end;
if gd = 1 then
begin
across := 0;
g := 6;
tw := 0;
togo := 0;
for CinP := 5 to Size do
begin
if togo > 0 then
begin
dec(togo);
dec(CinP);
end else begin
move (TPic^[CinP], Bytes, 2);
c[1] := bytes[2] shr 6;
c[2] := bytes[1] shr 6;
d[1] := bytes[2] mod 64;
d[2] := bytes[1] mod 64;
end;
if d[2] = 0 then
begin
togo := Bytes[2];
inc(CinP);
move (TPic^[CinP], Bytes, 2);
c[1] := bytes[2] shr 6;
c[2] := bytes[1] shr 6;
d[1] := bytes[2] mod 64;
d[2] := bytes[1] mod 64;
end;
for count := 1 to 2 do
for at := 1 to d[count] do
begin
if Across > width then
begin
Across := 0;
if g > 6 then
begin
Pic^[n] := tw;
inc(n);
tw := 0;
g := 6;
end else
if g < 6 then
g := 14;
end;
if g = -2 then
g := 14;
if c[count] > 0 then
tw := tw or (c[count] shl g);
Inc(Across);
dec(g);
dec(g);
if (g = 6) then
begin
Pic^[n] := tw;
inc(n);
tw := 0;
end;
end;
end;
end else begin
Across := plus2;
ybyte := 128;
b := 0;
ecnt := 1;
ecnt1 := plus+1;
ecnt2 := plus2+1;
ecnt3 := plus3+1;
tb0 := 0;
tb1 := 0;
tb2 := 0;
tb3 := 0;
for CinP := 5 to Size do
begin
togo := 1;
move (TPic^[CinP], Bytes, 2);
d[2] := Bytes[1] mod 16;
if d[2] = 0 then
begin
togo := Bytes[2] + 1;
Inc(CinP);
move (TPic^[CinP], Bytes, 2);
d[2] := Bytes[1] mod 16;
end;
c[1] := Bytes[2] shr 4;
d[1] := Bytes[2] mod 16;
c[2] := Bytes[1] shr 4;
repeat
dec(togo);
for count := 1 to 2 do
begin
{ temp0 := Colors[c[count],0];
temp1 := Colors[c[count],1];
temp2 := Colors[c[count],2];
temp3 := Colors[c[count],3]; }
temp0 := c[count] and 8;
temp1 := c[count] and 4;
temp2 := c[count] and 2;
temp3 := c[count] and 1;
for AT := 1 to d[count] do
begin
if ybyte = 0 then
begin
ybyte := 128;
CurBytes[ecnt] := tb0;
CurBytes[ecnt+plus] := tb1;
CurBytes[ecnt+plus2] := tb2;
CurBytes[ecnt+plus3] := tb3;
inc(ecnt);
{ inc(ecnt1);
inc(ecnt2);
inc(ecnt3); }
tb0 := 0;
tb1 := 0;
tb2 := 0;
tb3 := 0;
end;
if temp0=8 then
tb0 := tb0 or ybyte;
if temp1=4 then
tb1 := tb1 or ybyte;
if temp2=2 then
tb2 := tb2 or ybyte;
if temp3=1 then
tb3 := tb3 or ybyte;
ybyte := ybyte shr 1;
inc(b);
if b > width then
begin
{ CurBytes[ecnt] := tb0;
CurBytes[ecnt1] := tb1;
CurBytes[ecnt2] := tb2;
CurBytes[ecnt3] := tb3; }
CurBytes[ecnt] := tb0;
CurBytes[ecnt+plus] := tb1;
CurBytes[ecnt+plus2] := tb2;
CurBytes[ecnt+plus3] := tb3;
move (CurBytes, Pic^[n], Across*2);
b := 0;
ybyte := 128;
tb0 := 0;
tb1 := 0;
tb2 := 0;
tb3 := 0;
ecnt := 1;
{ ecnt1 := plus+1;
ecnt2 := plus2+1;
ecnt3 := plus3+1; }
n := n + across;
end;
end;
end;
until (togo = 0);
end;
end;
Size := BitSizeOf (width, Pic^[2]);
Dispose (TPic);
end;