Centimeter to pixel

前端 未结 6 1262
深忆病人
深忆病人 2021-01-11 18:55

How do I convert centimeter to pixel in c# ?

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-11 19:40

    You can use the DpiX and DpiY properties of the Graphics object on which you're drawing (which you must have, since conversion is meaningless in the absence of a graphics context of some kind.)

    In DpiX and DpiY, the "D" stands for "dots" or pixels, while the "i" stands for "inches". So, it will convert pixels to inches. Then all you have to do is convert inches to centimeters => (x * 2.54)

    Also if you want to be more "precise", have a look at the following: HOWTO: How to Make an Application Display Real Units of Measurement

提交回复
热议问题