Следуя коду here Я пытаюсь изогнуть края прямоугольника так, чтобы его не все были квадратными.Изменение обрамленного изображения в виде закругленного прямоугольника
Пример того, что он выглядит сейчас:
И то, что я ищу это сделать:
Используя этот код:
Using br As New SolidBrush(solidBGColor)
Dim r As New RectangleF(0, 0, myPictureBox.Width, myPictureBox.Height)
Dim gp As New System.Drawing.Drawing2D.GraphicsPath()
Dim d As Integer = 5
gp.AddArc(r.X, r.Y, imgSizeWH(0), imgSizeWH(1), 180, 90)
gp.AddArc(r.X + r.Width - d, r.Y, imgSizeWH(0), imgSizeWH(1), 270, 90)
gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, imgSizeWH(0), imgSizeWH(1), 0, 90)
gp.AddArc(r.X, r.Y + r.Height - d, imgSizeWH(0), imgSizeWH(1), 90, 90)
g.FillPath(br, gp)
End Using
У меня есть образ, который только что сделал sn't кажется правильным:
Полный код:
Private Function CreateLabeledAvatar(av As Image, text As String) As Image
Dim imgSizeWH() As Integer = {800, 800}
Dim bmp As New Bitmap(imgSizeWH(0), imgSizeWH(1))
Dim solidBGColor As Color = DirectCast(New ColorConverter().ConvertFromString("#" + _BackgroundColours(New Random().[Next](0, _BackgroundColours.Count - 1))), Color)
Using g As Graphics = Graphics.FromImage(bmp)
Using br As New SolidBrush(solidBGColor)
Dim r As New RectangleF(0, 0, myPictureBox.Width, myPictureBox.Height)
Dim gp As New System.Drawing.Drawing2D.GraphicsPath()
Dim d As Integer = 5
gp.AddArc(r.X, r.Y, imgSizeWH(0), imgSizeWH(1), 180, 90)
gp.AddArc(r.X + r.Width - d, r.Y, imgSizeWH(0), imgSizeWH(1), 270, 90)
gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, imgSizeWH(0), imgSizeWH(1), 0, 90)
gp.AddArc(r.X, r.Y + r.Height - d, imgSizeWH(0), imgSizeWH(1), 90, 90)
g.FillPath(br, gp)
'g.FillRectangle(br, 0, 0, bmp.Width, bmp.Height)
End Using
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.CompositingQuality = CompositingQuality.HighQuality
g.TextRenderingHint = TextRenderingHint.AntiAlias
g.SmoothingMode = SmoothingMode.HighQuality
g.DrawImage(av, 0, 0, bmp.Width, bmp.Height)
Using fnt As New Font("Arial", 132, FontStyle.Bold, GraphicsUnit.Pixel)
TextRenderer.DrawText(g, text, fnt, New Rectangle(0, 0, imgSizeWH(0), imgSizeWH(1)),
Color.WhiteSmoke, TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter)
End Using
End Using
Return bmp
End Function
Это сделало трюк! Спасибо за вашу помощь, Плутоникс! – StealthRT