Bonjour
Dans ce code qui permet de tapisser le fond du form3 avec une image repetée autant de fois que necessaire, le bitmap est chargé depuis C.
Je souhaiterais le telecharger depuis un Timagelist sur le form1.
C est la premiere fois que je manipule une image, je pense avoir fait correctement mais cela ne fonctionne pas comme desiré :
Code initial
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 procedure TForm3.FormPaint(Sender: TObject); var Bitmap: TBitmap; Left, Top: Integer; begin Bitmap := TBitmap.Create; Try Bitmap.LoadFromFile('C:\bg_clair.bmp'); Left := 0; while Left < Width do begin Top := 0; while Top < Height do begin Canvas.Draw(Left, Top, Bitmap); inc(Top, Bitmap.Height); end; inc(Left, Bitmap.Width); end; Finally Bitmap.Free; End; end;
code modifié
Ici, c est bien l image 0 de ma list_bg que je veux recuperer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 procedure TForm3.FormPaint(Sender: TObject); var Bitmap: TImage; Left, Top: Integer; begin Bitmap := TImage.Create(self); Try form1.list_bg.GetBitmap(0, Bitmap.Picture.Bitmap); Left := 0; while Left < Width do begin Top := 0; while Top < Height do begin Canvas.Draw(Left, Top, Bitmap.Picture.Bitmap); inc(Top, Bitmap.Height); end; inc(Left, Bitmap.Width); end; Finally Bitmap.Free; End; end;
L un d entre vous pourrait m expliquer où est mon erreur et comment y remdier.
merci de votre aide
Partager