Depends where the image you want to insert is in bCan
.
Let's say it's in a directory, you can use the command bCan.LoadFromFile
Take a look at the variations of the command LoadFrom...
of TBitmap
Edit:
Take a look, and see if this is right for you:
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
btnPosicionarImagem: TButton;
btnCarregarImagem: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnPosicionarImagemClick(Sender: TObject);
procedure btnCarregarImagemClick(Sender: TObject);
private
Image: TBitmap;
Canvas: TControlCanvas;
procedure CarregarImagemBitmap;
procedure PosicionarPainel;
procedure CarregarImagemCanvas;
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
Image := TBitmap.Create;
Canvas := TControlCanvas.Create;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
FreeAndNil(Canvas);
FreeAndNil(Image);
end;
procedure TForm2.CarregarImagemBitmap;
begin
Image.LoadFromFile('C:\executaveis_01_256x256.bmp');
end;
procedure TForm2.PosicionarPainel;
begin
Panel1.Width := Image.Width;
Panel1.Height := Image.Height;
Panel1.Left := Random(100);
Panel1.Top := Random(100);
end;
procedure TForm2.CarregarImagemCanvas;
begin
Canvas.Control := Panel1;
BitBlt(Canvas.Handle, 0, 0, Image.Width, Image.Height, Image.Canvas.Handle, 0, 0, SRCCOPY);
end;
procedure TForm2.btnPosicionarImagemClick(Sender: TObject);
begin
CarregarImagemBitmap;
PosicionarPainel;
end;
procedure TForm2.btnCarregarImagemClick(Sender: TObject);
begin
CarregarImagemCanvas;
end;
end.