Link to home
Start Free TrialLog in
Avatar of mitcht
mitchtFlag for United States of America

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 ***
Avatar of Russell Libby
Russell Libby
Flag of United States of America image


 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.Width * ScaleX, PageHeight-pBitmap.Height * ScaleY, pBitmap.Width * ScaleX,
      pBitmap.Height * ScaleY);
    Canvas.StretchDraw(R, pBitMap);
  finally
    // nothing to do...yet
  end;


Regards,
Russell
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You may have some problems using PageWidth and PageHeight on some printers.
You should set some reasonable margins.