16,547
社区成员
发帖
与我相关
我的任务
分享
Dim bMap As Bitmap = New Bitmap(800, 500)
Dim gph As Graphics = System.Drawing.Graphics.FromImage(bMap)
Dim cPt As PointF = New PointF(40, 420)
Dim destRect As New Rectangle(100, 100, 800, 500) '目标位置,前2个参数就是偏移位置,后两个是宽高,可以修改的和源不同进行缩放
Dim srcRect As New Rectangle(0, 0, 800, 500) '图片原始尺寸
Dim gcner As System.Drawing.Drawing2D.GraphicsContainer = gph.BeginContainer(destRect, srcRect, GraphicsUnit.Pixel)
gph.DrawLine(Pens.Black, 40, 120, 50, 200)
gph.EndContainer(gcner)
Using g As Graphics = Me.CreateGraphics
g.DrawImage(bMap, 0, 0)
End Using