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#程序设计有所帮助。