Bonjour,
avec la fonction Polygon, je dessine un polygone rempli d'un motif à l'écran chargé depuis un bmp - tout se passe bien - le dessin est correct
je fais la même chose vers une imprimante PDF, mais la dans le fichier PDF le fond du polygone reste blanc
j'ai essayé plein de choses sans succès (propriété du bmp transparent, changement de brosse, ...)
Pourtant, avec la fonction Draw mon Bmp s'affiche bien dans les deux cas.
Voici mon code :
dessin du polygone :
affichage à l'écran :
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
24
25
26
27
28
29
30
31 { =============================================================== } procedure TF_Princ.Dessine(Canvas1 : TCanvas ; LDess , HDess : Integer); { Affiche le dessin sur un canvas } Var bmp : tBitMap; begin Canvas1.Pen.Color := clBlack ; Canvas1.brush.Color := clWhite ; Canvas1.brush.Style := bsSolid ; // Affichage du fond blanc pour effacer un dessin précédent Canvas1.Rectangle( 0,0, LDess, HDess) ; // recupération d'un motif depuis un fichier Bmp bmp := tBitMap.create; bmp.LoadFromFile(ExtractFilePath(Application.ExeName)+'motif1.bmp'); // Dessin du Bmp par Draw : fonctionne à l'écran et aussi sur imprimante PDF Canvas1.Draw(200,200,bmp); // Remplissage d'un polygone par le motif du Bmp // Fonctionne à l'écran mais pas sur imprimante PDF // (le fond du polygone est blanc) Canvas1.brush.Bitmap :=bmp; Canvas1.Polygon([Point(10, 10), Point(60, 280), Point(230, 30), Point(540, 720)]); // Libération des objets Canvas1.brush.Bitmap := Nil ; bmp.free; end; { =============================================================== }
envoi vers l'imprimante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 { =============================================================== } procedure TF_Princ.Btn_DessinClick(Sender: TObject); { Dessine à l'écran } Var LDess, HDess : Integer ; begin Panel_Dessin.Update ; Plan.Update ; LDess := Plan.Width ; HDess := Plan.Height; Dessine(Plan.Canvas , LDess, Hdess) ; end; { =============================================================== }
Savez vous pourquoi cela ne fonctionne pas dans le PDF ?
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 { =============================================================== } procedure TF_Princ.Btn_ImprimerClick(Sender: TObject); { Impression du dessin } var HDess, LDess : Integer ; begin Printer.Orientation := poLandscape; if PrintDialog1.Execute then begin with Printer do begin BeginDoc; LDess := Printer.PageHeight ; HDess := Printer.PageWidth ; Dessine(Printer.Canvas, HDess, LDess) ; EndDoc; end; end; end; { =============================================================== }
Merci par avance
Charly
Partager