procedure TFormBarcode.printbmp(str : string);
var GRect : TRect;
IRatioDif : real;
begin
{First calculate the ration of the height to width of bitmap}
IRatioDif := Image1.Picture.Height / Image1.Picture.Width;
{Then get the various sizes of the printer canvas}
GRect.Top := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
GRect.Left := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
GRect.Right := Printer.PageWidth - GRect.Left;
GRect.Bottom := trunc(Printer.PageHeight * IRatioDif) - GRect.Top;
image1.Picture.LoadFromFile('c:\'+str);
with Printer do begin
BeginDoc;
grect.Top := 0;//这些地方修改打印的范围
grect.Left := 0;
grect.Right := trunc(image1.Width * 3) ;
grect.Bottom := trunc(image1.Height * 3);
Canvas.StretchDraw(GRect, Image1.Picture.Graphic);
EndDoc;
end;end;
var GRect : TRect;
IRatioDif : real;
begin
{First calculate the ration of the height to width of bitmap}
IRatioDif := Image1.Picture.Height / Image1.Picture.Width;
{Then get the various sizes of the printer canvas}
GRect.Top := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
GRect.Left := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
GRect.Right := Printer.PageWidth - GRect.Left;
GRect.Bottom := trunc(Printer.PageHeight * IRatioDif) - GRect.Top;
image1.Picture.LoadFromFile('c:\'+str);
with Printer do begin
BeginDoc;
grect.Top := 0;//这些地方修改打印的范围
grect.Left := 0;
grect.Right := trunc(image1.Width * 3) ;
grect.Bottom := trunc(image1.Height * 3);
Canvas.StretchDraw(GRect, Image1.Picture.Graphic);
EndDoc;
end;end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货