Icon with different resolution in MSVC2010 - c++

ALL,
I am making an application where I need to use an icon.
I have 2 icon files: myicon-16.ico and myicon-32.ico. First has resolution 16x16 and second - 32x32.
Now when I opened MSVC 2010 project (C++) I see that the default icon file has 2 icons combined, i.e. it has a resource for 16x16 and 32x32 in one file. What I mean is when I open the resource file in Visual Studio solution and click on the standard icon I see many different resolution for the icon. And I can select each and the bitmap (icon) will be displayed with an appropriate resolution. But when I open the rc file in the text editor I see only 2 lines: one with my own icon and one with the standard icon "IDI_SMALL".
What I need to do to make the same thing with my 2 files? What I want is when I open resource file in VS and click on my icon resource I want to see 2 icons with 16x16 and 32x32 resolutions. AFAIU, I can only place an additional icon resource in the rc file. Or I am wrong?
Please advise.

You can use VS2010 to add additional image types in your ico file. Just open an ico file with VS2010. Say, open myicon-16.ico. You will see just one icon there - 16x16. Now open menu Image->New Image Type (or use right click->New Image Type, or use keyboard shortcut Ins). You will be presented with a choice ranging from 16x16 1 bit to 128x128 24 bit. Just insert as many as you like.
For your case you need to insert an empty 32x32 into myicon-16.ico, then copy and paste from your 32-pixel file.
On the side note. Who draws the icons nowadays. Just google free icons, and you will find tons of icon libraries on the Internet with sizes from 16x16 to 256x256 png.

Yes, you need to combine your images into one ICO file that has all the data.
From Wikipedia:
ICO files contain one or more small images at multiple sizes and color
depths, such that they may be scaled appropriately.
There are many image editors that can do this, personally I've used GIMP to create multi-layered png files, and then save as .ico to get the final result.
You also should be able to right click in the list of image sizes in VS2010 and then click "New Image Type" to add different resolutions within the built in ICO editor. You can then copy and paste your image data from another editor into Visual Studio.

Related

C++ Win API Specify Custom toolbar Bitmap?

Picture and c++ files can be found here: http://phantomworksstudios.com/cpp/ss/
Ok so I have been having a lot of problems with my toolbars. such as them not displaying correctly, can't set the button size via height and width no matter what I do, the bitmaps are off set by 1 pixel to the right which are the back,forward,stop, etc icons. and the other icons such as the clip board and new file which is the last tool bar under the rest are cut off bad. I think its still trying to strip the tool bar list as 16x16 but the bitmap I have icons as 14x14.
The icons are within a bmp file which is 32 bit depth
one is 16x16 while the last one is 14x14
I have no idea what is going on and no matter what I can't seem to get it working like it should:

How to Set Icon in a Windows Application using Visual Studio

I want to add an icon to my application. I have added an icon resource. and its working file for the first icon. That means after I have compiled, the 16x16 icon of the exe file is same as the icon file used. but when the explorer window is zoomed to large icon size, then the icon of the exe file vanishes and another blank default icon is displayed.
How to set icon for large as well as small size display?
From your comments, it sounds like you have multiple icon files set for your project. That's not going to work the way you want, or at least it's the really hard way of doing it.
The simple way is to let the operating system handle it for you. Create a single icon file that contains multiple icon sizes. 16x16, 32x32, 48x48, and 256x256 are the minimum sizes needed for current versions of Windows, but you can certainly add more (like 24x24 or 128x128) to improve pixel fidelity at those sizes if desired.
You can use Visual Studio to create the icons. Opening an .ico file should automatically open its icon resource editor. But I personally find it difficult or cumbersome to use. I highly recommend using a third-party program like IcoFX to create your icons and push pixels around.

Selecting an icon from an image grid

I have a grid of icons and I want to select an individual icon and save it in separate image file. The image doesn't need to be processed further just simply split apart. Any thoughts on how to let the computer do this work for me?
For Windows, Bitmap::Clone will do it for you. MSDN Link

In resources of a executable file, how does one find the default icon?

i need to find the default icon of a windows executable (PE file = dll, exe, com..) programatically. I do know how to walk throught the resources and identify what is an icon, what a cursor etc, but as far as i know none of the icons is in any way marked as the default one. So, does somebody know, how to find the default icon? Moreover, i do not want to use any windows api call, i want to code the function myself. The problem is that i don't know which one of all the icons is the default one.
After a lot of searching, i found out that the default icon is not the one with the lowest id.
Windows use several sizes of one icon for various things. For more information, look here, but in short here is the important information:
When the system displays an icon, it must extract the appropriate icon image from the .exe or .dll file. The system uses the following steps to select the icon image:
Select the RT_GROUP_ICON resource.
If more than one such resource
exists, the system uses the first
resource listed in the resource
script.
Select the appropriate RT_ICON image
from the RT_GROUP_ICON resource. If
more than one image exists, the
system uses the following criteria
to choose an image:
The image closest in size to the
requested size is chosen.
If two or more images of that size
are present, the one that matches the
color depth of the display is chosen.
If no images exactly match the color
depth of the display, the image with
the greatest color depth that does
not exceed the color depth of the
display is chosen. If all exceed the
color depth, the one with the lowest
color depth is chosen.
Note: The system treats all color depths of 8 or more bpp as equal. Therefore, there is no advantage of including a 16x16 256-color image and a 16x16 16-color image in the same resource — the system will simply choose the first one it encounters. When the display is in 8-bpp mode, the system will choose a 16-color icon over a 256-color icon, and will display all icons using the system default palette.
Since the requested size is 16x16 (because thats the system small icon size, ie. the default icon size) i think we can say that the default icon is the icon from the first icon group which has the smallest size (no smaller icon than 16x16 can exist) with the highest color depth.
EDIT: a small correction. A icon of size smaller than 16x16 might apparently be in the resources, but that indicates that the file does not have a default icon and the system then does supply its own icon instead.
The first one you find is the default one.
The default icon is simply the icon with the lowest id, so, by definition, is the first icon discovered when enumerating resources.

Visual Studio dialog editor not using square dimensions

So, I'm busy making a model viewer, I'm trying to get my dialog properly setup, and get my openGL view ports squared ( I'm using picture box controls for it ), one big problem. Visual studio doesn't allow me to set the the size manually, I can't see the actual pixel size. I can only see it in the bottom right corner of the screen but that's in dialog units not in pixel units and somehow that screw up terribly..
Look here for example, that selected thing should be a square according to visual studio, you can see in the bottom right corner it says "170 x 170" but you can clearly see it's nowhere near square, I can even test it by running my application, the openGL render gets squashed up and doesn't look right cause of the thing not being squared:
Screenshot:
http://i42.tinypic.com/xpsepf.jpg
Because I can't set it by hand I can't get it right.. I've also tried opening/editing the .rc in other resource editors but visual studio saves it with it's own type of compression which makes any other tool unable to open the file, I've tried ResourceHacker, ResourceTuner, Restorator, XYExplorer and even the WinASM resource editor which I used for my previous model viewer, all are unable to open the file.
Does anybody have an idea or know about an option in visual studio so I can see it's width and height..? I can if I make a dialog in WinASM studio for example.. VisualStudio should support this.
The resource editor works in DLU ( Dialog Logical Unit), not in pixels.
see this other question (and links included) : MFC Dialog Size Question
Max.