Registriert seit: 24. Apr 2003
Ort: Neumarkt Stmk
892 Beiträge
Delphi XE6 Enterprise
|
Re: Antialiasing
11. Sep 2003, 13:05
Wahnsinn was das gebracht hat.
Danke Leute
Hier der neue Algo
Delphi-Quellcode:
procedure Antialiasing(Bitmap: TBitmap; Rect: TRect; Percent: Integer);
var
pix, prevscan, nextscan, hpix: ^PixArray;
l, p: Integer;
R, G, B: Integer;
R1, R2, G1, G2, B1, B2: Byte;
begin
Bitmap.PixelFormat := pf24bit;
with Bitmap.Canvas do begin
Brush.Style := bsclear;
for l := Rect.Top to Rect.Bottom - 1 do begin
pix:= Bitmap.ScanLine[l];
if l <> Rect.Top then prevscan := Bitmap.ScanLine[l-1]
else prevscan := nil;
if l <> Rect.Bottom - 1 then nextscan := Bitmap.ScanLine[l+1]
else nextscan := nil;
for p := Rect.Left to Rect.Right - 1 do begin
R1 := pix^[3];
G1 := pix^[2];
B1 := pix^[1];
if p <> Rect.Left then begin
//Pixel links
//Pixel left
hpix := pix;
dec(hpix);
R2 := hpix^[3];
G2 := hpix^[2];
B2 := hpix^[1];
if (R1 <> R2) or (G1 <> G2) or (B1 <> B2) then begin
R := R1 + (R2 - R1) * 50 div (Percent + 50);
G := G1 + (G2 - G1) * 50 div (Percent + 50);
B := B1 + (B2 - B1) * 50 div (Percent + 50);
hpix^[3] := R;
hpix^[2] := G;
hpix^[1] := B;
end;
end;
if p <> Rect.Right - 1 then begin
//Pixel rechts
//Pixel right
hpix := pix;
inc(hpix);
R2 := hpix^[3];
G2 := hpix^[2];
B2 := hpix^[1];
if (R1 <> R2) or (G1 <> G2) or (B1 <> B2) then begin
R := R1 + (R2 - R1) * 50 div (Percent + 50);
G := G1 + (G2 - G1) * 50 div (Percent + 50);
B := B1 + (B2 - B1) * 50 div (Percent + 50);
hpix^[3] := R;
hpix^[2] := G;
hpix^[1] := B;
end;
end;
if prevscan <> nil then begin
//Pixel oben
//Pixel up
R2 := prevscan^[3];
G2 := prevscan^[2];
B2 := prevscan^[1];
if (R1 <> R2) or (G1 <> G2) or (B1 <> B2) then begin
R := R1 + (R2 - R1) * 50 div (Percent + 50);
G := G1 + (G2 - G1) * 50 div (Percent + 50);
B := B1 + (B2 - B1) * 50 div (Percent + 50);
prevscan^[3] := R;
prevscan^[2] := G;
prevscan^[1] := B;
end;
Inc(prevscan);
end;
if nextscan <> nil then begin
//Pixel unten
//Pixel down
R2 := nextscan^[3];
G2 := nextscan^[2];
B2 := nextscan^[1];
if (R1 <> R2) or (G1 <> G2) or (B1 <> B2) then begin
R := R1 + (R2 - R1) * 50 div (Percent + 50);
G := G1 + (G2 - G1) * 50 div (Percent + 50);
B := B1 + (B2 - B1) * 50 div (Percent + 50);
nextscan^[3] := R;
nextscan^[2] := G;
nextscan^[1] := B;
end;
Inc(nextscan);
end;
Inc(pix);
end;
end;
end;
end;
Noch kurz eine Frage zu den Scanlines:
scanline^[3] ist Rot
scanline^[2] ist Grün
scanline^[1] ist Blau
Sehe ich das richtig?
Daniel
|
|
Zitat
|