mitcht
asked on
Print Stretched image in specific canvas position
Brain freeze here. Want to print a bitmap image to the printer canvas. Using stretchdraw preserves the image's size, but prints in in the upper left hand corner of my doc. Want to print it in the lower right hand corner (it's a barcode). How can I print it there, and still keep it's original size?
thanks!
*** CODE BEGINS ***
ScaleX, ScaleY: Integer;
R: TRect;
begin
with Printer do
try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
R := Rect(0, 0, pBitmap.Width * ScaleX,
pBitmap.Height * ScaleY);
Canvas.StretchDraw(R, pBitMap);
finally
// nothing to do...yet
end;
*** CODE ENDS ***
thanks!
*** CODE BEGINS ***
ScaleX, ScaleY: Integer;
R: TRect;
begin
with Printer do
try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
R := Rect(0, 0, pBitmap.Width * ScaleX,
pBitmap.Height * ScaleY);
Canvas.StretchDraw(R, pBitMap);
finally
// nothing to do...yet
end;
*** CODE ENDS ***
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may have some problems using PageWidth and PageHeight on some printers.
You should set some reasonable margins.
You should set some reasonable margins.
ScaleX, ScaleY: Integer;
R: TRect;
begin
with Printer do
try
ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
R := Rect(PageWidth-pBitmap.Wid
pBitmap.Height * ScaleY);
Canvas.StretchDraw(R, pBitMap);
finally
// nothing to do...yet
end;
Regards,
Russell