Only now I understand what you actually asked, sorry.
I beleive that this is what you want:
uses
..., LCLIntf, LCLType;
...
procedure TForm1.Button2Click(Sender: TObject);
var
MyBitmap, MyBitmap2: TBitmap;
MyDC: HDC;
R: TRect;
begin
MyBitmap2 := TBitmap.Create;
MyBitmap := TBitmap.Create;
try
MyDC := GetDC(Self.Handle);
try
MyBitmap.LoadFromDevice(MyDC);
finally
ReleaseDC(Self.Handle, MyDC);
end;
R.TopLeft := Image1.BoundsRect.TopLeft;
R.BottomRight := Panel1.BoundsRect.BottomRight;
MyBitmap2.Width := R.Right - R.Left;
MyBitmap2.Height := R.Bottom - R.Top;
MyBitmap2.Canvas.CopyRect(Rect(0, 0, MyBitmap2.Width, MyBitmap2.Height),
MyBitmap.Canvas, R);
MyBitmap2.SaveToFile('ImageAndPanel.bmp');
finally
FreeAndNil(MyBitmap);
FreeAndNil(MyBitmap2);
end;
end;