Here is an image of what I am trying to achieve:
As you can see, there is a slight reflection under the progress bar.
I have a custom progress bar that is heavily based on this code:
http://www.codeproject.com/Articles/19309/Vista-Style-Progress-Bar-in-C
Note: My code is in VB.
Problem - I would like to draw a reflection of that progress bar under it so it looks similar to the image I have given above. I have been told that one way to do it is using pixels, which need to be done manually. Is that the only option? Is there any other/easier way to do it?
I appreciate your help. Thanks!
Are you looking for something like this?
Here is the code:
Dim pgBarReflection As New Bitmap(ProgressBar1.Width, 20)
ProgressBar1.DrawToBitmap(pgBarReflection, ProgressBar1.ClientRectangle)
For x As Integer = 0 To pgBarReflection.Width - 1
For y As Integer = 0 To pgBarReflection.Height - 1
Dim alpha = 255 - 255 * y \ pgBarReflection.Height
Dim clr As Color = pgBarReflection.GetPixel(x, y)
clr = Color.FromArgb(alpha, clr.R, clr.G, clr.B)
pgBarReflection.SetPixel(x, y, clr)
Next y
Next x
Me.CreateGraphics.DrawImage(pgBarReflection, New Point(ProgressBar1.Left, ProgressBar1.Bottom + 10))
If you want greyscale shadow, replace this line
clr = Color.FromArgb(alpha, clr.R, clr.G, clr.B)
with these two:
Dim greyScale As Integer = CInt(clr.R * 0.3 + clr.G * 0.59 + clr.B * 0.11)
clr = Color.FromArgb(alpha, greyScale, greyScale, greyScale)
You will get something like this:
You can play with parameters to make the shadow more realistic.
Solution is based on this article:
Draw an image with gradient alpha (opacity) values in VB.NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With