如何在圖片框控件中圓化邊緣。我想要像橢圓一樣的角度,但我不知道如何去做。我使用C#。謝謝!圖片框C中的圓角#
11
A
回答
14
好的,沒問題,你可以給一個控制其Region屬性的任意形狀。爲您的項目添加一個新類並粘貼下面顯示的代碼。編譯。將新控件從工具箱的頂部拖放到表單上。
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
class OvalPictureBox : PictureBox {
public OvalPictureBox() {
this.BackColor = Color.DarkGray;
}
protected override void OnResize(EventArgs e) {
base.OnResize(e);
using (var gp = new GraphicsPath()) {
gp.AddEllipse(new Rectangle(0, 0, this.Width-1, this.Height-1));
this.Region = new Region(gp);
}
}
}
9
回合邊緣在回合中角落?
如果是退房http://social.msdn.microsoft.com/forums/en-US/winforms/thread/603084bb-1aae-45d1-84ae-8544386d58fd
Rectangle r = new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height);
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
int d = 50;
gp.AddArc(r.X, r.Y, d, d, 180, 90);
gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90);
gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90);
gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90);
pictureBox1.Region = new Region(gp);
10
把表格1張圖片框和編寫代碼 也可以改變寬度的旁邊的負號和高度,以獲得最好的結果
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3);
Region rg = new Region(gp);
pictureBox1.Region = rg;
+0
謝謝,這是必要的語法量的一個很好的解決方案。我還沒有測試過這個畫的資源,但我現在喜歡它。另外,不錯的圖片:P – soulshined
0
謝謝,漢斯。但我也需要一個光滑的外觀。我在這個主題上做了一些研究,但是我找不到解決方案。然後我嘗試自己做,並找到下面的解決方案。也許別人需要它。
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddEllipse(0, 0, this.Width - 1, this.Height - 1);
Region = new Region(gp);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawEllipse(new Pen(new SolidBrush(this.BackColor), 1), 0, 0, this.Width - 1, this.Height - 1);
}
}
相關問題
- 1. 圖片邊框和角C++
- 2. C中的圓形圖框#
- 3. C++從對話框圓角
- 4. Objective C,如何使UIImageView中的圖片的角落變圓?
- 5. 按鈕角落圓角背景圖片
- 6. wxPython中的圓角邊框
- 7. 圓角邊框
- 8. 更改圖片框中的圖片C#
- 9. C# - 圖片框中的圖片漸變
- 10. 修改圖片資源,圓角矩形邊框libgdx
- 11. Highcharts:繪圖邊框的圓角半徑
- 12. 的Webkit:圖像覆蓋圓角邊框
- 13. 圖像的圓角和邊框
- 14. C中的圖片框#
- 15. 圖像中的圓角
- 16. CSS圓角邊框
- 17. 繪製圓角框
- 18. 如何向圓角圖像添加圓角邊框(使用邊框半徑圓角)
- 19. 如何製作帶邊框的半圓角(頂角圓角)texview?
- 20. 圓角邊框的JPanel的
- 21. 圖像的圓角
- 22. 圓角圖像
- 23. UITableView的圓角邊框?
- 24. 帶邊框的Css圓角
- 25. 圓角的文本框
- 26. 帶圓角的Div邊框
- 27. 的UIButton圓角和邊框
- 28. img的圓角邊框
- 29. 圓角圓角?
- 30. 繪製圖像與圓角,邊框和漸變填充C#
啊,謝謝你!它確實爲您提供延伸課程時所具備的可能性的圖像。在工具箱中獲得修改組件是多麼容易。 :) – Arndroid