Draw Border by size - CSharp System.Drawing

CSharp examples for System.Drawing:Graphics

Description

Draw Border by size

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Drawing;
using System.Collections.Generic;
using System;//from  ww w  .j  a v a  2 s  . c o  m

public class Main{
        public static Image DrawBorder(Size size, Color color)
        {
            Bitmap bitmap = new Bitmap(size.Width, size.Height);
            bitmap.MakeTransparent();
            Graphics g = Graphics.FromImage(bitmap);
            g.DrawRectangle(new Pen(color, 1), 0, 0, size.Width-1, size.Height-1);
            return bitmap;
        }
}

Related Tutorials