Pen Brush Property
PenBrushProperty.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
Bitmap bmp = new Bitmap(600,250);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.AliceBlue);
Pen drawingPen = new Pen(Brushes.Red, 15);
g.DrawLine(drawingPen, 50, 50, 550, 50);
drawingPen.Brush = Brushes.Green;
g.DrawLine(drawingPen, 50, 100, 550, 100);
drawingPen.Brush = Brushes.Blue;
g.DrawLine(drawingPen, 50, 150, 550, 150);
String path = Server.MapPath("~/Image/PenBrushProperty.jpg");
bmp.Save(path,ImageFormat.Jpeg);
Image1.ImageUrl = "~/Image/PenBrushProperty.jpg";
g.Dispose();
bmp.Dispose();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>how to use Pen Brush Property in asp.net drawing</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:MidnightBlue; font-style:italic;">
How to get or set the Brush that determines
<br /> attributes of this Pen in asp.net drawing
<br />Pen.Brush Property
</h2>
<hr width="600" align="left" color="DarkBlue" />
<asp:Image
ID="Image1"
runat="server"
/>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Pen Brush Property"
Height="45"
Font-Bold="true"
ForeColor="DarkBlue"
/>
</div>
</form>
</body>
</html>

- How to use Graphics.ExcludeClip method
- How to fill the interior of an ellipse
- How to measure the specified string
- Initialize a new instance of the pen class with brush
- Initialize a new instance of the Pen class with color
- How to use Pen LineJoin property
- How to use Pen DashCap Round
- How to set change Pen color
- How to create Pen custom dash pattern
- How to use Pen DashOffset