Centimeter to pixel

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

How do I convert centimeter to pixel in c# ?

6条回答
  •  天命终不由人
    2021-01-11 19:51

    As I said in my comment, you'll have to give more information. (Is this a Windows Forms app? ASP.Net?)

    The fundamental approach is:

    • Find out the DPI of the output device in question. (It's frequently 96 [96 dots per inch], but you cannot assume that.) This thread may help you do that, if it's a Windows Forms app. Also, the Graphics class has the DpiX and DpiY members, so you can use those.
    • Convert the DPI to DPC [dots-per-centimeter] (DPC = DPI / 2.54).
    • Multiply your number of centimeters by your DPC value.

提交回复
热议问题