Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print Stretched image in specific canvas position

Posted on 2004-04-29
3
Medium Priority
?
300 Views
Last Modified: 2010-04-05
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 ***
0
Comment
Question by:mitcht
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 10955788

 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
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 10955799
Sorry, slight mistake in the rect calculation....

 R:=Rect(PageWidth-pBitmap.Width * ScaleX, PageHeight-pBitmap.Height * ScaleY, PageWidth, PageHeight);

Russell

0
 
LVL 17

Expert Comment

by:mokule
ID: 10959207
You may have some problems using PageWidth and PageHeight on some printers.
You should set some reasonable margins.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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