Resizing Icons in Win32

Started by
6 comments, last by benryves 18 years, 7 months ago
Hey, I'm working on a project where I need to resize a 32x32 icon to 24x24 as well as 16x16 in a few instances. Is there a function that can resize the icons that isn't DrawIconEx? DrawIconEx works, but the image is horrible quality. There must be an image resizing function in windows... Anyone have any ideas? One thing I was thinking of doing was rendering the icon to a device context at the normal size, then resizing it using GDI or something, there must be a way to resize bitmaps in Win32.
Advertisement
When working with images of that size pretty much any automated resizing is going to look like crap. Unless your icon is a big square or something like that. I'd recommend just biting the bullet and manually creating icons of the right size.
Quote:Original post by SiCrane
When working with images of that size pretty much any automated resizing is going to look like crap. Unless your icon is a big square or something like that. I'd recommend just biting the bullet and manually creating icons of the right size.

That's not an option, unfortunately. The application is similar to the MS Office Toolbar; it shows the contents of a directory on a toolbar that can be docked on the side of the screen.
Recreate the icon from the original large image (don't scale from 32x32)?
Quote:Original post by Daniel Miller
Recreate the icon from the original large image (don't scale from 32x32)?

I don't understand what you mean. I'm loading the icons that the application shows by using ExtractAssociatedIcon. There are no large images to use.
The image, whether it be big or small is going to look bad distorted. There's no win32 function to apply any sort of interpolation to make a distored image/icon look more proportional. If you only resize certain icons that come with your program, then you should just have copies of them at different sizes what were shrunk with something else that didn't just shrink it. If you're having your program accept icons from the user, i.e. you can't just have copies of some icons at different sizes in your program, then you probably need to look into bilinear interpolation or gaussian blur technique. Surely there's source or documentation out there for you to learn from.
GDI+ has a number of quality settings to use when resizing. the more computationally expensive ones, bilinear and bicubic, yield reasonably good results when resizing from a small image to an slightly smaller one, especially if pre-filtering is used, so i would think resizing from 32 to 24 would work okay. i don't know about 32->16 though.
Quote:Original post by Mercury
I don't understand what you mean. I'm loading the icons that the application shows by using ExtractAssociatedIcon. There are no large images to use.


Eh, they looked really crap for me (I tried using that call myself). If you look in my journal there is some VB.NET code (should be easy enough to follow!) that runs through the registry to get the correct icon so you can then use ExtractIconEx to extract the icon "properly". Note that under WindowsXP the alpha blended icons are not converted properly when using the Icon.ToBitmap call, but I assume that you're not doing it that way.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

This topic is closed to new replies.

Advertisement