我正在 vb.net 中制作一个应用程序,它具有良好的用户界面,包括包含图片框的帐户图标。我的问题是如何使图片框中的图像变成圆形?
像这样: https://drive.google.com/open?id=1rUBq68ULDkTiFFv2uEiV_oQIh3wQIfhd
我通常不会为没有显示尝试的问题提供代码,但答案中有几个步骤,而且自己编写代码比解释它们更容易。例如
'Get the original image.
Dim originalImage = PictureBox1.Image
'Create a new, blank image with the same dimensions.
Dim croppedImage As New Bitmap(originalImage.Width, originalImage.Height)
'Prepare to draw on the new image.
Using g = Graphics.FromImage(croppedImage)
Dim path As New GraphicsPath
'Create an ellipse that fills the image in both directions.
path.AddEllipse(0, 0, croppedImage.Width, croppedImage.Height)
Dim reg As New Region(path)
'Draw only within the specified ellipse.
g.Clip = reg
g.DrawImage(originalImage, Point.Empty)
End Using
'Display the new image.
PictureBox2.Image = croppedImage
这将创建一个与原始图像具有相同宽度和高度的椭圆形图像。如果原件是方形的,那么最终的将是圆形的。如果您想要一个圆形,而不管原始的纵横比如何,那么您必须以适当的方式对其进行操作。
මා දෑ දකී ඒ රූපේ මා හර්දේ ශෝබන ගංගා වෑහේවී ආලය හංගා දෑසින් පානා හී සැර යැව්වා මකරන්දේ සාරය ගි ල්වා ආශාවේ මා සිත දල්වා සේයාවන් ඔබගේ මං සෙව්ව් වා පායාවී සද ඔමරී ඒ යාමේ තරු ඇඹරී රූ ධාරී වන බබර ේමනකැලඹිලාරගනා හර සාරේ දෙපසේ පේනා මනසාරයි නාදය ඇසෙනා මං ආසයි හීනේ ලං වෙලා මනලෝලී කෝමල සේනා රන්දෝලී නර්තන ගේ නා නුඹ මාගේ නේදෝ යාවෙනා සරාගී සලුපටලාලා බලාවී ග ත සොලවාලා නුරාගී ප්u200dරේමා මුලු රෑ මත්වීලාදෝ මෝර ා