Hola, tengo un procedimiento para evitar el aliasing de las imagenes, pero solo me funciona al cargar imagenes bmp y resulta que lo necesito solo para imagenes jpg. He intentado adaptarlo pero no se como hacerlo. Me da un error de 'scan line index out of rande' en la linea SL1 := bmp1.ScanLine[0];
Alguien puede orientarme sobre como hacerlo.
Gracias
Código Delphi
[-]procedure TForm1.Image2Click(Sender: TObject);
begin
Antialiasing(image1.Picture.Bitmap, Image2.Picture.Bitmap);
end;
function TForm1._NewColor3(X, Y: integer; SL1, SL2,
SL3: PRGBTripleArray): TColor;
var
r1,g1,b1:Integer;
r2, g2,b2:Integer;
r3, g3,b3:Integer;
r4, g4,b4:Integer;
r5, g5,b5:Integer;
r6, g6,b6:Integer;
r7, g7,b7:Integer;
r8, g8,b8:Integer;
r9, g9,b9:Integer;
i:Integer;
begin
Result := RGB(R1,G1,B1);
end;
procedure TForm1.Antialiasing(bmp1, bmp2:TBitmap);
var
r1,g1,b1:Integer;
Y, X, j:integer;
SL1, SL2, SL3: PRGBTripleArray;
begin
bmp2.Height := bmp1.Height;
bmp2.Width := bmp1.Width;
SL1 := bmp1.ScanLine[0];
SL2 := bmp1.ScanLine[1];
SL3 := bmp1.ScanLine[2];
for Y := 1 to (bmp1.Height - 2) do begin
for X := 1 to (bmp1.Width - 2) do begin
R1 := 0; G1 := 0; B1 := 0;
for j := -1 to 1 do begin
R1 := R1 + SL1[X+j].rgbtRed + SL2[X+j].rgbtRed + SL3[X+j].rgbtRed;
G1 := G1 + SL1[X+j].rgbtGreen + SL2[X+j].rgbtGreen + SL3[X+j].rgbtGreen;
B1 := B1 + SL1[X+j].rgbtBlue + SL2[X+j].rgbtBlue + SL3[X+j].rgbtBlue;
end;
R1:=Round(R1 div 9);
G1:=Round(G1 div 9);
B1:=Round(B1 div 9);
bmp2.Canvas.Pixels[X, Y] := RGB(R1,G1,B1);
end;
SL1 := SL2;
SL2 := SL3;
SL3 := bmp1.ScanLine[Y+1];
end;
end;