关于图象打印另类问题 ( 积分: 200 )

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

biggj

Unregistered / Unconfirmed
GUEST, unregistred user!
如果在Image中调出了图片,怎么打都OK,
var
ScaleX, ScaleY: Real;
R: TRect;
begin
with Printer do
try
BeginDoc;
ScaleX := GetDeviceCaps(Printer.Handle, LOGPIXELSX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Printer.Handle, LOGPIXELSY) div PixelsPerInch;
R := Rect(0, 0, Round(Image2.Picture.Width * ScaleX),Round(Image2.Picture.Height * ScaleY));
Canvas.StretchDraw(R, Image2.Picture.Graphic);
finally
EndDoc;
end;

end;

如果我先调用这个清Image,然后写文字的东西,送打印就什么也打不出来
with image2 do
begin
Canvas.FillRect(rect(0,0,200,200));
Canvas.Font.Name:='宋体';
Canvas.Font.Size:=20;
Canvas.TextOut(10,10,'设备空号清单');
end;
end;
 
如果在Image中调出了图片,怎么打都OK,
var
ScaleX, ScaleY: Real;
R: TRect;
begin
with Printer do
try
BeginDoc;
ScaleX := GetDeviceCaps(Printer.Handle, LOGPIXELSX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Printer.Handle, LOGPIXELSY) div PixelsPerInch;
R := Rect(0, 0, Round(Image2.Picture.Width * ScaleX),Round(Image2.Picture.Height * ScaleY));
Canvas.StretchDraw(R, Image2.Picture.Graphic);
finally
EndDoc;
end;

end;

如果我先调用这个清Image,然后写文字的东西,送打印就什么也打不出来
with image2 do
begin
Canvas.FillRect(rect(0,0,200,200));
Canvas.Font.Name:='宋体';
Canvas.Font.Size:=20;
Canvas.TextOut(10,10,'设备空号清单');
end;
end;
 
忘了说了,我用的是D7,原来的D6里面用过没有问题的,现在用D7了就有问题了,大家回答呀,麻烦了,在线等待!
 
问题解决,大家以后不要画了直接送Printer,先把它存成文件,然后再用另一个Image当文件打开就可以打印了!
Image1.Picture.SaveToFile(PathStr+'back/aa.bmp');
Image2.Picture.LoadFromFile(PathStr+'back/aa.bmp');

with Printer do

try
BeginDoc;
ScaleX := GetDeviceCaps(Printer.Handle, LOGPIXELSX)/100;
ScaleY := GetDeviceCaps(Printer.Handle, LOGPIXELSY)/100;

R := Rect(0, 0, Round(Image2.Picture.Width * ScaleX),Round(Image2.Picture.Height * ScaleY));

Canvas.StretchDraw(R, Image2.Picture.Graphic);
finally
EndDoc;
end;
 
//uses printers; // 要加 printers单元
//这是我的一个处理你修改一下
//author: jfyes
//date: 2004-03-08
function PrintImg(I_M: TPicture; Tit: string): boolean;
var
prn: TPrinter;
dpix, dpiy: integer;
rc: TRect;
begin
Result := true;
prn := TPrinter.Create;
prn.Title := Tit;
try
prn.BeginDoc;
dpix := GetDeviceCaps(prn.Handle, LOGPIXELSX);
dpiy := GetDeviceCaps(prn.Handle, LOGPIXELSY);
rc.Left := Trunc(2 * dpix / 2.54);
rc.Top := Trunc(2 * dpiy / 2.54);
rc.Right := Trunc(rc.Left + I_M.Width * dpix / 96);
rc.Bottom := Trunc(rc.Bottom + I_M.Height * dpiy / 96);
prn.Canvas.StretchDraw(rc, I_M.Bitmap);
prn.EndDoc;
except
showmessage('读取位图格式出错!')
Result := false;
end;
end;
 
to jfyes:
不行的,我试过了.....
 
接受答案了.
 
后退
顶部