Возникло желание квадратные аватарки сделать круглыми. Есть входной Bitmap нужно сделать его круглым на прозрачном фоне.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Public Function RoundedAvatar(src As Bitmap) As Bitmap Dim dest As New Bitmap(src.Width, src.Height, Imaging.PixelFormat.Format32bppArgb) Dim g As Graphics = Graphics.FromImage(dest) g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality Dim gp As New Drawing2D.GraphicsPath gp.AddEllipse(New RectangleF(0, 0, src.Width, src.Height)) g.SetClip(gp) g.DrawImage(src, 0, 0) g.DrawEllipse(New Pen(Color.White, 1), 0, 0, src.Width, src.Height) g.Dispose() Return dest End Function |