We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Alpha blending in Taskbar

Thread ID:





1750 Nov 22,2002 12:32 PM UTC Dec 23,2002 12:24 PM UTC WinForms 6
Tags: Tools
Administrator [Syncfusion]
Asked On November 22, 2002 12:32 PM UTC

Hi, I am using XPTaskbar. I would like to get MSN Messenger 5.0 "I want to .." section kind of look for the taskbar (not the taskbar box). It has a navy blue kind of gradient and some bg image. How do I alphablend a background image with a bg gradient color in XPTaskbar? thanks, - Reddy

Administrator [Syncfusion]
Replied On November 22, 2002 01:58 PM UTC

Hi, Handle the Paint message of the XPTaskBar and do the following in the handler: 1) Draw the Gradient: Use the LinearGradientBrush to draw the gradient bg. The following link in MSDN should tell you how to do so: ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/_gdiplus_creating_a_linear_gradient_usecsharp.htm Topic: "Creating a Linear Gradient" 2) Draw the image semi-transparently: First designate a color for the portion in your bitmap that will be fully transparent. Then while drawing swap that color with Color.TransparentColor as per the following faq: http://www.syncfusion.com/faq/winforms/search/673.asp 33.3 How can I swap colors in a bitmap or icon Also, to draw the image semi-transparently, refer to this faq: http://www.syncfusion.com/FAQ/WinForms/FAQ_c3c.asp#q786q 33.7 How to draw a faded image? Combine the above to faqs to draw your image. Please do post the resulatant code here, if you can. Regards, Praveen Ramesh

Administrator [Syncfusion]
Replied On December 13, 2002 05:07 PM UTC

Ramesh, Thanks for the help. I got it to work. I had to extend XPTaskBar and override OnPaint event. Here is the resultant code... You may want to add this to the samples in future tools release. It looks pretty cool !! cheers, - Reddy ------------------------------ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Rectangle rc = this.ClientRectangle; int gradientWidth = 18; LinearGradientBrush linGrBrush = new System.Drawing.Drawing2D.LinearGradientBrush( new Point(0, 10), new Point(gradientWidth, 10), Color.FromArgb(255, 237, 241, 242), // Opaque Color.FromArgb(255, 42, 78, 129)); // Opaque float[] factors = {0.0f, 0.3f, 0.4f, 0.8f, 1.0f}; float[] positions = {0.0f, 0.1f, 0.2f, 0.4f, 1.0f}; //Create a Blend object and assign it to linGrBrush. Blend blend = new Blend(); blend.Factors = factors; blend.Positions = positions; linGrBrush.Blend = blend; // draw the gradient on the left edge e.Graphics.FillRectangle(linGrBrush, 0, 0, gradientWidth+5, rc.Height); // draw a filled rectangle rest of the area using (Brush brush = new SolidBrush(Color.FromArgb(42, 78, 129))) { e.Graphics.FillRectangle(brush, gradientWidth, 0, rc.Width-gradientWidth, rc.Height); } linGrBrush.Dispose(); // get the image from a resource file System.Resources.ResourceManager rm = new System.Resources.ResourceManager( "ControlsLibrary.Images", System.Reflection.Assembly.GetExecutingAssembly()); Image gearsImage = (Image)rm.GetObject("transparent_gears.gif"); ImageAttributes ia = new ImageAttributes(); ColorMatrix cm = new ColorMatrix(); cm.Matrix00 = 1; cm.Matrix11 = 1; cm.Matrix22 = 1; float transparancy = .14f; cm.Matrix33 = transparancy; ia.SetColorMatrix(cm); int imgWidth = gearsImage.Width; int imgHeight = gearsImage.Height; Rectangle destRect = new Rectangle(rc.Width-imgWidth, rc.Height-imgHeight, imgWidth, imgHeight); e.Graphics.DrawImage(gearsImage, destRect, 0, 0, imgWidth, imgHeight, GraphicsUnit.Pixel, ia); }

Administrator [Syncfusion]
Replied On December 16, 2002 12:28 PM UTC

Reddy, Thanks for the code! Yes, the effect does look very good. Does your gif have any transparency info (that might make the resultant bg much better)? If so and if you can, please do attach it here. Thanks Praveen Ramesh

Administrator [Syncfusion]
Replied On December 16, 2002 01:09 PM UTC

Praveen, I am attaching my example VS.NET Solution zip file. It contains the code and the image (B&W Image with transparent bg color). Before I came up with this code, I tried setting bg image for the taskbar. But the problem is that the bg image is tiled when ever the size of the taskbar is changed. So, I had to do my own painting. cheers, - Reddy

Administrator [Syncfusion]
Replied On December 18, 2002 05:19 PM UTC

Thanks for the sample. It looks very good. Would you mind if we ship this along with our samples? Thanks Praveen Ramesh

Administrator [Syncfusion]
Replied On December 23, 2002 12:24 PM UTC

Praveen, Sure... go ahead and ship it as a sample. I think all the developers should share these kinds of samples. cheers, - Reddy


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon