vb.net-如何使图片框中的任何图片呈圆形

时间:2018-06-15 08:43:53

标签: vb.net rounding picturebox

我正在vb.net中创建一个具有良好用户界面的应用程序,包括包含图片框的帐户图标。我的问题是,如何在图片框中将图像制作成圆形?

喜欢这个: https://drive.google.com/open?id=1rUBq68ULDkTiFFv2uEiV_oQIh3wQIfhd

2 个答案:

答案 0 :(得分:2)

我通常不会为没有显示尝试的问题提供代码,但答案中有几个步骤,而且自己编写代码比解释它们更容易。 E.g。

DEBUG IMAP: ignoring bad response, THROW:com.sun.mail.iap.ParsingException: error in FETCH parsing, unrecognized item at index 16416, starts with "ETCH Completed"
at com.sun.mail.imap.protocol.FetchResponse.parse(FetchResponse.java:218)
at com.sun.mail.imap.protocol.FetchResponse.<init>(FetchResponse.java:96)
at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:414)
at com.sun.mail.iap.Protocol.command(Protocol.java:395)
at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2158)
at com.sun.mail.imap.protocol.IMAPProtocol.fetch(IMAPProtocol.java:2150)
at com.sun.mail.imap.protocol.IMAPProtocol.fetchSectionBody(IMAPProtocol.java:1862)
at com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1845)
at com.sun.mail.imap.protocol.IMAPProtocol.fetchBody(IMAPProtocol.java:1834)
at com.sun.mail.imap.IMAPInputStream.fill(IMAPInputStream.java:157)
at com.sun.mail.imap.IMAPInputStream.read(IMAPInputStream.java:198)
at java.io.FilterInputStream.read(FilterInputStream.java:83)
at java.io.PushbackInputStream.read(PushbackInputStream.java:139)
at com.sun.mail.util.QPDecoderStream.read(QPDecoderStream.java:87)
at com.sun.mail.util.QPDecoderStream.read(QPDecoderStream.java:167)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:101)
at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:795)
at javax.activation.DataHandler.getContent(DataHandler.java:542)
at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:683)

这将创建一个与原始图像具有相同宽度和高度的椭圆图像。如果原件是正方形,那么最终将是圆形的。如果你想要一个圆圈而不管原件的纵横比如何,你就必须以适当的方式操纵它。

答案 1 :(得分:0)

虽然我发现您已经找到了问题的解决方案,但这是一个非常简单的解决方法。

假设您的项目位于WinForms,并且您正在使用Picture Box控件。实现圆形图像外观的最简单方法是将Image的{​​{1}}属性设置为圆形图像,中间为空白/透明,外部为白色。然后,无论你设置为PictureBox的任何图像,它都会显示为圆形。

此处有一个示例圆形透明图像,您可以将其设置为BackgroundImage(确保将Image设置为拉伸),然后将任何图片设置为SizeMode

Image is white so it will blend with the background color of this page, just right click and save it