Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should achieve better results if you resize the image to an intermediate bitmap (with a size suitable for the printer resolution) using one of the resamplers in <a href="http://wiki.delphi-jedi.org/wiki/JCL_Help%3aStretch@Cardinal@Cardinal@TResamplingFilter@Single@TGraphic@TBitmap" rel="nofollow">JCL</a> or <a href="http://graphics32.org/" rel="nofollow">Graphics32</a> and then you print the resized bitmap.</p> <p>The following routine will try to get the same size in printer as in the screen:</p> <pre><code>uses JclGraphics; procedure PrintGraphic(source: TGraphic); var dest: TBitmap; destWidth, destHeight, printerPixelsPerInch_X, printerPixelsPerInch_Y, printerLeftMargin, printerTopMargin: integer; begin printerPixelsPerInch_X := GetDeviceCaps(Printer.Handle, LOGPIXELSX); printerPixelsPerInch_Y := GetDeviceCaps(Printer.Handle, LOGPIXELSY); printerLeftMargin := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX); printerTopMargin := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY); dest := TBitmap.Create; try destWidth := source.Width * printerPixelsPerInch_X div Screen.PixelsPerInch; destHeight := source.Height * printerPixelsPerInch_Y div Screen.PixelsPerInch; Stretch(destWidth, destHeight, rfLanczos3, 0, source, dest); Printer.BeginDoc; try Printer.Canvas.Draw(printerLeftMargin, printerTopMargin, dest); Printer.EndDoc; except Printer.Abort; raise; end; finally dest.Free; end; end; procedure TFormMain.Button1Click(Sender: TObject); begin if not PrinterSetupDialog.Execute then exit; PrintGraphic(Image1.Picture.Graphic); end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload