function readhor(start:integer;ending:integer;y:integer;bit:TBitmap):TBitMap;
var i:integer;
begin
Result:=TBitMap.create;
//geht das überhaupt? wenn nicht, muss mans halt mit var-params machen.
result.width:=start-ending;
result.height:=1;
if start <= ending
then
for i := start
to ending
do
result.canvas.pixels[i,0]:=bit.canvas.pixels[i,y]
else
for i := start
downto ending
do
result.canvas.pixels[i,0]:=bit.canvas.pixels[i,y];
//das ganze würde mit copyrect wohl sehr viel performanter...
end;
function readvert(start:integer;ending:integer;x:integer;bit:TBitmap):TBitMap;
var i:integer;
begin
Result:=TBitMap.create;
//geht das überhaupt?
result.height:=start-ending;
result.width:=1;
if start <= ending
then
for i := start
to ending
do
result.canvas.pixels[0,i]:=bit.canvas.pixels[y,i]
else
for i := start
downto ending
do
result.canvas.pixels[i,0]:=bit.canvas.pixels[i,y];
//das ganze würde mit copyrect wohl sehr viel performanter...
end;
procedure spiralize(bit:TBitmap);
var i:integer;
widthleft,widthstart:integer;
heightleft,heightstart:integer;
begin
widthleft:=bit.width;
heightleft:=bitmap.height;
widthstart:=0;
heightstart:=0;
while widthleft > 0
do
begin
//einmal rundherum
readhor(widthstart,widthleft-1,heightstart,bit);
//nach rechts...
inc(heightstart);
dec(heightleft);
readvert(heightstart,heightleft-1,widthleft-1,bit);
//...nach unten....
inc(widthstart);
dec(widthleft);
readhor(widthleft-1,widthstart,heightleft-1,bit);
//...nach links...
inc(heightstart);
dec(heightleft);
readvert(heightleft-1,heightstart,widthstart,bit);
//...und wieder zurück!
inc(widthstart);
dec(widthleft);
end;
end;