Help us understand the problem. What is going on with this article?

Twipをピクセルに変換する

More than 1 year has passed since last update.

Twipをピクセルに変換する方法は以下の通りです。

Imports System.Runtime.CompilerServices

''X-coordinate
Public Function Twips2PixelsX(ByRef grph As Graphics, ByVal twipsX As Integer) As Double
  Dim LOGPIXELSX As Int32 = 88
  Dim hdc As IntPtr = grph.GetHdc
  Dim pixelsX As Int32 = GetDeviceCaps(hdc, LOGPIXELSX)
  grph.ReleaseHdc(hdc)

  Return twipsX * pixelsX / 1440
End Function

''Y-X-coordinate
Public Function Twips2PixelsY(ByRef grph As Graphics, ByVal twipsY As Integer) As Double
  Dim LOGPIXELSY As Int32 = 90
  Dim hdc As IntPtr = grph.GetHdc
  Dim pixelsY As Int32 = GetDeviceCaps(hdc, LOGPIXELSY)
  grph.ReleaseHdc(hdc)

  Return twipsY * pixelsY / 1440
End Function

''Get device information
<System.Runtime.InteropServices.DllImport("gdi32.dll", CharSet:=Runtime.InteropServices.CharSet.Auto)> _
Private Function GetDeviceCaps(ByVal Phdc As IntPtr, ByVal cIndex As Int32) As Int32
End Function
kazuhirox
基本的にはC#で開発してますが、時々でJavaScriptで四苦八苦するソフトウェア開発者。 三十路を越えてから、なぜかプログラミングへの興味が高まってます。 若い頃の趣味はスキューバやスキーのアウトドア派でしたが、子どもができてからは専らTVゲーム(特に洋ゲー好き)。洋ゲーは子どもの前ではプレイできないのがツライところ。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした