Module FuncModule
Public Function GetEmfExtTextOutW_StructFromIntPtr(ByVal dataSize As Integer, _
ByVal data As IntPtr) As EmfExtTextOutW_Struct
Dim DataArray As Byte() = Nothing, temp As EmfExtTextOutW_Struct = Nothing
If Not IntPtr.Zero.Equals(data) Then
DataArray = New Byte(dataSize) {}
Marshal.Copy(data, DataArray, 0, dataSize)
With temp
With .rclBounds '0-15
.Left = Marshal.ReadInt32(data, 0)
.Top = Marshal.ReadInt32(data, 4)
.Right = Marshal.ReadInt32(data, 8)
.Bottom = Marshal.ReadInt32(data, 12)
End With
.iGraphicsMode = Marshal.ReadInt32(data, 16)
.exScale = Marshal.ReadInt32(data, 20)
.eyScale = Marshal.ReadInt32(data, 24)
With .ptlReference '28-35
.X = Marshal.ReadInt32(data, 28)
.Y = Marshal.ReadInt32(data, 32)
End With
.nChars = Marshal.ReadInt32(data, 36)
.offString = Marshal.ReadInt32(data, 40)
.fOptions = Marshal.ReadInt32(data, 44)
With .rcl '48-63
.Left = Marshal.ReadInt32(data, 48)
.Top = Marshal.ReadInt32(data, 52)
.Right = Marshal.ReadInt32(data, 56)
.Bottom = Marshal.ReadInt32(data, 60)
End With
.offDx = Marshal.ReadInt32(data, 64)
Dim TextUTF16 As New System.Text.UnicodeEncoding
.CharsA = TextUTF16.GetString(DataArray, .offString - 8, .nChars * 2)
End With
End If
Return temp
End Function
'http://forums.devx.com/showthread.php?t=155532
Public Structure EmfExtTextOutW_Struct 'Offset Size Type
Public iType As Integer '-8 4 emr.iType (the EmfPlusRecordType)
Public nSize As Integer '-4 4 emr.nSize
Public rclBounds As rclBounds_Struct '0-15
Public iGraphicsMode As Integer '16 4 iGraphicsMode
Public exScale As Integer '20 4 exScale
Public eyScale As Integer '24 4 eyScale
Public ptlReference As ptlReference_Struct '28-35
Public nChars As Integer '36 4 nChars
Public offString As Integer '40 4 offString
Public fOptions As Integer '44 4 fOptions
Public rcl As rcl_Struct '48-63
Public offDx As Integer '64 4 offDx
Public CharsA As String '68 nChars*2 (string)
Public CharsB As String '68+nChars*2 nChars*4 (intercharacter spacings)
End Structure
Public Structure rclBounds_Struct
Public Left As Integer '0 4 rclBounds.left (header is excluded, so record data actually starts here)
Public Top As Integer '4 4 rclBounds.top
Public Right As Integer '8 4 rclBounds.right
Public Bottom As Integer '12 4 rclBounds.bottom
End Structure
Public Structure ptlReference_Struct
Public X As Integer '28 4 ptlReference.x
Public Y As Integer '32 4 ptlReference.y
End Structure
Public Structure rcl_Struct
Public Left As Integer '48 4 rcl.left
Public Top As Integer '52 4 rcl.top
Public Right As Integer '56 4 rcl.right
Public Bottom As Integer '60 4 rcl.bottom
End Structure
End Module
Комментариев нет:
Отправить комментарий