怎样在图片上裁剪一个不规则区域?

chanckaka 2011-03-16 07:00:24
我在网上看见很多可以裁剪矩形的方法,但好像没找到方法划定不规则区域,请问有大大知道吗?
谢谢!
...全文
1030 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
shaofei830927 2011-03-17
  • 打赏
  • 举报
回复
Region 向里面添加边界区域 最后闭合的曲线内部就是你想要的图形
朝三慕四 2011-03-17
  • 打赏
  • 举报
回复

GraphicsPath(Point[] apt, byte[] abyPointType);

GraphicsPath(PointF[] apt, byte[] abyPointType);

Region(GraphicsPath path);
Void SetClip(Region regn, CombineMode cm);


这个应该可以了吧...
ColinMelody 2011-03-17
  • 打赏
  • 举报
回复
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

private void IrregularForm_Load(object sender, EventArgs e)
{
GraphicsPath path = new GraphicsPath();
Point[] pt = {
new Point(0,0),
new Point(100,150),
new Point(this.Width-100,10),
};
path.AddCurve(pt);

Point[] ptA = {
new Point(this.Width-40,this.Height-60),
new Point(this.Width,this.Height),
new Point(50,this.Height),
};
path.AddCurve(ptA);

path.CloseAllFigures();
this.Region = new Region(path);

}

private void button1_Click(object sender, EventArgs e)
{
float f = 0.0f;
GraphicsPath path = new GraphicsPath();
Point[] pt = {
new Point(0,0),
new Point(10,20),
new Point(this.Width-20,0),
};
path.AddCurve(pt);

Point[] ptA = {
new Point(this.Width-40,this.Height-60),
new Point(this.Width,this.Height),
new Point(50,this.Height),
};
path.AddCurve(ptA);

Matrix rotationTra = new Matrix(1, 0, 0, 1, 1, 1);
PointF rp = new PointF(110.0f, 110.0f);
rotationTra.RotateAt(f, rp);
path.Transform(rotationTra);
f = f + 10;
this.Region = new Region(path);
}
}
julian 2011-03-17
  • 打赏
  • 举报
回复
是的
[Quote=引用 9 楼 lianaiqiong 的回复:]
C# code

GraphicsPath(Point[] apt, byte[] abyPointType);

GraphicsPath(PointF[] apt, byte[] abyPointType);

Region(GraphicsPath path);
Void SetClip(Region regn, CombineMode cm);



这个应该可以了吧……
[/Quote]
云瑀 2011-03-17
  • 打赏
  • 举报
回复
http://www.codeguru.com/cpp/misc/misc/graphics/article.php/c8965
像这种的吗?
zhoujk 2011-03-16
  • 打赏
  • 举报
回复
将这个选区理解成一个8位灰度构成的透明通道,也就是ARGB 里面的 A,可以在上面绘制多边形或半透明。在GUI上进行显示时,稍稍加一点像素合并的代码就行了。
chanckaka 2011-03-16
  • 打赏
  • 举报
回复
谢谢楼上的朋友,但我需要的是用c#写啊..
treasure_ever 2011-03-16
  • 打赏
  • 举报
回复
可以用photoshop cs4里的多边形套索工具,它专用来取不规则图形的。
miceswallonrabbit 2011-03-16
  • 打赏
  • 举报
回复
用snagit
dylike 2011-03-16
  • 打赏
  • 举报
回复
Rectange是矩形,Region是多边形

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