procedure TForm1.Button2Click(Sender: TObject);
var W,H:integer; C:TCanvas; BM2: TBitmap;
begin
W:=360; H:=360;
Panel2.Width := W;
Panel2.Height := H;
BM2 := TBitmap.Create;
BM2.Width := W;
BM2.Height := H;
C := BM2.Canvas;
C.Clear;
C.Brush.Color:= clGray;
C.FillRect(0,0,W,H);
C.AntialiasingMode:=amOn;
C.Pen.Color:=clRed;
C.Arc(20,20, 100, 100, 10,10,10,10);
C.Line(10,10, 10, 100);
C.Line(10,10, 100, 10);
C.Line(10,10, 100, 100);
Panel2.Canvas.Draw(0,0, BM2);
BM2.SaveToFile('test.png');
BM2.Free;
end;