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); g.Clear(Color.White); GraphicsPath gPath = new GraphicsPath(); Rectangle rect = new Rectangle(0, 0, 100, 100); gPath.AddRectangle(rect); 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"; g.Dispose(); bmp.Dispose(); }
Page aspx code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color: WindowText; font-style: normal;"> How to use PathGradientBrush WrapMode Property System.Drawing.Drawing2D.PathGradientBrush PathGradientBrush.WrapMode Property .NET GDI+ Graphics </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 PathGradientBrush WrapMode Property" Height="45" /> </div> </form> </body> </html>
By Mohd Zulkamal
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 =)
0 comments:
Post a Comment