在image.canvas中画的图像为什么打印不出来?(50分)

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

Unregistered / Unconfirmed
GUEST, unregistred user!
在image.canvas中画的图像为什么打印不出来,而用loadfrom调用的土却打印得出来?
代码:
procedure TForm1.FormCreate(Sender: TObject);
begin

with image1do

begin

canvas.Rectangle(30,30,100,100);
canvas.LineTo(150,150);
//image1.Picture.LoadFromFile('/all_bmp/close.bmp');
end;


end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
AspectRatio: Single;
OutputWidth, OutputHeight: Single;
begin

if not PrintDialog1.Execute then
Exit;
Printer.begin
Doc;
try
OutputWidth := Image1.Picture.Width;
OutputHeight := Image1.Picture.Height;
AspectRatio := OutputWidth / OutputHeight;

if OutputWidth > Printer.PageWidth then

begin

OutputWidth := Printer.PageWidth;
OutputHeight := OutputWidth / AspectRatio;
end;

if OutputHeight > Printer.PageHeight then

begin

OutputHeight := Printer.PageHeight;
OutputWidth := OutputHeight * AspectRatio;
end;

Printer.Canvas.StretchDraw(Rect(0,0,
Trunc(outputWidth), Trunc(OutputHeight)),
Image1.Picture.Graphic);
{BltTBitmapAsDib(Printer.Canvas.Handle,
0,
0,
Image1.Picture.Bitmap.Width,
Image1.Picture.Bitmap.Height,
Image1.Picture.Bitmap);
end;
}

finally
Printer.EndDoc;
end;

end;
 
用paintbox试试
 
不行啊,我都是用image.canvas画的。
 
笨一点的方法,先把image里的内容村成临时文件,再打开打印试试
 
后退
顶部