Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a file, "multi.ico" which has four images of different sizes (16x16, 24x24, 32x32, 48x48). Each sized image is a different color, to make it easy to tell which size we are dealing with. This file has been inserted into a resource file "Multi.resources" using Lutz Roeder's .NET Resourcer.

 

I need to be able to extract the ico from the .resource file in such a way as to keep all four sizes of images. Ideally, I would like to have a wrapper class around the .ico object which allows selection of the image of the proper size.

 

I have a working wrapper that I can use with a standalone .ico file (multi.ico), but my company system has a lot of images, and we need to be able to bundle them into .resource files for distribution.

 

Can anybody show me a piece of code which would take a.resources and extract the 16x16 version of a contained .ico file. I can't seem to get at anything but the 32x32 sized image.

  • Administrators
Posted
.Net's Icon class can probably do what you are after. If you look at the various constructors an Icon can be created from a resource stream and you can also specify your desired size - if the icon contains multiple resolutions then it will pick one based on your requested size.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Can you give me an example? Bearing in mind that what I am working with is a standalone .resource file, and that the resource file contains multiple .ico files. The stream needs to be opened at the beginning of the correct icon.
Posted
This code works fine if the icon comes from a single image .bmp, .ico, .png file, but if the file contained in the .resource file is a multi-image .ico (a single .ico with multiple images of different sizes inside) you end up with just one of those sizes. In a file with 16x16, 24x24, 32x32 and 48x48, the image I get in the Icon is always the 32x32 image. No matter what sort of size adjustments you do on the Icon or how you manipulate it, the image doesn't change. It is always the 32x32, just resized.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...