News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Icon scaling

Started by kkurkiewicz, September 14, 2023, 07:19:37 AM

Previous topic - Next topic

kkurkiewicz

According to this guide on icon scaling, when creating a new icon for a Windows application, it is necessary to provide – at minimum – the sizes 16x16, 24x24, 32x32, 48x48, and 256x256 because if there's no pixel-perfect match, Windows will display the icon only after scaling it down based on where the icon is intended to be rendered in the application window. However, I've noticed that loading some icons using the LoadImageA function blurs them to such an extent that I feel there is something wrong:



The image shows a fragment of the "open recent" window of IDA Freeware 8.2, while the second fragment shows what I get when I load the exact same (128px) icon into my program using the following call to LoadImageA:

    PUSH  10h              ; LR_LOADFROMFILE
    PUSH  128              ; Height
    PUSH  128              ; Width
    PUSH  1                ; IMAGE_ICON
    PUSH  OFFSET ICONNAME  ; C:\Program Files\IDA Freeware 8.2\ida.ico
    PUSH  0
    CALL  LoadImageA@24

Is it possible to somehow reduce the amount of scaling while loading icons from standalone filesapplied to scaled icons?
Kamil

zedd151

#1
Does ida.ico have an icon of that size 128x128 in it?  I don't have that program, so I cannot check this myself.
If not, it would be resized from an icon that it does have.

I would use Resource Hacker to view ida (the executable) in it, to see what size are the icons in the ida.ico icon group.


A little later... after thinking about it....
That didn't make sense, since the icon is in ida's directory. You would need an icon editor to see then, the sizes of the icons in ida.ico. 
No guarantee that it will have a 256x256 icon in it. No matter what Microsoft recommends.

jj2007

QuoteApps should have, at the bare minimum: 16x16, 24x24, 32x32, 48x48, and 256x256. This covers the most common icon sizes, and by providing a 256px icon, ensures Windows should only ever scale your icon down, never up.

Oh Micro$oft... the bare minimum used in practice is 32x32 for the Alt Tab icons. Which is perhaps the least frequent use of icons.

The most frequent use is captions, and they are 16x16 - see screenshot, the one to the right. So don't worry, Windows will upscale your 16p icons to 32p, and that's enough. Btw the main difference between the Ms Edge icon and the others is the number of colours used: 7 for the eye, 10 for the "big" PaintShop icon, and 558 for the Ms Edge icon.


NoCforMe

Speculating here, couple of ideas:

  • 128x128: doesn't seem like anything like a standard size for icons. Maybe the problem is trying to scale that odd size down? Although you do show that the other icon looks OK. Is that other icon the same size? how can you be sure of that? Do you have the actual icon file?
  • What is the actual (displayed) size of that icon you show? Maybe scale that icon down that size, using an icon editor, try that one instead? (It should be one of the standard sizes you listed. I can't imagine it's any larger than 32x32; 48x48 is huge.)

If you don't have an icon editor, you could try Axialis (30-day free trial), or IcoFX (unlimited free use). Axialis seems by far a better package, including lots of sample icons.
Assembly language programming should be fun. That's why I do it.

zedd151

Part of the issue is, I believe, no control over which icon in a multi icon group is loaded by LoadImage. The same for LoadIcon, I would think.

HSE

IDA free in 64 bits have 4 icon size: 16x16, 32x32, 48x48 and 256x256.

Are you sure that your program have only 1 icon size?
Equations in Assembly: SmplMath

NoCforMe

Quote from: jj2007 on September 14, 2023, 08:48:09 AMSo don't worry, Windows will upscale your 16p icons to 32p, and that's enough.

But but but ... won't that look crappy, upscaling to twice the resolution? The OP is concerned about the appearance of icons here.
Assembly language programming should be fun. That's why I do it.

Caché GB

IDA Pro 64


Hi kkurkiewicz
This icon "shark.ico" has 16x16, 32x32, 48x48, 64x64, 128x128 all 32bit bmp.
Test with it to see  results
Caché GB's 1 and 0-nly language:MASM

kkurkiewicz

The size of the icon saved in ida.ico definitely is 128x128, and, as far as I can tell, that's the only version of the icon that's provided because inspecting ida64.exe with Resource Hacker also gives me only that one icon. In the snippet, I'm loading it using LR_LOADFROMFILE, but turning the icon into a resource and then loading it by ordinal or name – using either LoadImageA or LoadIconA – gives me the exact same result, and the same thing happens with other icons too. Obviously, IDA is not written in assembly, but is it possible that, when ida64.exe is run, the icon is loaded in some other way?
Kamil

kkurkiewicz

Quote from: NoCforMe on September 14, 2023, 11:30:47 AMWhat is the actual (displayed) size of that icon you show?
As far as I recall, the displayed size is 32x32.
Kamil

jj2007


fearless

Also worth looking at these two functions: LoadIconMetric and LoadIconWithScaleDown

  • https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconmetric
  • https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown

kkurkiewicz

#12
Quote from: jj2007 on September 14, 2023, 07:08:40 PMDisplayed where?
On the left side of the title bar, just as in my original screenshot, but I "measured" it only in Paint—that is, I took a screenshot, opened it in Paint, enlarged the image to 1400%, drew a straight line next to the icon and read the size off the status bar :smiley:
Kamil

Biterider

Hi fearless
Quote from: fearless on September 14, 2023, 07:38:04 PMLoadIconMetric and LoadIconWithScaleDown

Thanks for the link, very useful.
I was not aware of these APIs. I read the documentation and it occurred to me that for some reason, MS does not provide the ANSI version.

Biterider

NoCforMe

#14
Quote from: kkurkiewicz on September 14, 2023, 06:26:03 PM
Quote from: NoCforMe on September 14, 2023, 11:30:47 AMWhat is the actual (displayed) size of that icon you show?
As far as I recall, the displayed size is 32x32.

Well, that being the case. how about scaling the icon yourself to that size and trying it?

What's happening is that someone (the little man inside the GDI* engine) is scaling the 128x128 icon to 32 square, and not doing a particularly good job of it. Dunno if you can improve things by doing the scaling yourself beforehand, but maybe worth a try.

* I should say GDI+, or that other more newfangled Windoze graphics protocol that I'm totally unfamiliar with.
Assembly language programming should be fun. That's why I do it.