Imported icon into Visual Studio 2013 looks terrible - visual-studio

-- I'm using Visual Studio 2013 --
I have an icon with transparent background. It was created in Photoshop as an 8-bit RGB image and exported to .ico via the free telegraphics ICO Format plugin. I saved out 16, 24, 32, 40, 48, 64, 96, 128 and 256 resolutions versions and then used another free telegraphics plugin to bundle them into a single .ico file with all the resolutions.
When I use Windows 10 to apply this .ico file as the icon for a shortcut it looks great. But when I try to import this icon into a Visual Studio C++ project and embed it into my EXE it looks terrible. By "terrible" I mean it looks choppy/pixelated and there appear to be random colors in several pixels. It just looks awful.
To import into my VS project I right-clicked the project in the VS "Solution Explorer" and chose Add --> Resource. In the Add Resource window I selected "Icon" and then used "Import..." to bring in my .ico file. After the import, I can see all the different resolutions of the icon were found, but like I said - they look terrible. Most of the problems of random colored pixels appear to take place along transparent edges of the image. (I have text with transparent background).
And when I actually build the EXE, it appears Windows only shows the smallest resolution (16x16) version of icon no matter what my view thumbnail size is.
This is only a problem when trying to use my icon in Visual Studio and building the EXE. Like I said, if I wait until after building the EXE and then use Windows to manually assign this icon it looks fine.

Related

Modify Toolbar for MFC MS Visual Studio 2019 app with Gimp

I'm trying to modify a toolbar's BMP file with GIMP 2.10.24 (tried with 2.9, too) for a MFC application in Visual Studio 2019's resource editor.
Using these explanations, I can save the BMP file so that it opens in Visual Studio.
I also set the mode to RGB and made sure there is no alpha channel.
The title of the MS VS editor reads
0x0, 1 bit, BMP
just like before.
The app builds OK, but when I run it,
VERIFY(toolBar->LoadToolBar(nID));
fails with an exception.
Is there anything else I need to do to make my toolbar load again?
Thanks in advance!
I finally worked out a solution that works with recent versions of GIMP (thanks to everyone who contributed!):
Do NOT convert to RGB! The confusion comes from the fact that ‘Advanced options’ is only active if you convert to RGB, but you do not need the advanced options. Maybe that changed at one point in MSVS or in GIMP, because explanations on different forums are confusing about this point...
Image/Mode -> Indexed colors (DO NOT CHANGE THIS)
File/Export as ... :
Run-Length encoded : do not check
Compatibility options : do not write color space information : check
Advanced options : is not accessible, but that DOESN'T MATTER !
Additional trick: you can copy-paste the buttons of toolbars (not the entire toolbar) one by one from Gimp to VS (if the color settings in Gimp are as explained above ; if not, you loose / mix up the colors).
Tested with Microsoft Visual Studio 2019 enterprise edition and GIMP 2.10.

Problems with fonts in Visual Studio, bad quality

Since I started using visual studio I have been having a problem with all fonts.
They just all look bad in Visual Studio, as if they have too many pixels.
In the image below, the first line is a normal font, as it should be. In the second line is Visual Studio, the same font, same size, but very ugly, it even seems to be stretched.
The only way I found to get around this is to go to other programs like Adobe XD, put the text I want and save it as an image, then I go to Visual Studio and put it as an image.
But, this is a problem, since if I want to change the text size or change the content of the text it will not be possible.
Edit:
In program.cs I changed the following line to true and improved it a lot:
Application.SetCompatibleTextRenderingDefault(true);
I think it can still improve.

How do I edit the ico file Visual Studio creates for me?

