What's in the RTF
picw
and
pich
tags is the actual width and height of the image in the document in pixels. It's not the displayed width and height. Those show up in the
picwgoal
and
pichgoal
tags. Then numbers after them are the desired display size but in twips, not pixels. Oh, and those values are specified as Long, not Integer.
You can find doucmentation on RTF tags
here[
^].
There is no support for twips scaling in .NET. You can use the following function to convert twips to pixels on the current display device using it's DPI settings:
Private Function ConvertTwipsToPixel(ByVal lngTwips As Long, ByVal blnHorizontal As Boolean) As Long
Const TWIPSPERINCH As Long = 1440
Dim gr As Graphics
gr = Me.CreateGraphics
If blnHorizontal Then
ConvertTwipsToPixel = CLng(lngTwips / TWIPSPERINCH * gr.DpiX)
Else
ConvertTwipsToPixel = CLng(lngTwips / TWIPSPERINCH * gr.DpiY)
End If
End Function
This code was lifted from http://vbcity.com/forums/t/5030.aspx[^], and has NOT been tested.