Jump to content
Xtreme .Net Talk

How to convert pixels to/from centimeters/inches?


Recommended Posts

Guest MrPolite
Posted

I want to see how many pixels is a centimeter/inch on my monitor, how can I do this?

I dont want to use the compatibility class.

Guest MrPolite
Posted
1440 twips per inch. 2.54 cm per inch.

well and how do I find that out at runtime?

let's say I'm running my app on two comps with two different screen resolutions. I need to know how many pixels each inch is on each monitor.

Dunno about twips, I dont think that would work:confused:

Guest OnErr0r
Posted

Its a constant, design or runtime makes no difference. Look at ScaleX/Y properties in the help.

 

 

Twip (1440 twips per logical inch; 567 twips per logical centimeter).

Guest OnErr0r
Posted
Pixels will vary with the screen resolution. Use Screen.TwipsPerPixelX/Y to calculate them. Your original question asked how many twips per inch/centimeter.
  • *Gurus*
Posted (edited)

There is no Screen object in VB.NET. There is no real way of getting an accurate pixels per inch measurement, I suppose one way would be to ask the user what size monitor they're using.

 

[edit]

Ok, there is a Screen object but it doesn't do what you want.

[/edit]

Edited by divil

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest OnErr0r
Posted

oops, didn't notice it was the .net board.

 

I hate it when they alter the original question too :/

Guest MrPolite
Posted
oops, didn't notice it was the .net board.

 

I hate it when they alter the original question too :/

:)

 

 

and there HAS to be a way to do this in .NET. It would be ridiculus otherwise. There is a DpiX and DpiY property, but I couldnt make it to work

any ideas?:confused:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...