?
Solved

PixelsPerInch in Horizontal?

Posted on 2003-04-01
5
Medium Priority
?
433 Views
Last Modified: 2010-04-06
Hi Guys.
I want to output a graphic that needs to be in an exact size - something like 10inch over 20inch.

I know I can convert vertically - Screen.PixelsPerInch gives me the amount of pixels in an inch. But only vertically.

So what are my options if I want the horizontal property as well?

T.
0
Comment
Question by:ShadowHawk071998
[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
5 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 1000 total points
ID: 8248685

Try this

var
 hdcScreen: HDC;
 vertppi:   Integer;
 horzppi:   Integer;
begin

 
 hdcScreen:=GetDC(0);
 vertppi:=GetDeviceCaps(hdcScreen, LOGPIXELSY);
 horzppi:=GetDeviceCaps(hdcScreen, LOGPIXELSX);
 ReleaseDC(hdcScreen);

end;

Regards,
Russell
0
 
LVL 2

Expert Comment

by:Zip58
ID: 8248887
Hi rllibby

mabey this site can help you also

http://homepages.borland.com/efg2lab/index.html

Regards

Zip58
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 8252483
I thought that you typically always got '72' for the PixelsPerInch for a screen - hence you don't actually get 100% accuracy? Is that wrong, then? Printers are fine. Screens are approximate???
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8255036

Delphi's Screen.PixelsPerInch is returned via a call to GetDeviceCaps, i gave you the corresponding call to get  the horizontal. As far as being an apprx, yes that is the case.

Russell

Notes from MSDN:

Sometimes you need an application to display things in terms of a real unit of measurement such as an inch or millimeter. When dealing with a printer, resolution is usually given in dots per inch (DPI), which makes it easy to convert pixels to real inches. However, on a video display, resolution is given only in pixels. A given video mode will be some X pixels wide with no information as to the real dimensions of the display area.

Because there is no way to programmatically determine the real dimensions of the viewable area on a video display, it is impossible for a program to determine real output dimensions. Two manual methods for determining real output dimensions are given in this article.


MORE INFORMATION
When output is destined for a printer, the application can call GetDeviceCaps() using LOGPIXELSX and LOGPIXELSY to determine dots per real inch. However, for a video display, LOGPIXELSX and LOGPIXELSY are defined by the video driver and may vary wildly. These numbers define a logical inch, which is almost never equal to a real inch.

Applications that need to output real sizes to the video display can use one of the following two methods for determining output size:

The application can ask the user what size monitor is attached. Using this value, an application can approximate the actual viewable area, and given the resolution of the output (GetDeviceCaps, HORZRES, VERTRES), the application can approximate real inches. This solution gives only an approximation of a real inch. Several factors can introduce errors into this approximation including the size adjustments on digital monitors.


The application can ask the user to hold a measuring device to the screen and measure a given line. This is the only way to guarantee that output on a video display is exactly the expected size, and recalibration would be necessary after any adjustment to the monitor.

0
 

Expert Comment

by:CleanupPing
ID: 9316498
ShadowHawk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 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