So könnte es funktionieren:
Delphi-Quellcode:
function BitmapFromBitmap(bm: TBitmap; r: TRect): TBitmap;
begin
Result := TBitmap.Create;
Result.Height := Succ(r.Bottom - r.Top);
Result.Width := Succ(r.Right - r.Left);
with Result.Canvas do
CopyRect(ClipRect, bm.Canvas, r);
end;
procedure TDemoForm.ButtonClick(Sender: TObject);
var
bm: TBitmap;
r: TRect;
begin
bm := BitmapFromWinControl(self);
r := ClientRect;
InflateRect(r, - bm.Height div 4, - bm.Width div 4);
with BitmapFromBitmap(bm, r) do
begin
SaveToFile('Demo.bmp');
Free;
end;
bm.Free;
end;
Freundliche Grüße