Hi there everyone!
I made a simplest example which must to draw a square on the BGRABitmap (I don't use layers for this case). Then, when mouse moves over the PaintBox component the line with mouse coordinates must to erase parts of the square, then put this bitmap layer (with transprency) on another layer (with white background) and then it together puts on the PaintBox.Canvas. The problem is the EraseLineAntialias procedure works only once, when the form is created, it erases one line of the square, but it don't work when the mouse is moved over the PaintBox. Here is the code:
var
Form1: TForm1;
mainLayer: TBGRABitmap;
resultLayer: TBGRABitmap;
OriginX, OriginY: Integer;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
mainLayer:= TBGRABitmap.Create(256,256,BGRAPixelTransparent);
mainLayer.FillRect(20,20,100,100,BGRA(255,0,0),dmDrawWithTransparency);
mainLayer.EraseLineAntialias(0,0,100,100,255,3,true); // It works here!!!
resultLayer:= TBGRABitmap.Create(256,256,clWhite);
resultLayer.PutImage(0,0,mainLayer,dmDrawWithTransparency);
resultLayer.Draw(PaintBox1.Canvas,0,0,false);
end;
procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
mainLayer.EraseLineAntialias(OriginX,OriginY,x,y,255,3,true); //It don't works here!!!
OriginX:=x;
OriginY:=y;
resultLayer.PutImage(0,0,mainLayer,dmDrawWithTransparency);
resultLayer.Draw(PaintBox1.Canvas,0,0,false);
//Label1.Caption:='x: '+IntToStr(x)+' y: '+IntToStr(y) ;
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
mainLayer.Free;
resultLayer.Free;
end;