发布网友 发布时间:2022-04-25 22:10
共1个回答
热心网友 时间:2022-06-18 00:41
方法1:
printer.Canvas.strechDraw(s,Image1.Picture.Bitmap);
procere TForm1.BtnPringClick(Sender: TObject);
var
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
begin
if DIGPrint.execute then
begin
temhi:=imgpic.picture.height;
temwd:=imgpic.picture.width;
while (temhi = printer.pageheight div 2)and
//将图形放大到打印页面的1/2大小
(temwd = printer.pagewidth div 2) do
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left := (printer.pagewidth -temwd) div 2;
top := (printer.pageheight-temhi) div 2;
right := left+temwd;
bottom := top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,imgpic.picture.graphic);
enddoc;
end;
end;
end;
procere TForm1.Button1Click(Sender: TObject);
begin
if DLGOpen.Execute then
begin
IMGPic.Picture.LoadFromFile(DlgOpen.FileName);
end;
end;
procere TForm1.BtnCloseClick(Sender: TObject);
begin
Close;
end;
end.
方法2:
uses Printers;
procere TForm1.Button1Click(Sender: TObject);
var
R: TRect;
begin
Printer.BeginDoc;
try
R := Rect(0,0,Image1.Picture.Width,Image1.Picture.Height);//请先在Image1里面载入图片。
Printer.Canvas.StretchDraw(R, Image1.Picture.Graphic);
finally
Printer.EndDoc;
end;
end;