VB.NET 使用跟踪栏重新定位位图中的文本?



我想让用户能够使用跟踪栏在位图周围自由拖动文本,这是我的尝试,但正如你所看到的,当拖动跟踪栏时,文本不会移动,而是创建一个新的文本层。我不知道我在这里做错了什么,任何帮助都值得赞赏!

我尝试的结果

Private Sub MaskedTextBox1_TextChanged(sender As Object, e As EventArgs) Handles MaskedTextBox1.TextChanged, TrackBarX.Scroll, TrackBarY.Scroll
MaskedTextBoxX.Text = TrackBarX.Value
MaskedTextBoxY.Text = TrackBarY.Value
If Not PictureBox.Image Is Nothing Then
Dim bmp As Bitmap
bmp = Form3.PictureBox1.Image
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.TextRenderingHint = TextRenderingHint.AntiAlias
gr.SmoothingMode = SmoothingMode.AntiAlias
Dim f As New Font("Impact", 72)
Dim b As New SolidBrush(Color.White)
Dim gp As New GraphicsPath
gp.AddString(MaskedTextBox1.Text, f.FontFamily, FontStyle.Regular, 100, New Point(TrackBarX.Value, TrackBarY.Value), StringFormat.GenericTypographic)
gr.FillPath(Brushes.White, gp)
gr.DrawPath(Pens.Black, gp)
gp.Dispose()
gr.Dispose()
PictureBox.Image = bmp
End If

End Sub

根据评论

bmp = New Bitmap(Form3.PictureBox1.Image)

最新更新