Solved

Can't get PrintScale to work

Posted on 2000-05-16
2
638 Views
Last Modified: 2011-10-03
Hi,

I've said this, I don't know how many times, but I'm sorta' a novice with Delphi.

How do I get this to work?

(From the Delphi Help Files)
type TPrintScale = (poNone, poProportional, poPrintToFit);
property PrintScale: TPrintScale;

Question is, how do I impliment it with this?

procedure TForm1.Print1Click(Sender: TObject);
begin
    with Printer do
    begin
    PrintScale := poProportional;
    BeginDoc;      { start printing }
    Canvas.Draw(0, 0, Image1.Picture.Bitmap);      { draw Image at top left corner of printed page }
    EndDoc;      { finish printing }
    end;

end;
0
Comment
Question by:fibdev
2 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 25 total points
ID: 2816291
When you're trying to output a bitmap I'd forget about using the Printscale property and stretch the image yourself using StretchDraw e.g.:

Printer.Canvas.StretchDraw(RECT(0, 0, 100, 100), Image1.Picture.Bitmap);

This of course will ruin the aspect ratio but you can work that out like so:

rX := Printer.PageWidth / Image1.Picture.Bitmap.Width;
rY := Printer.PageHeight / Image1.Picture.Bitmap.Height;

IF rY > rX
THEN
  rY := rX
ELSE
  rX := rY;

iW := ROUND(Image1.Picture.Bitmap.Width * rX);
iH := ROUND(Image1.Picture.Bitmap.Height * rY);

iCx := (Printer.PageWidth - iW) DIV 2;
iCy := (Printer.PageHeight - iH) DIV 2;

Printer.Canvas.StretchDraw(RECT(iCx, iCy, iCx + iW, iCy + iH), Image1.Picture.Bitmap);

I'm pretty sure that's right but I might have got the initial division the wrong way around

Hope that helps

The Neil =:)
0
 
LVL 3

Author Comment

by:fibdev
ID: 2823665
Didn't work, but oh well ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now