How to make the area on the thumbnail of the taskbar transparent in Windows 7?

I am developing a program that uses the functions of the Windows 7 (and Vista) taskbar. Right now I have a custom bitmap that will be displayed in the taskbar thumbnail. A bitmap is created programmatically and displayed successfully. The only problem I am facing is that you want to use transparent in this image, which should also be transparent in thumbnail. But without any success, the result was a standard color Light Gray .

I saw evidence that programs are successfully becoming transparent in their images:


Now my question is: how do I get transparency in my thumbnail?


I will populate the image with the Graphics class, so anything is allowed.
It is worth mentioning that I am using the Windowsยฎ API Code Pack , which uses GetHbitmap to set a thumbnail image.

EDIT:
To do this, this is the code I use atm:

 Bitmap bmp = new Bitmap(197, 119); Graphics g = Graphics.FromImage(bmp); g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(0, 0, bmp.Width, bmp.Height)); // Transparent is actually light-gray; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.DrawString("Information:", fontHeader, brush, new PointF(5, 5)); bmp.MakeTransparent(Color.Red); return bmp; 
+4
source share
2 answers

What pixel format is your bitmap? If it does not have an alpha channel, you cannot store transparency information in your image.

Here's how to create a bitmap with an alpha channel and make it transparent by default:

 Bitmap image = new Bitmap(width, height, PixelFormat.Format32bppArgb); using(Graphics graphics = Graphics.FromImage(image)) { graphics.Clear(Color.Transparent); // Draw your stuff } 

Then you can draw whatever you want, including translucent things, using the alpha channel.

Also note that if you are trying to draw transparency over an existing opaque material (say, to make a hole), you need to change the layout mode:

 graphics.CompositingMode = CompositingMode.SourceCopy; 

This will make any color that you use to rewrite it in the image, not mix with it.

+2
source

System.Drawing.Bitmap supports the alpha level. So the easiest way is

 Graphics g = Graphics.FromImage(bmp); g.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, bmp.Width, bmp.Height)); // Transparent is actually light-gray; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.DrawString("Information:", fontHeader, brush, new PointF(5, 5)); 

however, you can also have partial transparency by replacing Brushes.Transparent with

 new SolidBrush(Color.FromArgb(150, 255, 255, 255)); 
0
source

Source: https://habr.com/ru/post/1341506/


All Articles