'''根据坐标的现有图片上绘制多边形 Public Shared Function GetSelectedActionImage(ByVal imgurl As String, ByVal coords As String, ByVal colors As String) As Bitmap Dim bmp As New Bitmap(imgurl, True) Dim g As Graphics = Graphics.FromImage(bmp) Dim pens As New Pen(getColor(colors), 2) Dim arr As Array = Report.GetStrArray(coords, "|") Dim x As Array = Report.GetStrArray(arr.GetValue(0), ",") Dim y As Array = Report.GetStrArray(arr.GetValue(1), ",") Dim pen As New Pen(Color.Red, 2) Dim points As New ArrayList If x.Length = y.Length Then For j As Integer = 0 To x.Length - 1 Dim pf As PointF = New PointF(x(j), y(j)) points.Add(pf) Next End If Dim i As Integer For i = 0 To points.Count - 2 g.DrawLine(pen, points(i).X, points(i).Y, points(i + 1).X, points(i + 1).Y) Next g.DrawLine(pen, points(i).X, points(i).Y, points(0).X, points(0).Y) g.Dispose() Return bmp End Function '''缩放图片 Public Shared Function Zoom(ByVal myImage As Bitmap, ByVal nWidth As Integer, ByVal nHeight As Integer) As Bitmap Dim iX As Integer Dim iY As Integer Dim xMax As Integer Dim yMax As Integer If nWidth < myImage.Width Or nHeight < myImage.Height Then If myImage.Width / myImage.Height > nWidth / nHeight Then xMax = nWidth yMax = myImage.Height * nWidth / myImage.Width Else yMax = nHeight xMax = myImage.Width * nHeight / myImage.Height End If Else xMax = myImage.Width yMax = myImage.Height End If Dim tembmp As Bitmap = New Bitmap(myImage, xMax, yMax) Return tembmp End Function
根据坐标在图片上绘制多边形边框
最新推荐文章于 2023-11-19 08:59:58 发布
本文介绍了一种在图片上绘制多边形的方法,并提供了一个基于坐标数据实现的示例。此外,还分享了如何按指定宽度和高度缩放图片的技术。
989

被折叠的 条评论
为什么被折叠?



