How to use PathGradientBrush WrapMode Property

Here The code To Create Page like picture above.

The code behind

       protected void Button1_Click(object sender, EventArgs e)
            Bitmap bmp = new Bitmap(600, 300);
            Graphics g = Graphics.FromImage(bmp);

            GraphicsPath gPath = new GraphicsPath();
            Rectangle rect = new Rectangle(0, 0, 100, 100);

            PathGradientBrush pathGradientBrush = new PathGradientBrush(gPath);
            pathGradientBrush.CenterColor = Color.Crimson;

            Color[] colors = { Color.Snow, Color.IndianRed };
            pathGradientBrush.SurroundColors = colors;
            pathGradientBrush.WrapMode = WrapMode.Tile;

            Rectangle rect2 = new Rectangle(0, 0, 300, 300);
            g.FillRectangle(pathGradientBrush, rect2);

            pathGradientBrush.WrapMode = WrapMode.TileFlipXY;
            Rectangle rect3 = new Rectangle(300, 0, 300, 300);
            g.FillRectangle(pathGradientBrush, rect3);

            String path = Server.MapPath("~/Image/PathGradientBrushWrapModeProperty.jpg");
            bmp.Save(path, ImageFormat.Jpeg);

            Image1.ImageUrl = "~/Image/PathGradientBrushWrapModeProperty.jpg";

Page aspx code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <h2 style="color: WindowText; font-style: normal;">
            How to use PathGradientBrush WrapMode Property
            PathGradientBrush.WrapMode Property
            .NET GDI+ Graphics
        <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 PathGradientBrush WrapMode Property"
            Height="45"  />

NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Popular posts from this blog

Example to disable save as certain file type in SSRS Report Viewer

Phone book application example - Java

Modal Popup Message Box ASP.NEt C# Example