图形打印 (100分)

  • 主题发起人 主题发起人 zyb158
  • 开始时间 开始时间
Z

zyb158

Unregistered / Unconfirmed
GUEST, unregistred user!
各位专家:
如何将canvas绘制的图形用DELPHI直接打印输出,用何控件,尽量详细些。
 
Try it:
{ Print a Bitmap using the whole Printerpage }
procedure PrintBitmap(ABitmap: TBitmap);
var
relheight, relwidth: integer;
begin
screen.cursor := crHourglass;
try
try
Printer.begin
Doc;
if ((ABitmap.width / ABitmap.height) > (printer.pagewidth /printer.pageheight)) then
begin
// Stretch Bitmap to width of Printerpage
relwidth := printer.pagewidth;
relheight := MulDiv(ABitmap.height, printer.pagewidth,ABitmap.width);
end else
begin
// Stretch Bitmap to height of Printerpage
relwidth := MulDiv(ABitmap.width, printer.pageheight, ABitmap.height);
relheight := printer.pageheight;
end;
DrawImage(Printer.Canvas, Rect(0, 0, relWidth, relHeight), ABitmap);
Printer.EndDoc;
except
Application.MessageBox('打印错误!','提示',MB_OK+MB_ICONERROR);
end;
finally
screen.cursor := crDefault;
end;
end;
 
Delphi多媒体编程一书上有的是源代码,买本看看,
由于代码太长不发给你了
 
procedure TForm1.Button1Click(Sender: TObject);
var
aBitmap : TBitMap;
begin
try
Abitmap := TBitmap.Create;
if(OpenPictureDialog1.Execute)then
Abitmap.LoadFromFile(OpenPictureDialog1.FileName);
Printer.begin
Doc;
Printer.Canvas.Draw(40,40,Abitmap);
Printer.EndDoc;
finally
Abitmap.free;
end;
end;
 
后退
顶部