bwells Posted March 1, 2003 Posted March 1, 2003 How can I draw a gradient, in a panel (bitmap?) that goes from black to white from left to right? I can create the bitmap easliy enough, but I thought there might be an easy way to draw such a gradient with GDI+ so I can resize it as needed. thanks Bryan Quote
*Gurus* divil Posted March 1, 2003 *Gurus* Posted March 1, 2003 Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint Dim b As Brush b = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Panel1.Width, 0), Color.Black, Color.White) e.Graphics.FillRectangle(b, Panel1.ClientRectangle) b.Dispose() End Sub private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Brush b; b = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(panel1.Width, 0), Color.Black, Color.White); e.Graphics.FillRectangle(b, panel1.ClientRectangle); b.Dispose(); } Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
bwells Posted March 1, 2003 Author Posted March 1, 2003 Is it faster and more efficient in a program to draw a linear gradient, or to create the gradient as a jpg and put it in a picture box? The graident I am using is 512x50 so it is not very big. Quote
*Gurus* divil Posted March 1, 2003 *Gurus* Posted March 1, 2003 The best way is to draw it yourself, like I showed you. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.