In Solution Explorer, Right click -> Add... Icon file.
The file gets created, but looking at it in Visual Studio, it is uneditable. It includes multiple mips. If you open in external editor, it opens paint. If you then make changes and save it, it asks to save it elsewhere and doesn't affect the original ico.
The thing is, I'm sure this has worked for me before. I'm just not sure what's happening now. Can anyone enlighten me?
The issue you're experiencing is that Visual Studio does NOT know how to edit PNG targets - even though it adds them to your ico by default.
You'll notice that if you have the image edit bar up, you can in-fact edit the BMP target ones (including pasting over from a more capable image editor 😀). Further oddness on visual studio's part, you don't appear to be able to add back the PNG targets, so if you delete them they're gone forever unless you have an external ICO editor (which I assume would mean you wouldn't be using the VS one anyway).
Your best bet if you're committed to continuing in VS (several free websites available that will do this for you given some images) is to clear out the unused versions, and add BMP targets for the sizes you care about. The max for BMP is 24 bit, so be aware, but you should be able to keep a fair amount of fidelity, and still keep your transparency (there is a transparent color, and if you paste in with transparency the editor will automatically fill that in for you) - all while keeping the same sizes as the PNG targets.
Hope that helps!

Why does the icon for my project look so horrible in Windows 7?

I have an old VB6 project that I updated for Windows 7, including icons with 48x48 size. When I run it, the icon in the task bar appears washed out.
I think I have all the necessary icon sizes in the .ico file, but maybe I am missing something:
What am I missing here?
VB6 only supports 16 color icons which will cause dithering and, consequently, the transparency information is limited to a single bit indicating whether a pixel is transparent or not.
As always, you can rely on a set of Windows' APIs to overcome this limitation.
Here's a link to a forum post explaining how to use 256 color icons: VB6 System Tray Icon Color Depth
I found a vbaccelerator article from the XP days that seems to work in Windows 7 as well. The key is to follow the instructions to the letter. And it only works in a compiled app, not in the IDE. Finally, when you add a 256x256 image to your icon, make sure that it's not PNG compressed when the icon is saved (most editors have a preference for that hidden away somewhere).
The solution is very simple:
Enable visual styles; add manifest to your application and the VB IDE.
Adding manifest to the VB IDE is a bit tricky in Vista and above. Follow instructions here:
http://vbnet.mvps.org/index.html?code/forms/vbidevista.htm
Then, to add the manifest to your application.
This will also enable you to make your application start as elevated (Have Admin access when started):
Step 1: Create your manifest text-file.
There are 2 options: The normal manifest-file, and a manifest-file for requiring Admin-privileges.
Manifest File:
(Download link at the end)
Manifest Admin File:
(Download link at the end)
Once you have created your manifest-file, add it to your project:
Open the Resource Editor, and click "Add Custom Resource..." (The button next to the question-mark).
Select your manifest-file and add it to the editor.
Now, double-click on the newly added resource, to edit it's properties.
Set these values:
Type: #24
ID: 1
Now, here is the last and most important step:
Set your project to start with Sub Main.
In Sub Main, as one of the first things, you call the function InitCommonControls.
This HAS TO BE CALLED before any Forms, Controls or other Dialogs are loaded!
InitCommonControls:
(Download link at the end)
That's it!
Your VB6 is not fully up to date and using visual styles.
Download link, as promised:
https://www.dropbox.com/sh/neyueoozv87k1qd/AACbID8_aC718LCjs12T16Oqa?dl=0

'Size to content' in Visual Studio resource editor and Luna/Windows 7/Classic theme

I've been having problems with text being truncated from static controls when I run my app on Windows 7, even though it shows fine on my development machine which runs XP with Classic Look (Windows 98).
I decided to make an experiment, and loaded my project in Visual Studio on a Win7 machine, and when I clicked 'Size to content' on a static control, its width became bigger, even though I had used 'Size to content' on Visual Studio with Classic Look theme.
I know that the resource editor uses real window controls to show you the dialog, and they are painted with whatever theme is set on your machine.
Is it possible that 'Size to content' depends on what theme you have set? With what theme should I test to make sure text always fits in the static control?
Just off the cuff here, but it sounds like "size to content" occurs at design-time rather than run-time. So if you design on Windows 7, it will size to content there. Look in the .design. file and you should see the size of each control assigned as an integer, so the size does not change based on the run-time environment.
QUICK ANSWERS: Leave lots of extra space or move to WPF.

Resources