Public Shared Function LoadString(ByRef Context As String, ByRef Brush As System.Drawing.Brush, ByVal Size As Integer, ByVal FontName As String, _
Optional ByVal BorderWidth As Integer = 1, Optional ByVal Width As Integer = 1600, Optional ByVal Height As Integer = 64) As DxImage
Dim Image As System.Drawing.Bitmap = New System.Drawing.Bitmap(Width, Height)
Dim GDI As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(Image)
Dim FontFamily As System.Drawing.FontFamily = New System.Drawing.FontFamily(FontName)
Dim Font As System.Drawing.Font = New System.Drawing.Font(FontFamily, Size, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel)
GDI.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
GDI.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High
For o = 0 To Math.PI * 2 Step Math.PI / 16
For i = 1 To BorderWidth Step 1
GDI.DrawString(Context, Font, System.Drawing.Brushes.Black, i * Math.Cos(o), i * Math.Sin(o))
Next i
Next o
GDI.DrawString(Context, Font, Brush, 0, 0)
Dim SoftHandle As Integer = DX.MakeARGB8ColorSoftImage(Image.Width, Image.Height)
Dim TmpColor As New System.Drawing.Color()
For i = 0 To Image.Width - 1 Step 1
For j = 0 To Image.Height - 1 Step 1
TmpColor = Image.GetPixel(i, j)
DX.DrawPixelSoftImage(SoftHandle, i, j, TmpColor.R, TmpColor.G, TmpColor.B, TmpColor.A)
Next j
Next i
'Dim Data As System.Drawing.Imaging.BitmapData = New System.Drawing.Imaging.BitmapData()
'Data = Image.LockBits(New System.Drawing.Rectangle(0, 0, Image.Width, Image.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim TmpImage As DxImage = New DxImage(DX.CreateGraphFromSoftImage(SoftHandle), Image.Width, Image.Height)
'Image.UnlockBits(Data)
DX.DeleteSoftImage(SoftHandle)
GDI.Dispose() : Image.Dispose() : Font.Dispose() : FontFamily.Dispose()
Return TmpImage
End Function
感觉贴图加载代码和我这边思路类似,都是以内存为中介 我之前是用的。。硬盘。。。