Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing icon color and size distortions when bundling a Visual Studio project template in a VSIX

We have created a VSIX that contains a number of project templates. In each template, the .vstemplate references the icon image file like this:

  <Icon>TemplateIcon.png</Icon>

Here are examples of such PNGs:

enter image description here enter image description here enter image description here

I literally dragged these three images directly from the template project - the very same files that will be compiled into the VSIX.

It's hard to tell here, but the upper-left and bottom-right corners are transparent, and the inside of the blue is filled with white.

When I compile the VSIX, all of the templates are correctly installed and they all work fine. However, the icons in the New Project dialog are different:

enter image description here

The transparent corners look fine, but the inside white has turned to black, and in the third icon appears shrunk.

I've tried GIF and ICO formats to no avail (the GIF version didn't shrink, but it did replace white with black). Also, the images above are 64x64. I tried using 32x32 (the actual size of the icons in the dialog). Got the same results.

Can you help me get the images into the New Project dialog as intended?

like image 402
biscuit314 Avatar asked Mar 12 '23 01:03

biscuit314


1 Answers

Setting the top right pixel of each icon to RGBA # 00 FF FF 01 might help. (Cyan color that's almost transparent.) This will tell Visual Studio not to transform your icons. Setting the alpha channel (opacity) to 00 does not work - that's why it is 01. And with FF you'd make the cyan pixel visible.

It works for us with VSiX menu command icons. (https://msdn.microsoft.com/en-us/library/bb165158.aspx)

You can find some information also here https://msdn.microsoft.com/en-US/library/mt628927.aspx. Look for "AllowColorInversion". Maybe that's more relevant for you.

Let me thank to @Newrad0603 and @lishu from https://gitter.im/Microsoft/extendvs for helping me to put this together.

like image 188
Antonín Procházka Avatar answered Mar 19 '23 00:03

Antonín Procházka