I create a Bitmap in this way:
function Control2Bitmap(Control_: TWinControl): TBitmap;
begin
Result := TBitmap.Create;
with Result do begin
Height := Control_.Height;
Width := Control_.Width;
Canvas.Handle := CreateDC(nil, nil, nil, nil);
Canvas.Lock;
Control_.PaintTo(Canvas.Handle, 0, 0);
Canvas.Unlock;
DeleteDC(Canvas.Handle);
end;
end;
procedure TFormMain.tbtnGetPicGridClick(Sender: TObject);
var
ThisBitmap: TBitmap;
begin
ThisBitmap := Control2Bitmap(FlowPanel);
CodeSite.Send('TFormMain.tbtnGetPicGridClick: ThisBitmap', ThisBitmap);
ImageEnView1.Bitmap.Assign(ThisBitmap);
ThisBitmap.ReleaseHandle;
ThisBitmap.Free;
end;
But the image looks distorted (although ImageEnView1.LegacyBitmap = True):
How can I get a clean bitmap?