Salut à tous,
Je travaille actuellement avec le composant TGraphXY de Kénavo. J'ai besoin de pouvoir l'imprimer en noir et blanc, j'utilise donc ce code là :
procedure TForm1.Print_BtClick(Sender: TObject);
Var
Img:TImage;
BitMap:TBitMap;
BcCl,GdCl,Cl:TColor;
Rect:TRect;
begin
If not PrinterSetupDialog1.Execute then Exit;
BitMap:=TBitMap.Create;
BitMap.Width:=Graph.Width;
BitMap.Height:=graph.Height;
With Graph Do
Begin
BcCl:=BackColor;
GdCl:=GridColor;
Cl:=Color;
BackColor:=ClWhite;
GridColor:=ClBlack;
Color:=ClBlack;
Graph.PaintTo(BitMap.Canvas,0,0);
BackColor:=BcCl;
GridColor:=GdCl;
Color:=Cl;
End;
try
With Printer Do
Begin
Rect.Left:=(Width-BitMap.Width) Div 2;
Rect.Right:=Rect.Left+BitMap.Width;
Rect.Top:=(height-BitMap.height) Div 2;
Rect.Bottom:=Rect.Top+BitMap.Height;
Img:=TImage.Create(nil);
Img.Picture.Bitmap.Assign(BitMap);
While Img.Picture.Bitmap.Empty Do
Application.ProcessMessages;
BeginDoc;
Canvas.StretchDraw(Rect,Img.Picture.Bitmap);
EndDoc;
Img.Free;
End;
Except
Showmessage('Imprimante absnete ou autre erreur');
End;
BitMap.Free;
End;
Malheureusement j'obtient une magnifique page blanche : Si quelqu'un a une idée du pourquoi du comment ?
Merci
@+