const
ssv = 8;
//8-Faches Super-Sampling
type
TFC =
packed record
r,g,b: Single;
end;
PFC = ^TFC;
procedure TForm1.Button1Click(Sender: TObject);
function Cut(ain: single): single;
begin
result := ain;
if result > 255
then
result := 255
else if result < 0
then
result := 0;
end;
var
bitmap: TBitmap;
re, im, rez, imz, rezold, col: Single;
a: boolean;
i, x, y: integer;
pmem: PFC;
ps: PFC;
pi: PInteger;
const
iterations = 100;
colchangevar = 1;
begin
bitmap := TBitmap.Create;
bitmap.PixelFormat := pf32bit;
bitmap.Width := Image1.Width;
bitmap.Height := Image1.Height;
GetMem(pmem, bitmap.Width * bitmap.Height * SizeOf(TFC));
ZeroMemory(pmem, bitmap.Width * bitmap.Height * SizeOf(TFC));
for y := 0
to (bitmap.height - 1) * ssv
do
begin
for x := 0
to (bitmap.width - 1) * ssv
do
begin
re := (x/bitmap.width/ssv)*4-2;
// mit Startwerten zoom = 4, move = -2
im := (y/bitmap.height/ssv)*4-2;
rez := 0;
imz := 0;
a := true;
for i := 0
to iterations
do
begin
if a
then
begin
rezold := rez;
rez := rez*rez-imz*imz+re;
imz := 2*rezold*imz+im;
if rez*rez+imz*imz > 4
then
a := false;
end;
end;
if not a
then
begin
ps := pmem;
inc(ps, (bitmap.Height) * trunc(y / ssv) + trunc(x/ssv));
col := (rez*rez+imz*imz)/4*colchangevar;
col := col+256*col+256*256+col;
ps^.r := ps^.r + GetRValue(Round(col));
ps^.g := ps^.g + GetGValue(Round(col));
ps^.b := ps^.b + GetBValue(Round(col));
end;
end;
end;
for y := 0
to (bitmap.height - 1)
do
begin
pi := bitmap.ScanLine[y];
for x := 0
to (bitmap.width - 1)
do
begin
inc(pi);
ps := pmem;
inc(ps, (bitmap.Height) * y + x);
pi^ :=
RGB(
Round(Cut(ps^.b / (ssv*ssv))),
Round(Cut(ps^.g / (ssv*ssv))),
Round(Cut(ps^.r / (ssv*ssv))));
end;
end;
Image1.Picture.Bitmap := bitmap;
end;