位图反走样Bitmap.Canvas.Pixels[x,y] Bitmap.ScanLine[y]
提示:这里可以添加技术概要
核心源码
`
public
{ Public declarations }
procedure AntiAliasPicture;
procedure FastAntiAliasPicture;
end;
var
AntiAliasForm: TAntiAliasForm;
const
MaxPixelCount = 32768;
type
pRGBArray = ^TRGBArray;
TRGBArray = array[0…MaxPixelCount - 1] of TRGBTriple;
implementation
{$R *.DFM}
var
orig_bmp, big_bmp, out_bmp: TBitmap;
procedure TAntiAliasForm.SeparateColor(color: TColor;
var r, g, b: Integer);
begin
r := Byte(color);
g := Byte(color shr 8);
b := Byte(color shr 16);
end;
procedure TAntiAliasForm.AntiAliasPicture;
var
x, y: integer;
totr, totg, totb, r, g, b: integer;
i, j: integer;
begin
for y := 0 to orig_bmp.Height - 1 do
begin
for x := 0 to orig_bmp.Width - 1 do
begin
totr := 0;
totg := 0;
totb := 0;
for i := 0 to 2 do
begin
for j := 0 to 2 do
begin
SeparateColor(big_bmp.Canvas.Pixels[(x * 3) + j, (y *
3) + i], r, g, b);
totr := totr + r;
totg := totg + g;
totb := totb + b;
end;
end;
out_bmp.Canvas.Pixels[x, y] := RGB(totr div 9,
totg div 9,
totb div 9);
end;
end;
end;
procedure TAntiAliasForm.FastAntiAliasPicture;
var
x, y, cx, cy: integer;
totr, totg, totb: integer;
Row1, Row2, Row3, DestRow: pRGBArray;
i: integer;
begin
for y := 0 to orig_bmp.Height - 1 do
begin
cy := y *