C#实现图片加相框的方法
本文实例讲述了C#实现图片加相框的方法。分享给大家供大家参考,具体如下:
//加边框
try
{
BitmapBackbmp=newBitmap(@""+Path);
floatw=(float)(Backbmp.Width*0.2);
using(Graphicsg=Graphics.FromImage(Backbmp))
{
using(Brushbrush=newSolidBrush(Color.FromArgb(0,156,255)))
{
using(Penpen=newPen(brush,w))
{
pen.DashStyle=DashStyle.Custom;
g.DrawRectangle(pen,newRectangle(0,0,Math.Abs(Backbmp.Width),Math.Abs(Backbmp.Height)));
g.Dispose();
pic.BackgroundImage=Backbmp;
}
}
}
}
catch(Exception)
{
}
//加椭圆
try
{
BitmapBackbmp=newBitmap(@""+Path);
floatw=(float)(Backbmp.Width*0.2);
using(Graphicsg=Graphics.FromImage(Backbmp))
{
using(Brushbrush=newSolidBrush(Color.FromArgb(0,156,255)))
{
using(Penpen=newPen(brush,w))
{
pen.DashStyle=DashStyle.Custom;
g.DrawEllipse(pen,newRectangle(0,0,Math.Abs(Backbmp.Width),Math.Abs(Backbmp.Height)));
g.Dispose();
pic.BackgroundImage=Backbmp;
}
}
}
}
catch(Exception)
{
}
更多关于C#相关内容感兴趣的读者可查看本站专题:《C#面向对象程序设计入门教程》、《C#常见控件用法教程》及《C#数据结构与算法教程》
希望本文所述对大家C#程序设计有所帮助。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短