[Windows] Problème d'impression d'image
Bonjour à tous
Lors de l'impression d'image sous windows , message 'erreur d'impression' alors que lors d'impression de texte pas de problème.
j'ai les paquets cairocanvas_pkg, printers4lazide, printerlazarus dans l'inspecteur de projet
Code:
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, printers,osprinters,Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
Scale: double;
image1:graphics.Tbitmap;
RR: TRect;
begin
image1:=graphics.Tbitmap.Create;
image1.LoadFromFile('d:\test.bmp');
with Printer do
begin
BeginDoc;
try
scale := Printer.PageWidth / image1.Width;
RR := Rect(0, 0, trunc(Image1.Width * scale), trunc(Image1.Height * Scale));
canvas.StretchDraw(RR, Image1);
finally
EndDoc;
end;
end;
end;
end. |